Module: Elabs::ContentFiltersHelper
- Defined in:
- app/helpers/elabs/content_filters_helper.rb
Instance Method Summary collapse
- #admin_order_by_link(title, field) ⇒ Object (also: #member_order_by_link)
- #all_filter_link ⇒ Object
- #all_sfw_status_link ⇒ Object
- #nsfw_only_link ⇒ Object
- #order_link(title, field) ⇒ Object
- #render_filters? ⇒ Boolean
- #sfw_only_link ⇒ Object
- #sfw_status_links ⇒ Object
- #with_content_filter_links ⇒ Object
- #with_content_only_filter_link ⇒ Object
Instance Method Details
#admin_order_by_link(title, field) ⇒ Object Also known as: member_order_by_link
70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 70 def admin_order_by_link(title, field) current_direction = params['order_by'] == field && params['direction'] ? params['direction'] : 'desc' direction = current_direction == 'asc' ? :desc : :asc = { order_by: field, direction: direction } icon = direction == :asc ? 'sort-up' : 'sort-down' link_to , class: 'filter-link' do icon_text icon, title, ['fw'], true end end |
#all_filter_link ⇒ Object
63 64 65 66 67 68 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 63 def all_filter_link icon = params['with_content_only'] && params['with_content_only'] == 'false' ? 'dot-circle' : 'circle' link_to request.params.merge(with_content_only: 'false'), class: 'filter-link' do icon_text(icon, _('Show all'), ['fw'], true) end end |
#all_sfw_status_link ⇒ Object
40 41 42 43 44 45 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 40 def all_sfw_status_link icon = params['sfw_status'] && %w[sfw_only nsfw_only].include?(params['sfw_status']) ? 'circle' : 'dot-circle' link_to request.params.merge(sfw_status: 'all'), class: 'filter-link' do icon_text(icon, _('Show all'), ['fw'], true) end end |
#nsfw_only_link ⇒ Object
33 34 35 36 37 38 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 33 def nsfw_only_link icon = params['sfw_status'] && params['sfw_status'] == 'nsfw_only' ? 'dot-circle' : 'circle' link_to request.params.merge(sfw_status: 'nsfw_only'), class: 'filter-link' do icon_text(icon, _('Only NSFW'), ['fw'], true) end end |
#order_link(title, field) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 3 def order_link(title, field) param_name = "order_by_#{field}" direction = params[param_name] && params[param_name] == 'asc' ? :desc : :asc = { param_name => direction } ['sfw_status'] = params['sfw_status'] if params['sfw_status'] icon = direction == :asc ? 'sort-up' : 'sort-down' link_to , class: 'filter-link' do icon_text icon, title, ['fw'], true end end |
#render_filters? ⇒ Boolean
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 84 def render_filters? %w[acts languages licenses tags users albums articles notes projects uploads].include?(controller_name) && action_name == 'index' end |
#sfw_only_link ⇒ Object
26 27 28 29 30 31 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 26 def sfw_only_link icon = params['sfw_status'] && params['sfw_status'] == 'sfw_only' ? 'dot-circle' : 'circle' link_to request.params.merge(sfw_status: 'sfw_only'), class: 'filter-link' do icon_text(icon, _('Only SFW'), ['fw'], true) end end |
#sfw_status_links ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 16 def sfw_status_links out = [] out.push all_sfw_status_link out.push sfw_only_link out.push nsfw_only_link raw out.join('') end |
#with_content_filter_links ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 47 def with_content_filter_links out = [] out.push all_filter_link out.push with_content_only_filter_link raw out.join('') end |
#with_content_only_filter_link ⇒ Object
56 57 58 59 60 61 |
# File 'app/helpers/elabs/content_filters_helper.rb', line 56 def with_content_only_filter_link icon = !params['with_content_only'] || params['with_content_only'] == 'true' ? 'dot-circle' : 'circle' link_to request.params.merge(with_content_only: 'true'), class: 'filter-link' do icon_text(icon, _('With content only'), ['fw'], true) end end |