Module: Workarea::Admin::NavigationHelper
- Included in:
- DataFileMailer
- Defined in:
- app/helpers/workarea/admin/navigation_helper.rb
Instance Method Summary collapse
- #administrators_path ⇒ Object
- #customers_path ⇒ Object
- #index_url_for(class_or_model, options = {}) ⇒ Object
- #link_to_index_for(model) ⇒ Object
- #navigation_link_classes(url = nil) ⇒ Object
- #todays_orders_path ⇒ Object
-
#todays_signups_path ⇒ Object
TODO remove in v3.6, no longer used.
- #yesterdays_orders_path ⇒ Object
Instance Method Details
#administrators_path ⇒ Object
30 31 32 |
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 30 def administrators_path users_path(role: %w(Administrator)) end |
#customers_path ⇒ Object
26 27 28 |
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 26 def customers_path users_path(role: %w(Customer)) end |
#index_url_for(class_or_model, options = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 61 def index_url_for(class_or_model, = {}) url_for( .reverse_merge( controller: "workarea/admin/#{class_or_model.model_name.route_key}", action: 'index' ) ) rescue ActionController::UrlGenerationError nil end |
#link_to_index_for(model) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 42 def link_to_index_for(model) unfiltered_path = index_url_for(model) last_index_path = session[:last_index_path].to_s title_name = model.model_name.human.downcase.pluralize show_last_index_path = last_index_path.present? && last_index_path != unfiltered_path && last_index_path.include?(unfiltered_path) if show_last_index_path link_to("↑ #{t('workarea.admin.shared.primary_nav.back_filtered_link', resource: title_name)}", session[:last_index_path]) else link_to("↑ #{t('workarea.admin.shared.primary_nav.back_link', resource: title_name)}", unfiltered_path) end rescue ActionController::UrlGenerationError # It's ok if we can't render back to index, better to allow page to show end |
#navigation_link_classes(url = nil) ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 4 def (url = nil) return 'primary-nav__link' if url.blank? classes = ['primary-nav__link'] classes << 'primary-nav__link--active' if request.fullpath == url classes.join(' ') end |
#todays_orders_path ⇒ Object
12 13 14 15 16 17 |
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 12 def todays_orders_path orders_path( placed_at_greater_than: Time.current.to_s(:date_only), placed_at_less_than: Time.current.to_s(:date_only) ) end |
#todays_signups_path ⇒ Object
TODO remove in v3.6, no longer used
35 36 37 38 39 40 |
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 35 def todays_signups_path users_path( created_at_greater_than: Time.current.to_s(:date_only), created_at_less_than: Time.current.to_s(:date_only) ) end |
#yesterdays_orders_path ⇒ Object
19 20 21 22 23 24 |
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 19 def yesterdays_orders_path orders_path( placed_at_greater_than: 1.day.ago.to_s(:date_only), placed_at_less_than: 1.day.ago.to_s(:date_only) ) end |