From 053429bb7975cf55b4b061b10b871b6b998d8c35 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Fri, 6 Nov 2020 10:49:32 +0100 Subject: [PATCH] Fixes #3042 - Timeaccounting ignores tags in conditions. --- .../app/controllers/ticket_zoom.coffee | 4 +++- app/assets/javascripts/app/models/ticket.coffee | 5 ++++- public/assets/tests/ticket_selector.js | 15 +++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index 9ab37aac9..08abc2158 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -884,8 +884,10 @@ class App.TicketZoom extends App.Controller return # verify if time accounting is active for ticket + selector = ticket.clone() + selector.tags = @tags time_accounting_selector = @Config.get('time_accounting_selector') - if !App.Ticket.selector(ticket, time_accounting_selector['condition']) + if !App.Ticket.selector(selector, time_accounting_selector['condition']) @submitPost(e, ticket, macro) return diff --git a/app/assets/javascripts/app/models/ticket.coffee b/app/assets/javascripts/app/models/ticket.coffee index a74967cf1..c39311ce2 100644 --- a/app/assets/javascripts/app/models/ticket.coffee +++ b/app/assets/javascripts/app/models/ticket.coffee @@ -120,7 +120,7 @@ class App.Ticket extends App.Model # apply tag changes if attributes[1] is 'tags' - tags = content.value.split(',') + tags = content.value.split(/\s*,\s*/) for tag in tags if content.operator is 'remove' if params.callback && params.callback.tagRemove @@ -244,6 +244,9 @@ class App.Ticket extends App.Model contains_regex = new RegExp(App.Utils.escapeRegExp(conditionValue.toString()), 'i') # move value to array if it is not already + if objectName is 'ticket' && attributeName is 'tags' + conditionValue = conditionValue.split(/\s*,\s*/) + if !_.isArray(objectValue) objectValue = [objectValue] # move value to array if it is not already diff --git a/public/assets/tests/ticket_selector.js b/public/assets/tests/ticket_selector.js index edf4de3f4..7c7ac3c0f 100644 --- a/public/assets/tests/ticket_selector.js +++ b/public/assets/tests/ticket_selector.js @@ -457,7 +457,7 @@ window.onload = function() { "condition": { "ticket.tags": { "operator": "contains all", - "value": ["tag a", "not existing"], + "value": "tag a, not existing", }, } }; @@ -479,7 +479,7 @@ window.onload = function() { "condition": { "ticket.tags": { "operator": "contains all not", - "value": ["tag a", "tag b"], + "value": "tag a, tag b", }, } }; @@ -490,7 +490,7 @@ window.onload = function() { "condition": { "ticket.tags": { "operator": "contains all not", - "value": ["tag a", "tag b", "tag c"], + "value": "tag a, tag b, tag c", }, } }; @@ -501,7 +501,7 @@ window.onload = function() { "condition": { "ticket.tags": { "operator": "contains all not", - "value": ["tag c", "tag d"], + "value": "tag c, tag d", }, } }; @@ -516,7 +516,6 @@ window.onload = function() { }, } }; - result = App.Ticket.selector(ticket, setting['condition']); equal(result, true, result); @@ -524,7 +523,7 @@ window.onload = function() { "condition": { "ticket.tags": { "operator": "contains one not", - "value": ["tag a", "tag b"], + "value": "tag a, tag b", }, } }; @@ -535,7 +534,7 @@ window.onload = function() { "condition": { "ticket.tags": { "operator": "contains one not", - "value": ["tag a", "tag c"], + "value": "tag a, tag c", }, } }; @@ -546,7 +545,7 @@ window.onload = function() { "condition": { "ticket.tags": { "operator": "contains one not", - "value": ["tag c"], + "value": "tag c", }, } };