Module: Admin::FormHelper
- Defined in:
- app/helpers/admin/form_helper.rb
Instance Method Summary collapse
- #actions(&block) ⇒ Object
- #back_action(name = I18n.t('admin.common.return'), path = back_uri) ⇒ Object
- #cancel_action(path, name = I18n.t('admin.common.cancel')) ⇒ Object
- #create_link(path = url_for(action: :new)) ⇒ Object
- #field_set(title = nil, options = {}, &block) ⇒ Object
- #fixed_actions(&block) ⇒ Object
- #sort_link(path = url_for(action: :sort)) ⇒ Object
- #standard_actions(form) ⇒ Object
- #twitter_form_for(name, *args, &block) ⇒ Object
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) content_tag(: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 |
#create_link(path = url_for(action: :new)) ⇒ Object
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> #{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, = {}, &block) content = capture(self, &block) content = content_tag(:legend, title) + content if title content_tag :fieldset, content, 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) content_tag :div, panel_tag, class: 'action-bar' end |
#sort_link(path = url_for(action: :sort)) ⇒ Object
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> #{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) = args. form_for(name, *(args << {builder: Coalla::FormBuilder, html: {class: 'form-horizontal'}}.deep_merge()), &block) end |