Module: ActiveAdmin::DynamicFields
- Defined in:
- lib/activeadmin/dynamic_fields/engine.rb,
lib/activeadmin/dynamic_fields/version.rb
Defined Under Namespace
Classes: Engine
Constant Summary collapse
- VERSION =
'0.8.0'
Class Method Summary collapse
- .edit_boolean(field, url, value) ⇒ Object
- .edit_select(field, url) ⇒ Object
- .edit_string(field, url) ⇒ Object
- .update(resource, params, permit_params = nil) ⇒ Object
Class Method Details
.edit_boolean(field, url, value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/activeadmin/dynamic_fields/engine.rb', line 11 def self.edit_boolean(field, url, value) { 'data-field': field, 'data-field-type': 'boolean', 'data-field-value': value, 'data-content': "<span class=\"status_tag changed\">#{value ? 'no' : 'yes'}</span>", 'data-save-url': url, 'data-show-errors': '1' } end |
.edit_select(field, url) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/activeadmin/dynamic_fields/engine.rb', line 22 def self.edit_select(field, url) { 'data-field': field, 'data-field-type': 'select', 'data-save-url': url, 'data-show-errors': '1' } end |
.edit_string(field, url) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/activeadmin/dynamic_fields/engine.rb', line 31 def self.edit_string(field, url) { contenteditable: true, 'data-field': field, 'data-field-type': 'string', 'data-save-url': url, 'data-show-errors': '1' } end |
.update(resource, params, permit_params = nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/activeadmin/dynamic_fields/engine.rb', line 41 def self.update(resource, params, permit_params = nil) if params[:data] if resource.update(permit_params ? params[:data].permit(permit_params) : params[:data].permit!) { json: { status: 'ok' } } else { json: { status: 'error', message: resource.errors } } end else { json: { status: 'error', message: 'No data' }, status: 400 } end end |