Class: ActionAdmin::SlugInput
- Inherits:
-
SimpleForm::Inputs::StringInput
- Object
- SimpleForm::Inputs::StringInput
- ActionAdmin::SlugInput
- Defined in:
- app/inputs/action_admin/slug_input.rb
Instance Method Summary collapse
- #edit_button ⇒ Object
- #empty_value ⇒ Object
- #input(wrapper_options) ⇒ Object
- #input_value ⇒ Object
- #label(wrapper_options) ⇒ Object
- #prefix(text) ⇒ Object
- #preview_link ⇒ Object
- #preview_value ⇒ Object
- #save_button ⇒ Object
- #url ⇒ Object
- #value_pattern ⇒ Object
Instance Method Details
#edit_button ⇒ Object
53 54 55 56 |
# File 'app/inputs/action_admin/slug_input.rb', line 53 def opts = { class: 'edit-button mdi mdi-pencil', data: { edit: '' } } template.content_tag :span, nil, opts end |
#empty_value ⇒ Object
32 33 34 |
# File 'app/inputs/action_admin/slug_input.rb', line 32 def empty_value prefix('Not defined') end |
#input(wrapper_options) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/inputs/action_admin/slug_input.rb', line 3 def input() [:placeholder] ||= raw_label_text [:type] ||= 'text' [:class] ||= [] [:class] += ['small', 'edit-input'] opts = { class: 'inline-edit-box', data: { inline_edit_box: '' } } template.content_tag(:div, opts) do template.concat preview_link template.concat super template.concat template.concat end end |
#input_value ⇒ Object
28 29 30 |
# File 'app/inputs/action_admin/slug_input.rb', line 28 def input_value object.try(attribute_name) end |
#label(wrapper_options) ⇒ Object
63 64 65 |
# File 'app/inputs/action_admin/slug_input.rb', line 63 def label() '' end |
#prefix(text) ⇒ Object
24 25 26 |
# File 'app/inputs/action_admin/slug_input.rb', line 24 def prefix(text) "#{raw_label_text}: #{text}" end |
#preview_link ⇒ Object
48 49 50 51 |
# File 'app/inputs/action_admin/slug_input.rb', line 48 def preview_link data = { preview: '', value: value_pattern, placeholder: empty_value } template.content_tag :small, preview_value, class: 'edit-preview', data: data end |
#preview_value ⇒ Object
44 45 46 |
# File 'app/inputs/action_admin/slug_input.rb', line 44 def preview_value input_value.present? ? prefix(url) : empty_value end |
#save_button ⇒ Object
58 59 60 61 |
# File 'app/inputs/action_admin/slug_input.rb', line 58 def opts = { class: 'save-button mdi mdi-check', data: { save: '' } } template.content_tag :span, nil, opts end |
#url ⇒ Object
19 20 21 22 |
# File 'app/inputs/action_admin/slug_input.rb', line 19 def url method = .fetch :url, ActionAdmin.config.app_urls template.try(method, object) unless object.new_record? end |
#value_pattern ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/inputs/action_admin/slug_input.rb', line 36 def value_pattern if url.present? prefix "#{url}".sub("#{input_value}", '[val]') else prefix "#{template.root_url}[val]" end end |