Commit 7c4ff587 authored by Tugce Nur Tas's avatar Tugce Nur Tas

modify custom_filter_dropdown to not show all link

parent 7b2c1aa8
Pipeline #36199 passed with stage
in 38 minutes and 32 seconds
module FilterDropdownHelper
def custom_filter_dropdown(name, *filters)
_custom_filter_dropdown_general(name, true, *filters)
end
def custom_filter_dropdown_no_all(name, *filters)
_custom_filter_dropdown_general(name, false, *filters)
end
def _custom_filter_dropdown_general(name, all_link, *filters)
filter_keys = filters.map { |filter| filter[:q] }
filter_keys += filters.map { |filter| filter[:qs] }
filters = custom_filter_dropdown_filters(filters, filter_keys)
render_filter_dropdown top_text: name + custom_text_end(filters),
all_url: filter_keys, filters: filters
all_url: filter_keys, filters: filters, all_link: all_link
end
def custom_filter_dropdown_filters(filters, filter_keys)
......@@ -19,7 +27,7 @@ module FilterDropdownHelper
filter.merge(url: url_for(q_args), link_class: list_filter_link_class(filter[:active]))
end
end
def custom_filter_q_arg(filter, multi_qs, value, *excludes)
q_values = search_parameters.merge(multi_qs.map { |q| [q, value.to_s] }.to_h) if multi_qs
(q_values || search_parameters).except(*excludes).merge("#{filter}": value.to_s)
......@@ -36,7 +44,7 @@ module FilterDropdownHelper
)
end
render_filter_dropdown top_text: toggler_text(attribute.to_sym, [attribute_q]),
all_url: attribute_q, filters: filters
all_url: attribute_q, filters: filters, all_link: true
end
def boolean_filter_dropdown(attribute, collection = nil)
......@@ -50,7 +58,7 @@ module FilterDropdownHelper
)
end
render_filter_dropdown top_text: toggler_text(attribute, filters.pluck(:q)),
all_url: filters.pluck(:q), filters: filters
all_url: filters.pluck(:q), filters: filters, all_link: true
end
# Creates a filter dropdown that filters a boolean attribute to either true or false
......@@ -72,8 +80,8 @@ module FilterDropdownHelper
end
def render_filter_dropdown(locals)
render template: 'application/filter_dropdown',
locals: locals.merge(all_url: all_url_for(locals[:all_url]))
locals.merge!(all_url: all_url_for(locals[:all_url])) if locals[:all_link]
render template: 'application/filter_dropdown', locals: locals
end
def custom_text_end(filters)
......
- all_link ||= false
li.dropdown
a*{ class: 'dropdown-toggle btn btn-default btn-sm', role: 'button', href: '#',
data: { toggle: 'dropdown' }, aria: { expanded: 'false', haspopup: 'true' } }
=> top_text
span.caret
ul.dropdown-menu
li= link_to t('all'), all_url
li.divider[role="separator"]
- if all_link
li= link_to t('all'), all_url
li.divider[role="separator"]
- filters.each do |filter|
li= link_to filter[:text], filter[:url], class: filter[:link_class]
......@@ -7,7 +7,7 @@ h1 Spesenformulare erfassen
ul.list-inline
= button_link icon_span(:back), billing_expenses_path
li= clear_filter_button
= custom_filter_dropdown(t_attr(:semester, BillingExpense), *@billing_semester_filters)
= custom_filter_dropdown_no_all(t_attr(:semester, BillingExpense), *@billing_semester_filters)
li= f.button :submit, 'Selektierte Spesenformulare erstellen', 'data-confirm' => 'Sind Sie sicher dass Sie die Spesenformulare für die ausgewählten Freiwilligen erstellen möchten?'
.table-responsive
......
Markdown is supported
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