From 025cc8b12f5e992d3ca53d6944bc899ee1c14ba7 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 2 Dec 2020 09:35:59 +0100 Subject: [PATCH] Fixed #3321 - Unable to unassign owner via macro or trigger. --- .../_ui_element/ticket_perform_action.coffee | 6 +- .../tests/form_ticket_perform_action.js | 59 +++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) 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 d53da8ec4..f5e40d8b8 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 @@ -275,12 +275,14 @@ class App.UiElement.ticket_perform_action options = 'current_user.id': App.i18n.translateInline('current user') 'specific': App.i18n.translateInline('specific user') - #'set': App.i18n.translateInline('set') + + if attributeSelected.null is true + options['not_set'] = App.i18n.translateInline('unassign user') + else if preCondition is 'org' options = 'current_user.organization_id': App.i18n.translateInline('current user organization') 'specific': App.i18n.translateInline('specific organization') - #'set': App.i18n.translateInline('set') for key, value of options selected = '' diff --git a/public/assets/tests/form_ticket_perform_action.js b/public/assets/tests/form_ticket_perform_action.js index ba79b63f8..778f17050 100644 --- a/public/assets/tests/form_ticket_perform_action.js +++ b/public/assets/tests/form_ticket_perform_action.js @@ -546,3 +546,62 @@ test( "ticket_perform_action orphan time fields", function() { equal(el.find('.js-valueRangeSelector').length, 0) }); + +test( "ticket_perform_action check possible owner selection", function() { + $('#forms').append('

ticket_perform_action check possible owner selection

') + + var el = $('#form5') + + var defaults = { + ticket_perform_action5: { + 'ticket.owner_id': { + pre_condition: 'not_set', + } + } + } + + new App.ControllerForm({ + el: el, + model: { + configure_attributes: [ + { + name: 'ticket_perform_action5', + display: 'TicketPerformAction5', + tag: 'ticket_perform_action', + null: true, + }, + ] + }, + params: defaults, + autofocus: true + }) + + var params = App.ControllerForm.params(el) + var test_params = { + ticket_perform_action5: { + 'ticket.owner_id': { + pre_condition: 'not_set', + value: '', + value_completion: '' + } + } + } + + deepEqual(params, test_params, 'form param check') + + el.find('[name="ticket_perform_action5::ticket.owner_id::pre_condition"]').val('specific').trigger('change') + + params = App.ControllerForm.params(el) + test_params = { + ticket_perform_action5: { + 'ticket.owner_id': { + pre_condition: 'specific', + value: '', + value_completion: '' + } + } + } + + deepEqual(params, test_params, 'form param check') + +});