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

#content_toggler(model, key, togglee, status = false) ⇒ Object



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

def content_toggler(model, key,  togglee, status=false)
  link = HtmlGrid::Link.new("#{key}", model, @session, self)
  link.css_id = key
  link.value = @lookandfeel.lookup(key)
  script = "event.preventDefault();
// console.log('onclick: key #{key} togglee #{togglee}');
var element = document.getElementById('#{togglee}');
element.hidden = !element.hidden;
"
  link.set_attribute("onclick", script)
  link
end

#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



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

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

#toggle(model) ⇒ Object



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

def toggle(model)
  content_toggler(model, 'additional_info', 'info')
end

#toggle_status(model) ⇒ Object



363
364
365
# File 'lib/bbmb/html/view/current_order.rb', line 363

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

#toggle_terms(model) ⇒ Object



366
367
368
# File 'lib/bbmb/html/view/current_order.rb', line 366

def toggle_terms(model)
  content_toggler(model, 'terms', 'terms-of-service')
end

#toggle_terms_statusObject



369
370
371
# File 'lib/bbmb/html/view/current_order.rb', line 369

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

#total(model) ⇒ Object



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

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