Implement disabled tabs
This commit is contained in:
parent
3f0e032c7a
commit
fd3c447dda
2 changed files with 29 additions and 9 deletions
|
@ -41,16 +41,24 @@ module ApplicationHelper
|
|||
def nav_tabs_list(scope_name, current_tab_name, format, options)
|
||||
tag.ul class: NAV_TABS_LIST_HTML_CLASS[format] do
|
||||
options.each do |(k, v)|
|
||||
concat nav_tabs_item scope_name, current_tab_name, k, v
|
||||
concat nav_tabs_item scope_name, current_tab_name, k, *v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def nav_tabs_item(scope_name, current_tab_name, tab_name, url)
|
||||
def nav_tabs_item(scope_name, current_tab_name, tab_name, policy, url)
|
||||
tag.li class: 'nav-item' do
|
||||
if policy
|
||||
link_to translate(tab_name, scope: [:nav_tabs, scope_name]),
|
||||
url,
|
||||
class: "nav-link #{:active if current_tab_name == tab_name}"
|
||||
else
|
||||
link_to translate(tab_name, scope: [:nav_tabs, scope_name]),
|
||||
url,
|
||||
class: 'nav-link disabled',
|
||||
tabindex: -1,
|
||||
'aria-disabled': true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,9 +2,21 @@
|
|||
<%= nav_tabs(
|
||||
:person,
|
||||
tab,
|
||||
overview: [:staff, person],
|
||||
person_comments: staff_person_person_comments_path(person),
|
||||
relationships: staff_person_relationships_path(person),
|
||||
passports: staff_person_passports_path(person),
|
||||
overview: [
|
||||
policy([:staff, person]).show?,
|
||||
[:staff, person],
|
||||
],
|
||||
person_comments: [
|
||||
policy([:staff, person, :person_comment]).index?,
|
||||
staff_person_person_comments_path(person),
|
||||
],
|
||||
relationships: [
|
||||
policy([:staff, person, :relationship]).index?,
|
||||
staff_person_relationships_path(person),
|
||||
],
|
||||
passports: [
|
||||
policy([:staff, person, :passport]).index?,
|
||||
staff_person_passports_path(person),
|
||||
],
|
||||
) %>
|
||||
</div>
|
||||
|
|
Reference in a new issue