Class: BBMB::Html::View::CurrentOrderForm

Inherits:
HtmlGrid::DivForm
  • Object
show all
Includes:
HtmlGrid::ErrorMessage
Defined in:
lib/bbmb/html/view/current_order.rb

Constant Summary collapse

COMPONENTS =
{
  [0,0] => :toggle,
  [0,1] => CurrentToggleable,
  [0,2] => :order_total,
  [1,2] => :total,
}
CSS_ID_MAP =
{ 1 => 'info', 2 => 'order-total' }
EVENT =
:commit
FORM_ID =
'additional_info'
SORT_DEFAULT =
:description
SYMBOL_MAP =
{
  :order_total => HtmlGrid::LabelText, 
}

Instance Method Summary collapse

Instance Method Details

#initObject



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/bbmb/html/view/current_order.rb', line 328

def init
  submit = 3
  if @lookandfeel.enabled?(:terms_of_service, false)
    components.update [0,submit] => :toggle_terms,
                      [0,submit + 1] => TermsOfService
    css_id_map.update submit + 1 => 'terms-of-service'
    submit += 2
  end
  if BBMB.config.mail_confirm_reply_to && !@model.empty?
    components.store [0,submit], :order_confirmation
    css_id_map.update submit => 'order-confirmation'
    submit += 1
  end
  components.store [0,submit], :submit
  super
  error_message
end

#order_confirmation(model) ⇒ Object



345
346
347
# File 'lib/bbmb/html/view/current_order.rb', line 345

def order_confirmation(model)
  OrderConfirmation.new(@session.state._customer, @session, self)
end

#submit(model) ⇒ Object



384
385
386
# File 'lib/bbmb/html/view/current_order.rb', line 384

def submit(model)
  super unless(model.empty?)
end

#toggle(model) ⇒ Object



348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/bbmb/html/view/current_order.rb', line 348

def toggle(model)
  ms_open = " + #{@lookandfeel.lookup(:additional_info)}"
  ms_close = " − #{@lookandfeel.lookup(:additional_info)}"
  attrs = {
    'css_class'     => 'toggler',
    'message_open'  => ms_open, 
    'message_close' => ms_close, 
    'status'        => toggle_status(model),
    'togglee'       => 'info',
  }
  dojo_tag('contenttoggler', attrs)
end

#toggle_status(model) ⇒ Object



360
361
362
# File 'lib/bbmb/html/view/current_order.rb', line 360

def toggle_status(model)
  model.additional_info.empty? ? 'closed' : 'open'
end

#toggle_terms(model) ⇒ Object



363
364
365
366
367
368
369
370
371
372
373
374
# File 'lib/bbmb/html/view/current_order.rb', line 363

def toggle_terms(model)
  ms_open = " + #{@lookandfeel.lookup(:terms)}"
  ms_close = " − #{@lookandfeel.lookup(:terms)}"
  attrs = {
    'css_class'     => 'toggler',
    'message_open'  => ms_open,
    'message_close' => ms_close,
    'status'        => toggle_terms_status,
    'togglee'       => 'terms-of-service',
  }
  dojo_tag('contenttoggler', attrs)
end

#toggle_terms_statusObject



375
376
377
# File 'lib/bbmb/html/view/current_order.rb', line 375

def toggle_terms_status
  @session.state._customer.terms_last_accepted ? 'closed' : 'open'
end

#total(model) ⇒ Object



378
379
380
381
382
383
# File 'lib/bbmb/html/view/current_order.rb', line 378

def total(model)
  span = HtmlGrid::Span.new(model, @session, self)
  span.css_id = 'total'
  span.value = model.total
  span
end