Module: OrdersHelperOverrides

Defined in:
lib/kete_gets_trollied/orders_helper_overrides.rb

Instance Method Summary collapse

Instance Method Details

#add_ons_logged_in_user_listObject

override ### TODO: this isn’t overriding the default method



30
31
32
33
34
35
36
37
38
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 30

def add_ons_logged_in_user_list
  link_html = super

  link_html += link_to_unless_current(t('base.your_cart'),
                                      { :user_id => current_user.id, :controller => :trolleys, :action => :show },
                                      { :tabindex => '2', :class => "trolley-button" })

  ('li', link_html)
end

#button_to_checkout(order) ⇒ Object



104
105
106
107
108
109
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 104

def button_to_checkout(order)
  order_button_for('checkout', order,
                   { :method => 'get',
                     :target_action => 'checkout_form',
                     :url_for_options => { :urlified_name => @site_basket.urlified_name } })
end

#can_trigger_finish?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 7

def can_trigger_finish?
  params[:controller] == 'orders' && at_least_a_moderator?
end

#can_trigger_fulfilled_without_acceptance?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 3

def can_trigger_fulfilled_without_acceptance?
  params[:controller] == 'orders' && at_least_a_moderator?
end

#checkout_form_target_action_url_hashObject



146
147
148
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 146

def checkout_form_target_action_url_hash
  {:action => 'checkout', :id => @order, :urlified_name => @site_basket.urlified_name}
end

#clear_extra_paramsObject



89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 89

def clear_extra_params
  if @user || @from || @until
    options = set_options_from_vars

    to_be_cleared = [:user, :trolley, :from, :until]

    to_be_cleared.each { |key_sym| options.delete(key_sym) }

    clear_link = link_to(t("orders.helpers.clear_params"), options)

    clear_link = ' [ ' + clear_link + ' ]'
    ('span', clear_link, :class => 'clear-params')
  end
end


84
85
86
87
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 84

def link_basket_orders(basket)
  options = set_options_from_vars.merge({:urlified_name => basket.urlified_name})
  link_to(council_full_name_from(basket.name), options)
end

order number order user council number of line_items date required by



132
133
134
135
136
137
138
139
140
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 132

def link_to_as_summary_of(order, user = nil)
  link_text = t('orders.helpers.order_number') + " #{order.id}"
  link_text += " - #{user.trolley_user_display_name}" if user.present? && params[:controller] == 'orders'
  link_text += " - #{council_full_name_from(order.basket.name)}"
  link_text += " - (#{order.line_items.size} #{t 'orders.helpers.items'})" if order.line_items.size > 0
  link_text += " - #{order.updated_at.to_s(:db).split(' ')[0]}"

  link_to(link_text, url_for_order(:order => order))
end


11
12
13
14
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 11

def link_to_orders_for(user)
  options = set_options_from_vars.merge({:user => user})
  link_to(user.trolley_user_display_name, options)
end


16
17
18
19
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 16

def link_to_state_unless_current(state, count)
  options = set_options_from_vars.merge({:state => state})
  link_to_unless_current(t("orders.index.#{state}") + show_count_for(count), options)
end

#meta_data_for(order) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 59

def (order)
  html = '<div id="order-meta-data">'
  html += '<h3 id="order-id">' + t('orders.helpers.order_number') + " #{order.id}"
  # TODO: move "order in" to I18n
  html += " ("
  if current_user == order.user && params[:controller] == 'trolleys'
    html += council_full_name_from(order.basket.name)
  else
    html += link_basket_orders(order.basket)
  end
  html += ')'

  html += (order)

  html += '</h3>'

  if !order.current? && !(order.contact_name.blank? && order.contact_phone.blank?)
    html += '<h4 id="order-info">'
    html += order.contact_name + ' - ' if order.contact_name
    html += order.contact_phone if order.contact_phone
    html += '</h4>'
  end
  html += '</div>'
end

#meta_data_headline_extentions_for(order) ⇒ Object

override this if you want to tie-in to meta_data_for’s headline



56
57
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 56

def (order)
end

#order_checkout_fields(form) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 111

def order_checkout_fields(form)
  html = '<div class="form-element">'
  html += "<label for=\"order_contact_name\">#{t('orders.helpers.contact_name')}</label>"
  html += form.text_field(:contact_name, { :tabindex => '1', :label => t('orders.helpers.contact_name')})
  # html += "<div class=\"form-example\">#{t('orders.helpers.contact_name_example')}</div>"
  html += '</div>'
  html += '<div class="form-element">'
  html += "<label for=\"order_contact_phone\">#{t('orders.helpers.contact_phone')}</label>"
  html += form.text_field(:contact_phone, { :tabindex => '1' })
  html += "<div class=\"form-example\">#{t('orders.helpers.contact_phone_example')}</div>"
  html += '</div>'
  html += '<div class="form-element">'
  html += '</div>'
  html
end

#orders_state_headlineObject



21
22
23
24
25
26
27
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 21

def orders_state_headline
  html = super
  if @current_basket != @site_basket
    html += ' ' + t('base.inside') + ' ' + @current_basket.name
  end
  html
end

#set_options_from_varsObject



40
41
42
43
44
45
46
47
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 40

def set_options_from_vars
  options = url_for_options_for_orders_index
  options[:state] = @state if @state
  options[:from] = @from if @from
  options[:until] = @until if @until
  options[:user] = @user if @user
  options
end

#sorted_state_namesObject



142
143
144
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 142

def sorted_state_names
  [:in_process, :ready, :completed, :cancelled]
end

#url_for_options_for_orders_indexObject



49
50
51
52
53
# File 'lib/kete_gets_trollied/orders_helper_overrides.rb', line 49

def url_for_options_for_orders_index
  { :urlified_name => @current_basket.urlified_name,
    :controller => 'orders',
    :action => 'index' }
end