diff --git a/app/assets/javascripts/app/controllers/_ui_element/boolean.coffee b/app/assets/javascripts/app/controllers/_ui_element/boolean.coffee index e92aa84bd..9d74d459e 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/boolean.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/boolean.coffee @@ -19,6 +19,12 @@ class App.UiElement.boolean extends App.UiElement.ApplicationUiElement # find selected/checked item of list @selectedOptions(attribute, params) + # disable item of list + @disabledOptions(attribute, params) + + # filter attributes + @filterOption(attribute, params) + item = $(App.view('generic/select')(attribute: attribute)) item.find('select').data('field-type', 'boolean') - item \ No newline at end of file + item diff --git a/spec/system/examples/core_workflow_examples.rb b/spec/system/examples/core_workflow_examples.rb index a67b312fe..9e655739a 100644 --- a/spec/system/examples/core_workflow_examples.rb +++ b/spec/system/examples/core_workflow_examples.rb @@ -349,6 +349,167 @@ RSpec.shared_examples 'core workflow' do end end + describe 'modify boolean attribute', authenticated_as: :authenticate, db_strategy: :reset do + def authenticate + create(:object_manager_attribute_boolean, object_name: object_name, name: field_name, display: field_name, screens: screens) + ObjectManager::Attribute.migration_execute + true + end + + describe 'action - show' do + before do + create(:core_workflow, + object: object_name, + perform: { + "#{object_name.downcase}.#{field_name}": { + operator: 'show', + show: 'true' + }, + }) + end + + it 'does perform' do + before_it.call + expect(page).to have_selector("select[name='#{field_name}']", wait: 10) + end + end + + describe 'action - hide' do + before do + create(:core_workflow, + object: object_name, + perform: { + "#{object_name.downcase}.#{field_name}": { + operator: 'hide', + hide: 'true' + }, + }) + end + + it 'does perform' do + before_it.call + expect(page).to have_selector(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden, wait: 10) + end + end + + describe 'action - remove' do + before do + create(:core_workflow, + object: object_name, + perform: { + "#{object_name.downcase}.#{field_name}": { + operator: 'remove', + remove: 'true' + }, + }) + end + + it 'does perform' do + before_it.call + expect(page).to have_selector(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden, wait: 10) + end + end + + describe 'action - set_optional' do + before do + create(:core_workflow, + object: object_name, + perform: { + "#{object_name.downcase}.#{field_name}": { + operator: 'set_optional', + set_optional: 'true' + }, + }) + end + + it 'does perform' do + before_it.call + expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*', wait: 10) + end + end + + describe 'action - set_mandatory' do + before do + create(:core_workflow, + object: object_name, + perform: { + "#{object_name.downcase}.#{field_name}": { + operator: 'set_mandatory', + set_mandatory: 'true' + }, + }) + end + + it 'does perform' do + before_it.call + expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*', wait: 10) + end + end + + describe 'action - restrict values' do + before do + create(:core_workflow, + object: object_name, + perform: { + "#{object_name.downcase}.#{field_name}": { + operator: 'set_fixed_to', + set_fixed_to: %w[true] + }, + }) + end + + it 'does perform' do + before_it.call + expect(page).to have_selector("select[name='#{field_name}'] option[value='true']", wait: 10) + expect(page).to have_no_selector("select[name='#{field_name}'] option[value='false']", wait: 10) + end + end + + describe 'action - select' do + before do + create(:core_workflow, + object: object_name, + perform: { + "#{object_name.downcase}.#{field_name}": { + operator: 'select', + select: ['true'] + }, + }) + end + + it 'does perform' do + before_it.call + expect(page).to have_selector("select[name='#{field_name}'] option[value='true'][selected]", wait: 10) + end + end + + describe 'action - auto select' do + before do + create(:core_workflow, + object: object_name, + perform: { + "#{object_name.downcase}.#{field_name}": { + operator: 'set_fixed_to', + set_fixed_to: ['', 'true'], + }, + }) + create(:core_workflow, + object: object_name, + perform: { + "#{object_name.downcase}.#{field_name}": { + operator: 'auto_select', + auto_select: 'true', + }, + }) + end + + it 'does perform' do + before_it.call + expect(page).to have_selector("select[name='#{field_name}'] option[value='true'][selected]", wait: 10) + end + end + end + describe 'modify tree select attribute', authenticated_as: :authenticate, db_strategy: :reset do def authenticate create(:object_manager_attribute_tree_select, object_name: object_name, name: field_name, display: field_name, screens: screens)