Module: Workarea::Admin::NavigationHelper

Included in:
DataFileMailer
Defined in:
app/helpers/workarea/admin/navigation_helper.rb

Instance Method Summary collapse

Instance Method Details

#administrators_pathObject



30
31
32
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 30

def administrators_path
  users_path(role: %w(Administrator))
end

#customers_pathObject



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, options = {})
  url_for(
    options.reverse_merge(
      controller: "workarea/admin/#{class_or_model.model_name.route_key}",
      action: 'index'
    )
  )

rescue ActionController::UrlGenerationError
  nil
end


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


4
5
6
7
8
9
10
# File 'app/helpers/workarea/admin/navigation_helper.rb', line 4

def navigation_link_classes(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_pathObject



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_pathObject

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_pathObject



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