You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2017/03/29 16:14:56 UTC
ambari git commit: AMBARI-20621 Implement handling of conditional
expressions for data attributes helper. (ababiichuk)
Repository: ambari
Updated Branches:
refs/heads/trunk 4d6c80feb -> f44d9d22b
AMBARI-20621 Implement handling of conditional expressions for data attributes helper. (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f44d9d22
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f44d9d22
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f44d9d22
Branch: refs/heads/trunk
Commit: f44d9d22b2c03797cf76c8fefd4e919f2d5b3c77
Parents: 4d6c80f
Author: ababiichuk <ab...@hortonworks.com>
Authored: Wed Mar 29 18:31:14 2017 +0300
Committer: ababiichuk <ab...@hortonworks.com>
Committed: Wed Mar 29 18:31:14 2017 +0300
----------------------------------------------------------------------
ambari-web/app/utils/helper.js | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/f44d9d22/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index 6c706b8..0d4ea80 100644
--- a/ambari-web/app/utils/helper.js
+++ b/ambari-web/app/utils/helper.js
@@ -366,6 +366,12 @@ Em.Handlebars.registerHelper('highlight', function (property, words, fn) {
* <div {{QAAttr "someText"}}></div>
* <div {{QAAttr "{someProperty}"}}></div>
* <div {{QAAttr "someText-and-{someProperty}"}}></div>
+ * <div {{QAAttr "{someProperty:some-text}"}}></div>
+ * <div {{QAAttr "someText-and-{someProperty:some-text}"}}></div>
+ * <div {{QAAttr "{someProperty:some-text:another-text}"}}></div>
+ * <div {{QAAttr "someText-and-{someProperty:some-text:another-text}"}}></div>
+ * <div {{QAAttr "{someProperty::another-text}"}}></div>
+ * <div {{QAAttr "someText-and-{someProperty::another-text}"}}></div>
*
*/
Em.Handlebars.registerHelper('QAAttr', function(text, data) {
@@ -373,7 +379,15 @@ Em.Handlebars.registerHelper('QAAttr', function(text, data) {
var textToReplace = text.match(/\{(.*?)\}/g);
if (textToReplace) {
textToReplace.forEach(function (t) {
- var value = Em.Handlebars.getPath(self, t.slice(1, t.length-1), data);
+ var value,
+ expression = t.slice(1, t.length - 1),
+ conditionals = Em.View._parsePropertyPath(expression);
+ if (conditionals.classNames) {
+ var sourceValue = Em.Handlebars.getPath(self, conditionals.path, data);
+ value = sourceValue ? conditionals.className : (conditionals.falsyClassName || '');
+ } else {
+ value = Em.Handlebars.getPath(self, expression, data);
+ }
text = text.replace(t, value);
});
}