Renamed helper function or tab selector

This commit is contained in:
2024-09-05 12:31:54 +02:00
parent 26ccaa9bb4
commit 6d1fbc5af4
2 changed files with 9 additions and 9 deletions

View File

@@ -18,19 +18,19 @@ module ApplicationHelper
end end
end end
def operator? def operator_tab?
controller.class.name.split("::").first=="Operator" controller.class.name.split("::").first=="Operator"
end end
def admin? def admin_tab?
controller.class.name.split("::").first=="Admin" controller.class.name.split("::").first=="Admin"
end end
def profile_tab?
controller_name=="profiles"
end
def is_admin_or_operator? def is_admin_or_operator?
current_user.admin? || current_user.operator? current_user.admin? || current_user.operator?
end end
def profile?
controller_name=="profiles"
end
end end

View File

@@ -4,17 +4,17 @@
<nav> <nav>
<ul class="flex justify-center space-x-2 font-semibold items-color"> <ul class="flex justify-center space-x-2 font-semibold items-color">
<li class="relative"> <li class="relative">
<button class="px-4 py-2 cursor-default hover:text-hsrm-red border-b-4 <%= profile? && 'border-hsrm-red-light' %>"> <button class="px-4 py-2 cursor-default hover:text-hsrm-red border-b-4 <%= profile_tab? && 'border-hsrm-red-light' %>">
<%= link_to "Profil", profile_path %> <%= link_to "Profil", profile_path %>
</button> </button>
</li> </li>
<li class="relative"> <li class="relative">
<button class="px-4 py-2 cursor-default <%= current_user.admin? && 'hover:text-hsrm-red' || 'text-hsrm-gray-light' %> border-b-4 <%= admin? && 'border-hsrm-red-light' %>"> <button class="px-4 py-2 cursor-default <%= current_user.admin? && 'hover:text-hsrm-red' || 'text-hsrm-gray-light' %> border-b-4 <%= admin_tab? && 'border-hsrm-red-light' %>">
<%= link_to_if current_user.admin?, "Admin", admin_dashboard_path %> <%= link_to_if current_user.admin?, "Admin", admin_dashboard_path %>
</button> </button>
</li> </li>
<li class="relative"> <li class="relative">
<button class="px-4 py-2 cursor-default hover:text-hsrm-red border-b-4 <%= operator? && 'border-hsrm-red-light' %>"> <button class="px-4 py-2 cursor-default hover:text-hsrm-red border-b-4 <%= operator_tab? && 'border-hsrm-red-light' %>">
<%= link_to 'Operator', operator_jobs_path %> <%= link_to 'Operator', operator_jobs_path %>
</button> </button>
</li> </li>