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
def operator?
def operator_tab?
controller.class.name.split("::").first=="Operator"
end
def admin?
def admin_tab?
controller.class.name.split("::").first=="Admin"
end
def profile_tab?
controller_name=="profiles"
end
def is_admin_or_operator?
current_user.admin? || current_user.operator?
end
def profile?
controller_name=="profiles"
end
end

View File

@@ -4,17 +4,17 @@
<nav>
<ul class="flex justify-center space-x-2 font-semibold items-color">
<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 %>
</button>
</li>
<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 %>
</button>
</li>
<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 %>
</button>
</li>