Module: Admin::FormHelper

Defined in:
app/helpers/admin/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#actions(&block) ⇒ Object



16
17
18
19
# File 'app/helpers/admin/form_helper.rb', line 16

def actions(&block)
  content = capture(self, &block)
  (:div, content, class: 'well') if content.present?
end

#back_action(name = I18n.t('admin.common.return'), path = back_uri) ⇒ Object



46
47
48
# File 'app/helpers/admin/form_helper.rb', line 46

def back_action(name = I18n.t('admin.common.return'), path = back_uri)
  link_to name, path, class: 'btn btn-default'
end

#cancel_action(path, name = I18n.t('admin.common.cancel')) ⇒ Object



42
43
44
# File 'app/helpers/admin/form_helper.rb', line 42

def cancel_action(path, name = I18n.t('admin.common.cancel'))
  link_to name, path, class: 'btn btn-default'
end


30
31
32
33
34
# File 'app/helpers/admin/form_helper.rb', line 30

def create_link(path = url_for(action: :new))
  return unless policy.action_enabled?(:create)
  content = "<i class='glyphicon glyphicon-plus'></i>&nbsp;&nbsp;#{I18n.t('admin.common.new')}".html_safe
  link_to content, path, class: 'btn btn-success'
end

#field_set(title = nil, options = {}, &block) ⇒ Object



10
11
12
13
14
# File 'app/helpers/admin/form_helper.rb', line 10

def field_set(title = nil, options = {}, &block)
  content = capture(self, &block)
  content = (:legend, title) + content if title
   :fieldset, content, options
end

#fixed_actions(&block) ⇒ Object



25
26
27
28
# File 'app/helpers/admin/form_helper.rb', line 25

def fixed_actions(&block)
  panel_tag = actions(&block)
   :div, panel_tag, class: 'action-bar'
end


36
37
38
39
40
# File 'app/helpers/admin/form_helper.rb', line 36

def sort_link(path = url_for(action: :sort))
  return unless policy.action_enabled?(:sort)
  content = "<i class='glyphicon glyphicon-random'></i>&nbsp;&nbsp;#{I18n.t('admin.common.sort')}".html_safe
  link_to content, path, class: 'btn btn-primary'
end

#standard_actions(form) ⇒ Object



21
22
23
# File 'app/helpers/admin/form_helper.rb', line 21

def standard_actions(form)
  fixed_actions { form.save + form.apply + form.cancel }
end

#twitter_form_for(name, *args, &block) ⇒ Object



5
6
7
8
# File 'app/helpers/admin/form_helper.rb', line 5

def twitter_form_for(name, *args, &block)
  options = args.extract_options!
  form_for(name, *(args << {builder: Coalla::FormBuilder, html: {class: 'form-horizontal'}}.deep_merge(options)), &block)
end