Fixes issue #2516 - trigger email notification UI defective on removal of recipient.

This commit is contained in:
Martin Edenhofer 2019-06-07 13:28:58 +02:00
parent c7d1b9d8d7
commit db531e66b3
7 changed files with 264 additions and 29 deletions

View file

@ -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)

View file

@ -9,7 +9,7 @@
<div class="js-setNotification flex"></div>
<div class="js-setArticle flex"></div>
</div>
<div class="filter-controls">
<div class="filter-controls js-rowActions">
<div class="filter-control filter-control-remove js-remove" title="<%- @Ti('Remote') %>">
<%- @Icon('minus-small') %>
</div>

View file

@ -0,0 +1,22 @@
<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
<script src="/assets/tests/qunit-1.21.0.js"></script>
<script src="/assets/tests/form_ticket_perform_action.js"></script>
<style type="text/css">
body {
padding-top: 0px;
}
</style>
<script type="text/javascript">
</script>
<div id="qunit" class="u-dontfold"></div>
<div>
<form class="form-stacked pull-left">
<div id="forms"></div>
<button type="submit" class="btn btn-primary submit">Submit</button>
</form>
</div>

View file

@ -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

View file

@ -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('<hr><h1>ticket_perform_action check</h1><form id="form1"></form>')
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')
});

View file

@ -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

View file

@ -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',