1
0
Fork 0

Implement disabled tabs

This commit is contained in:
Alex Kotov 2019-08-15 12:06:11 +05:00
parent 3f0e032c7a
commit fd3c447dda
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 29 additions and 9 deletions

View file

@ -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

View file

@ -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>