|
|
@ -1,17 +1,17 @@ |
|
|
|
module NavigationItemsHelper |
|
|
|
module NavigationItemsHelper |
|
|
|
NavigationItem = Struct.new(:text, :href, :current, :classes) |
|
|
|
NavigationItem = Struct.new(:text, :href, :current, :classes) |
|
|
|
|
|
|
|
|
|
|
|
def primary_items(current_user) |
|
|
|
def primary_items(current_user, user) |
|
|
|
if current_user.support? |
|
|
|
if current_user.support? |
|
|
|
[ |
|
|
|
[ |
|
|
|
NavigationItem.new("Organisations", organisations_path, organisation_current?), |
|
|
|
NavigationItem.new("Organisations", organisations_path, organisation_current?), |
|
|
|
NavigationItem.new("Users", users_path, users_current?), |
|
|
|
NavigationItem.new("Users", users_path, users_current?(current_user, user)), |
|
|
|
NavigationItem.new("Logs", case_logs_path, logs_current?), |
|
|
|
NavigationItem.new("Logs", case_logs_path, logs_current?), |
|
|
|
] |
|
|
|
] |
|
|
|
else |
|
|
|
else |
|
|
|
[ |
|
|
|
[ |
|
|
|
NavigationItem.new("Logs", case_logs_path, logs_current?), |
|
|
|
NavigationItem.new("Logs", case_logs_path, logs_current?), |
|
|
|
NavigationItem.new("Users", users_organisation_path(current_user.organisation), users_current?), |
|
|
|
NavigationItem.new("Users", users_organisation_path(current_user.organisation), users_current?(current_user, user)), |
|
|
|
NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}", organisation_current?), |
|
|
|
NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}", organisation_current?), |
|
|
|
] |
|
|
|
] |
|
|
|
end |
|
|
|
end |
|
|
@ -31,7 +31,9 @@ private |
|
|
|
current?(controller, %w[case_logs form]) |
|
|
|
current?(controller, %w[case_logs form]) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def users_current? |
|
|
|
def users_current?(current_user, user) |
|
|
|
|
|
|
|
return false if current_user == user |
|
|
|
|
|
|
|
|
|
|
|
current?(controller, %w[users]) || current_action?(controller, "users") |
|
|
|
current?(controller, %w[users]) || current_action?(controller, "users") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|