From 5a5419c2c10ca36e387e6a42fb97d6d2ec1250b4 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 18 Sep 2015 13:35:56 +0200 Subject: [PATCH] Improved human text. --- .../_ui_element/ticket_selector.js.coffee | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_ui_element/ticket_selector.js.coffee b/app/assets/javascripts/app/controllers/_ui_element/ticket_selector.js.coffee index c870b258d..5b8c680a2 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/ticket_selector.js.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/ticket_selector.js.coffee @@ -84,9 +84,10 @@ class App.UiElement.ticket_selector ) # build inital params - if !_.isEmpty(params.condition) + if !_.isEmpty(params[attribute.name]) + selectorExists = false - for groupAndAttribute, meta of params.condition + for groupAndAttribute, meta of params[attribute.name] if groupAndAttribute isnt 'attribute' selectorExists = true operator = meta.operator @@ -268,18 +269,11 @@ class App.UiElement.ticket_selector # get stored params if meta && objectAttribute[1] - selectorExists = true operator = meta.operator value = meta.value model = toCamelCase(objectAttribute[0]) - modelAttribute = objectAttribute[1] - config = elements[attribute] - if modelAttribute.substr(modelAttribute.length-4,4) is '_ids' - modelAttribute = modelAttribute.substr(0, modelAttribute.length-4) - if modelAttribute.substr(modelAttribute.length-3,3) is '_id' - modelAttribute = modelAttribute.substr(0, modelAttribute.length-3) valueHuman = [] if _.isArray(value) for data in value @@ -287,7 +281,10 @@ class App.UiElement.ticket_selector valueHuman.push r else valueHuman.push @humanTextLookup(config, value) - rules.push "#{App.i18n.translateContent('Where')} #{App.i18n.translateContent(model)} -> #{App.i18n.translateContent(toCamelCase(modelAttribute))} #{App.i18n.translateContent(operator)} #{valueHuman}." + + if valueHuman.join + valueHuman = valueHuman.join(', ') + rules.push "#{App.i18n.translateContent('Where')} #{App.i18n.translateContent(model)} -> #{App.i18n.translateContent(config.display)} #{App.i18n.translateContent(operator)} #{valueHuman}." return [none] if _.isEmpty(rules) rules