ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-8556. Sorting by non-string values is broken (onechiporenko)
Date Fri, 05 Dec 2014 12:15:32 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk a5c6834d6 -> 753029ff5


AMBARI-8556. Sorting by non-string values is broken (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/753029ff
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/753029ff
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/753029ff

Branch: refs/heads/trunk
Commit: 753029ff55c07cda1fbe20108cd6e0000f08bee5
Parents: a5c6834
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Fri Dec 5 14:13:09 2014 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Fri Dec 5 14:13:09 2014 +0200

----------------------------------------------------------------------
 ambari-web/app/views/common/sort_view.js       | 8 ++++----
 ambari-web/test/views/common/sort_view_test.js | 8 ++++++++
 2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/753029ff/ambari-web/app/views/common/sort_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/sort_view.js b/ambari-web/app/views/common/sort_view.js
index 880d74e..3615af1 100644
--- a/ambari-web/app/views/common/sort_view.js
+++ b/ambari-web/app/views/common/sort_view.js
@@ -171,12 +171,12 @@ var wrapperView = Em.View.extend({
         };
         break;
       case 'alert_status':
-        func = function(a, b) {
+        func = function (a, b) {
           var a_summary = a.get('summary'),
             b_summary = b.get('summary'),
             st_order = a.get('severityOrder'),
             ret = 0;
-          for(var i = 0; i < st_order.length; i++) {
+          for (var i = 0; i < st_order.length; i++) {
             var a_v = Em.isNone(a_summary[st_order[i]]) ? 0 : a_summary[st_order[i]],
               b_v = Em.isNone(b_summary[st_order[i]]) ? 0 : b_summary[st_order[i]];
             ret = b_v - a_v;
@@ -196,8 +196,8 @@ var wrapperView = Em.View.extend({
         func = function (a, b) {
           var a_p = a.get(property.get('name'));
           var b_p = b.get(property.get('name'));
-          a_p = Em.isNone(a_p) ? '' : a_p;
-          b_p = Em.isNone(b_p) ? '' : b_p;
+          a_p = Em.isNone(a_p) ? '' : '' + a_p;
+          b_p = Em.isNone(b_p) ? '' : '' + b_p;
           return order ? a_p.localeCompare(b_p) : b_p.localeCompare(a_p)
         };
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/753029ff/ambari-web/test/views/common/sort_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/sort_view_test.js b/ambari-web/test/views/common/sort_view_test.js
index ef61551..f03fb52 100644
--- a/ambari-web/test/views/common/sort_view_test.js
+++ b/ambari-web/test/views/common/sort_view_test.js
@@ -143,6 +143,14 @@ describe('#wrapperView', function () {
           });
       });
 
+      it('test non-string values', function () {
+        property = Em.Object.create({type: 'string', name: 'enabled'});
+        var func = sort.wrapperView.create().getSortFunc(property, true),
+        a = Em.Object.create({enabled: false}),
+        b = Em.Object.create({enabled: true});
+        expect(func(a, b)).to.equal(-1);
+      });
+
     });
 
   });


Mime
View raw message