Browse Source

fixed tab highlights

pull/627/head
JG 3 years ago
parent
commit
2ce7c9dfa4
  1. 6
      app/controllers/organisations_controller.rb
  2. 30
      app/helpers/navigation_items_helper.rb

6
app/controllers/organisations_controller.rb

@ -24,7 +24,11 @@ class OrganisationsController < ApplicationController
@pagy, @users = pagy(filtered_users(@organisation.users.sorted_by_organisation_and_role, search_term))
@searched = search_term.presence
@total_count = @organisation.users.size
render "users", layout: "application"
if current_user.support?
render "users", layout: "application"
else
render "/users/index"
end
end
def details

30
app/helpers/navigation_items_helper.rb

@ -4,24 +4,24 @@ module NavigationItemsHelper
def primary_items(path, current_user)
if current_user.support?
[
NavigationItem.new("Organisations", organisations_path, organisation_current?(path)),
NavigationItem.new("Organisations", organisations_path, organisations_current?(path)),
NavigationItem.new("Users", "/users", users_current?(path)),
NavigationItem.new("Logs", case_logs_path, logs_current?(path)),
]
else
[
NavigationItem.new("Logs", case_logs_path, logs_current?(path)),
NavigationItem.new("Users", users_organisation_path(current_user.organisation), users_current?(path)),
NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}", organisation_current?(path)),
NavigationItem.new("Users", users_organisation_path(current_user.organisation), subnav_users_path?(path)),
NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}", subnav_details_path?(path)),
]
end
end
def secondary_items(path, current_organisation_id)
[
NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", organisation_logs_current?(path, current_organisation_id)),
NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", organisation_logs_current?(path, current_organisation_id)),
NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", about_organisation_current?(path, current_organisation_id)),
NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)),
NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)),
NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)),
]
end
@ -32,18 +32,22 @@ private
end
def users_current?(path)
path.include?("/users")
path == "/users"
end
def organisation_current?(path)
path.include?("/organisations") && !path.include?("/users")
def organisations_current?(path)
path == "/organisations" || subnav_users_path?(path) || subnav_logs_path?(path) || subnav_details_path?(path)
end
def about_organisation_current?(path, organisation_id)
path.include?("/organisations/#{organisation_id}/details") || path.include?("/organisations/#{organisation_id}/edit")
def subnav_users_path?(path)
path.include?("/organisations") && path.include?("/users")
end
def organisation_logs_current?(path, organisation_id)
path == "/organisations/#{organisation_id}/logs"
def subnav_logs_path?(path)
path.include?("/organisations") && path.include?("/logs")
end
def subnav_details_path?(path)
path.include?("/organisations") && path.include?("/details")
end
end

Loading…
Cancel
Save