diff --git a/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee b/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee index 25666402b..c3ada47fc 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee @@ -66,7 +66,7 @@ class App.UiElement.ticket_perform_action item = $( App.view('generic/ticket_perform_action/index')( attribute: attribute ) ) # add filter - item.on('click', '.js-add', (e) => + item.on('click', '.js-rowActions .js-add', (e) => element = $(e.target).closest('.js-filterElement') placeholder = @placeholder(item, attribute, params, groups, elements) if element.get(0) @@ -78,7 +78,7 @@ class App.UiElement.ticket_perform_action ) # remove filter - item.on('click', '.js-remove', (e) => + item.on('click', '.js-rowActions .js-remove', (e) => return if $(e.currentTarget).hasClass('is-disabled') $(e.target).closest('.js-filterElement').remove() @updateAttributeSelectors(item) diff --git a/app/assets/javascripts/app/views/generic/ticket_perform_action/row.jst.eco b/app/assets/javascripts/app/views/generic/ticket_perform_action/row.jst.eco index 13fd03350..3c590c8c0 100644 --- a/app/assets/javascripts/app/views/generic/ticket_perform_action/row.jst.eco +++ b/app/assets/javascripts/app/views/generic/ticket_perform_action/row.jst.eco @@ -9,7 +9,7 @@
-
+
<%- @Icon('minus-small') %>
diff --git a/app/views/tests/form_ticket_perform_action.html.erb b/app/views/tests/form_ticket_perform_action.html.erb new file mode 100644 index 000000000..2248bd106 --- /dev/null +++ b/app/views/tests/form_ticket_perform_action.html.erb @@ -0,0 +1,22 @@ + + + + + + + + + +
+ +
+
+
+ +
+
diff --git a/config/routes/test.rb b/config/routes/test.rb index f0a80eadf..e6c0afb63 100644 --- a/config/routes/test.rb +++ b/config/routes/test.rb @@ -1,30 +1,31 @@ Zammad::Application.routes.draw do - match '/tests_core', to: 'tests#core', via: :get - match '/tests_session', to: 'tests#session', via: :get - match '/tests_ui', to: 'tests#ui', via: :get - match '/tests_model', to: 'tests#model', via: :get - match '/tests_model_binding', to: 'tests#model_binding', via: :get - match '/tests_model_ui', to: 'tests#model_ui', via: :get - match '/tests_form', to: 'tests#form', via: :get - match '/tests_form_tree_select', to: 'tests#form_tree_select', via: :get - match '/tests_form_find', to: 'tests#form_find', via: :get - match '/tests_form_trim', to: 'tests#form_trim', via: :get - match '/tests_form_extended', to: 'tests#form_extended', via: :get - match '/tests_form_timer', to: 'tests#form_timer', via: :get - match '/tests_form_validation', to: 'tests#form_validation', via: :get - match '/tests_form_column_select', to: 'tests#form_column_select', via: :get - match '/tests_form_searchable_select', to: 'tests#form_searchable_select', via: :get - match '/tests_table', to: 'tests#table', via: :get - match '/tests_table_extended', to: 'tests#table_extended', via: :get - match '/tests_html_utils', to: 'tests#html_utils', via: :get - match '/tests_ticket_selector', to: 'tests#ticket_selector', via: :get - match '/tests_taskbar', to: 'tests#taskbar', via: :get - match '/tests/wait/:sec', to: 'tests#wait', via: :get - match '/tests/unprocessable_entity', to: 'tests#error_unprocessable_entity', via: :get - match '/tests/not_authorized', to: 'tests#error_not_authorized', via: :get - match '/tests/ar_not_found', to: 'tests#error_ar_not_found', via: :get - match '/tests/standard_error', to: 'tests#error_standard_error', via: :get - match '/tests/argument_error', to: 'tests#error_argument_error', via: :get + match '/tests_core', to: 'tests#core', via: :get + match '/tests_session', to: 'tests#session', via: :get + match '/tests_ui', to: 'tests#ui', via: :get + match '/tests_model', to: 'tests#model', via: :get + match '/tests_model_binding', to: 'tests#model_binding', via: :get + match '/tests_model_ui', to: 'tests#model_ui', via: :get + match '/tests_form', to: 'tests#form', via: :get + match '/tests_form_tree_select', to: 'tests#form_tree_select', via: :get + match '/tests_form_find', to: 'tests#form_find', via: :get + match '/tests_form_trim', to: 'tests#form_trim', via: :get + match '/tests_form_extended', to: 'tests#form_extended', via: :get + match '/tests_form_timer', to: 'tests#form_timer', via: :get + match '/tests_form_validation', to: 'tests#form_validation', via: :get + match '/tests_form_column_select', to: 'tests#form_column_select', via: :get + match '/tests_form_searchable_select', to: 'tests#form_searchable_select', via: :get + match '/tests_form_ticket_perform_action', to: 'tests#form_ticket_perform_action', via: :get + match '/tests_table', to: 'tests#table', via: :get + match '/tests_table_extended', to: 'tests#table_extended', via: :get + match '/tests_html_utils', to: 'tests#html_utils', via: :get + match '/tests_ticket_selector', to: 'tests#ticket_selector', via: :get + match '/tests_taskbar', to: 'tests#taskbar', via: :get + match '/tests/wait/:sec', to: 'tests#wait', via: :get + match '/tests/unprocessable_entity', to: 'tests#error_unprocessable_entity', via: :get + match '/tests/not_authorized', to: 'tests#error_not_authorized', via: :get + match '/tests/ar_not_found', to: 'tests#error_ar_not_found', via: :get + match '/tests/standard_error', to: 'tests#error_standard_error', via: :get + match '/tests/argument_error', to: 'tests#error_argument_error', via: :get end diff --git a/public/assets/tests/form_ticket_perform_action.js b/public/assets/tests/form_ticket_perform_action.js new file mode 100644 index 000000000..3ffa674e2 --- /dev/null +++ b/public/assets/tests/form_ticket_perform_action.js @@ -0,0 +1,197 @@ +// ticket_perform_action +test( "ticket_perform_action check", function() { + + App.TicketPriority.refresh([ + { + id: 2, + name: '2 normal', + active: false, + }, + { + id: 1, + name: '1 low', + active: true, + }, + ]) + + App.TicketState.refresh([ + { + id: 1, + name: 'new', + active: true, + }, + { + id: 2, + name: 'open', + active: true, + }, + { + id: 3, + name: 'closed', + active: false, + }, + ]) + + $('#forms').append('

ticket_perform_action check

') + var el = $('#form1') + var defaults = { + ticket_perform_action1: { + 'ticket.state_id': { + value: '2' + } + }, + ticket_perform_action2: { + 'ticket.state_id': { + value: '1' + }, + 'ticket.priority_id': { + value: '2' + }, + 'notification.email': { + body: 'some body', + recipient: ['ticket_owner', 'ticket_customer'], + subject: 'some subject' + }, + }, + ticket_perform_action3: { + 'ticket.state_id': { + value: '3' + }, + + } + } + new App.ControllerForm({ + el: el, + model: { + configure_attributes: [ + { + name: 'ticket_perform_action1', + display: 'TicketPerformAction1', + tag: 'ticket_perform_action', + null: true, + }, + { + name: 'ticket_perform_action2', + display: 'TicketPerformAction2', + tag: 'ticket_perform_action', + null: false, + notification: true, + }, + { + name: 'ticket_perform_action3', + display: 'TicketPerformAction3', + tag: 'ticket_perform_action', + null: true, + notification: true, + }, + ] + }, + params: defaults, + autofocus: true + }) + + var params = App.ControllerForm.params(el) + var test_params = { + ticket_perform_action1: { + 'ticket.state_id': { + value: '2' + } + }, + ticket_perform_action2: { + 'notification.email': { + body: 'some body', + recipient: ['ticket_owner', 'ticket_customer'], + subject: 'some subject' + }, + 'ticket.priority_id': { + value: '2' + }, + 'ticket.state_id': { + value: '1' + }, + }, + ticket_perform_action3: { + 'ticket.state_id': { + value: '3' + } + } + } + deepEqual(params, test_params, 'form param check') + + // add email notification + $('[data-attribute-name="ticket_perform_action3"] .js-add').click() + $('[data-attribute-name="ticket_perform_action3"] .js-attributeSelector .form-control').last().val('notification.email').trigger('change') + $('[data-attribute-name="ticket_perform_action3"] .js-setNotification [name="ticket_perform_action3::notification.email::subject"]').val('some subject').trigger('change') + $('[data-attribute-name="ticket_perform_action3"] .js-setNotification [data-name="ticket_perform_action3::notification.email::body"]').html('some body').trigger('change') + $('[data-attribute-name="ticket_perform_action3"] .js-setNotification .js-recipient .js-option[data-value="ticket_owner"]').click() + + params = App.ControllerForm.params(el) + test_params = { + ticket_perform_action1: { + 'ticket.state_id': { + value: '2' + } + }, + ticket_perform_action2: { + 'notification.email': { + body: 'some body', + recipient: ['ticket_owner', 'ticket_customer'], + subject: 'some subject' + }, + 'ticket.priority_id': { + value: '2' + }, + 'ticket.state_id': { + value: '1' + }, + }, + ticket_perform_action3: { + 'notification.email': { + body: 'some body', + recipient: 'ticket_owner', + subject: 'some subject' + }, + 'ticket.state_id': { + value: '3' + } + } + } + deepEqual(params, test_params, 'form param check') + + // remove recipient + $('[data-attribute-name="ticket_perform_action2"] .js-setNotification .js-recipient .js-remove.js-option[data-value="ticket_owner"]').click() + + params = App.ControllerForm.params(el) + test_params = { + ticket_perform_action1: { + 'ticket.state_id': { + value: '2' + } + }, + ticket_perform_action2: { + 'notification.email': { + body: 'some body', + recipient: 'ticket_customer', + subject: 'some subject' + }, + 'ticket.priority_id': { + value: '2' + }, + 'ticket.state_id': { + value: '1' + }, + }, + ticket_perform_action3: { + 'notification.email': { + body: 'some body', + recipient: 'ticket_owner', + subject: 'some subject' + }, + 'ticket.state_id': { + value: '3' + } + } + } + deepEqual(params, test_params, 'form param check') + +}); diff --git a/spec/system/js/q_unit_spec.rb b/spec/system/js/q_unit_spec.rb index 16dfebe8e..5e51c4034 100644 --- a/spec/system/js/q_unit_spec.rb +++ b/spec/system/js/q_unit_spec.rb @@ -86,6 +86,10 @@ RSpec.describe 'QUnit', type: :system, authenticated: false, set_up: true, webso q_unit_tests('form_column_select') end + it 'Ticket perform action' do + q_unit_tests('form_ticket_perform_action') + end + it 'Validation' do q_unit_tests('form_validation') end diff --git a/test/browser/aab_unit_test.rb b/test/browser/aab_unit_test.rb index 4ab1fbfc5..4321cddfe 100644 --- a/test/browser/aab_unit_test.rb +++ b/test/browser/aab_unit_test.rb @@ -157,6 +157,17 @@ class AAbUnitTest < TestCase value: '0', ) + location(url: browser_url + '/tests_form_ticket_perform_action') + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) + match( + css: '.result .failed', + value: '0', + ) + location(url: browser_url + '/tests_form_tree_select') watch_for( css: '.result',