Module: BootstrapFormExtensions::SubmitBar

Defined in:
lib/bootstrap_form_extensions/submit_bar.rb

Constant Summary collapse

@@partial =
'bootstrap_form_extensions/submit_bar'
@@show_submit_button =
true
@@submit_button_text =
'Save'
@@show_submit_menu =
true
@@show_submit_and_dup_button =
true
@@show_submit_and_new_button =
true
@@show_cancel_button =
true
@@cancel_button_text =
'Cancel'
@@back_button_text =
'Back'

Instance Method Summary collapse

Instance Method Details

#submit_bar(show_submit_button: @@show_submit_button, submit_button_text: @@submit_button_text, show_submit_menu: @@show_submit_menu, show_submit_and_dup_button: @@show_submit_and_dup_button, show_submit_and_new_button: @@show_submit_and_new_button, show_cancel_button: @@show_cancel_button, cancel_button_text: nil, cancel_button_url: nil, extra_buttons: [], right_buttons: [], partial: @@partial) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/bootstrap_form_extensions/submit_bar.rb', line 32

def submit_bar show_submit_button: @@show_submit_button, submit_button_text: @@submit_button_text,
               show_submit_menu: @@show_submit_menu, show_submit_and_dup_button: @@show_submit_and_dup_button, show_submit_and_new_button: @@show_submit_and_new_button,
               show_cancel_button: @@show_cancel_button, cancel_button_text: nil, cancel_button_url: nil,
               extra_buttons: [], right_buttons: [],
               partial: @@partial

  show_submit_menu   &&= @template.current_ability.can? :new, object if @template.respond_to? :current_ability
  cancel_button_url  ||= @template.url_for(object.persisted? ? object : @template.controller_name.to_sym) rescue 'javascript:history.back();'
  cancel_button_text ||= show_submit_button ? @@cancel_button_text : @@back_button_text

  @template.render partial, {
    show_submit_button: show_submit_button, submit_button_text: submit_button_text,
    show_submit_menu:   show_submit_menu,   show_submit_and_dup_button: show_submit_and_dup_button, show_submit_and_new_button: show_submit_and_new_button,
    show_cancel_button: show_cancel_button, cancel_button_text: cancel_button_text, cancel_button_url: cancel_button_url,
    extra_buttons: parse_extra_buttons_for_submit_bar(extra_buttons, :extra),
    right_buttons: parse_extra_buttons_for_submit_bar(right_buttons, :right),
  }
end