Skip to content

Commit 180e643

Browse files
committed
New feature: setText action
1 parent 584a3f5 commit 180e643

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

app/assets/javascripts/activeadmin/dynamic_fields.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
fade: el => el.fadeOut(),
1414
hide: el => el.hide(),
15+
setText: (el, text) => el.text(text),
1516
setValue: (el, value) => {
1617
if (el.attr('type') == 'checkbox') el.prop('checked', value == '1')
1718
else el.val(value)

spec/dummy/app/admin/posts.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ def add_field(form, name, type, data, override_options = {})
135135
df261 = { if: 'checked', then: 'slide', target: '#post_data_field_261_input .inline-hints' }
136136
add_field(f, :data_field_261, :boolean, df261)
137137

138+
# --- setText
139+
df271 = { if: 'checked', then: 'setText data test', target: '#post_data_field_271_input .inline-hints' }
140+
add_field(f, :data_field_271, :boolean, df271)
141+
138142
# --- gtarget
139143
df301 = { if: 'checked', then: 'addClass red', gtarget: 'body.active_admin' }
140144
add_field(f, :data_field_301, :boolean, df301)

spec/system/dynamic_fields_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@
134134
find('#post_data_field_261').click
135135
expect(page).to have_css('#post_data_field_261_input .inline-hints', visible: :hidden)
136136

137+
# --- setText
138+
expect(find('#post_data_field_271_input .inline-hints').text).not_to eq 'data test'
139+
find('#post_data_field_271').click
140+
expect(find('#post_data_field_271_input .inline-hints').text).to eq 'data test'
141+
137142
# --- gtarget
138143
expect(page).not_to have_css('body.active_admin.red')
139144
find('#post_data_field_301').click

0 commit comments

Comments
 (0)