Verified Commit f96a5ffc authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

change action name helper to controller and action name helper, plus use them...

change action name helper to controller and action name helper, plus use them in views, to shorten conditionals
parent d0f447bd
module ActionNameHelper
module ActionAndControllerNameHelper
def action_new?
action_name == 'new' || action_name == 'create'
end
......@@ -14,4 +14,12 @@ module ActionNameHelper
def action_edit?
action_name == 'edit' || action_name == 'update'
end
def action_in?(*names)
names.map(&:to_s).include? action_name
end
def controller_in?(*names)
names.map(&:to_s).include? controller_name
end
end
- unless controller_name == 'group_offers'
- unless controller_in?(:group_offers)
= bootstrap_paginate(volunteers)
.table-responsive
......@@ -11,7 +11,7 @@
- if policy(Volunteer).show_acceptance?
th= sort_link @q, :acceptance
th= sort_link @q, :salutation
- if action_index? || action_name == 'seeking_clients' || controller_name == 'group_offers'
- if action_in?(:index, :seeking_clients) || controller_in?(:group_offers)
th= sort_link @q, :contact_last_name, t_attr(:full_name, Volunteer)
th= sort_link @q, :contact_city
th= sort_link @q, :contact_postal_code
......@@ -29,4 +29,5 @@
tbody
= render volunteers
= bootstrap_paginate(volunteers)
- unless controller_in?(:group_offers)
= bootstrap_paginate(volunteers)
......@@ -10,7 +10,7 @@ tr
- if policy(volunteer).show?
= button_link navigation_glyph(:journal), volunteer_journals_path(volunteer), title: 'Journal'
td
- if controller_name == 'group_offers'
- if controller_in?(:group_offers)
= link_to 'Freiwillige/n hinzufügen',
group_assignments_path(group_assignment: { group_offer_id: @group_offer.id, volunteer_id: volunteer.id }),
class: 'btn btn-default', method: :post
......@@ -31,7 +31,7 @@ tr
br
'Importiert
td = t("salutation.#{volunteer.salutation}") if volunteer.salutation?
- if action_index? || action_name == 'seeking_clients' || controller_name == 'group_offers'
- if action_in?(:index, :seeking_clients) || controller_in?(:group_offers)
td = link_to_if policy(Volunteer).edit?, volunteer.contact.full_name, edit_volunteer_path(volunteer)
td = volunteer.contact.city
td = volunteer.contact.postal_code
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment