ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [34/55] [abbrv] ambari git commit: AMBARI-20621 Implement handling of conditional expressions for data attributes helper. (ababiichuk)
Date Fri, 31 Mar 2017 07:22:41 GMT
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/455870b1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/455870b1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/455870b1

Branch: refs/heads/branch-3.0-perf
Commit: 455870b1d1532e3719d67c65bf429af14f456558
Parents: 27af648
Author: ababiichuk <ababiichuk@hortonworks.com>
Authored: Wed Mar 29 18:31:14 2017 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Fri Mar 31 10:21:45 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/455870b1/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);
     });
   }


Mime
View raw message