ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject [2/2] ambari git commit: AMBARI-8990 Link for clearing filter is being shown even when none of the filter is active (ababiichuk)
Date Tue, 24 Feb 2015 14:08:35 GMT
AMBARI-8990 Link for clearing filter is being shown even when none of the filter is active
(ababiichuk)


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

Branch: refs/heads/trunk
Commit: 32c30c8f9678477a0be53678e36577e5c9a40897
Parents: 0c23443
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Tue Feb 24 12:43:35 2015 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Tue Feb 24 16:07:17 2015 +0200

----------------------------------------------------------------------
 .../templates/main/dashboard/config_history.hbs |  2 ++
 ambari-web/app/templates/main/host.hbs          |  4 +++-
 .../app/templates/main/host/host_alerts.hbs     |  6 ++++--
 .../app/templates/main/host/stack_versions.hbs  |  6 ++++--
 ambari-web/app/views/common/table_view.js       | 20 +++++++++++++++++++
 ambari-web/test/views/common/table_view_test.js | 21 ++++++++++++++++++++
 6 files changed, 54 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/32c30c8f/ambari-web/app/templates/main/dashboard/config_history.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/dashboard/config_history.hbs b/ambari-web/app/templates/main/dashboard/config_history.hbs
index af921fb..ccbcf05 100644
--- a/ambari-web/app/templates/main/dashboard/config_history.hbs
+++ b/ambari-web/app/templates/main/dashboard/config_history.hbs
@@ -87,8 +87,10 @@
 
   <div class="page-bar">
     <div class="filtered-info span4">
+    {{#if view.showFilteredContent}}
       <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
               href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+    {{/if}}
     </div>
     <div class="items-on-page">
       <label>{{t common.show}}: {{view view.rowsPerPageSelectView selectionBinding="view.displayLength"}}</label>

http://git-wip-us.apache.org/repos/asf/ambari/blob/32c30c8f/ambari-web/app/templates/main/host.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host.hbs b/ambari-web/app/templates/main/host.hbs
index 3474686..01f2951 100644
--- a/ambari-web/app/templates/main/host.hbs
+++ b/ambari-web/app/templates/main/host.hbs
@@ -169,7 +169,9 @@
 
   <div class="page-bar">
     <div class="filtered-info span4">
-      <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
id="hosts-page-clear-filters" href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+      {{#if view.showFilteredContent}}
+        <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
id="hosts-page-clear-filters" href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+      {{/if}}
     </div>
     <div class="selected-hosts-info span4">
       {{#if view.showSelectedFilter}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/32c30c8f/ambari-web/app/templates/main/host/host_alerts.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/host_alerts.hbs b/ambari-web/app/templates/main/host/host_alerts.hbs
index 407cca8..344fb7a 100644
--- a/ambari-web/app/templates/main/host/host_alerts.hbs
+++ b/ambari-web/app/templates/main/host/host_alerts.hbs
@@ -72,8 +72,10 @@
 
   <div class="page-bar">
     <div class="filtered-info span4">
-      <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
-          href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+      {{#if view.showFilteredContent}}
+        <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
+            href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+      {{/if}}
     </div>
     <div class="selected-hosts-info span4">
     </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/32c30c8f/ambari-web/app/templates/main/host/stack_versions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/stack_versions.hbs b/ambari-web/app/templates/main/host/stack_versions.hbs
index 0627ae1..ea5a74b 100644
--- a/ambari-web/app/templates/main/host/stack_versions.hbs
+++ b/ambari-web/app/templates/main/host/stack_versions.hbs
@@ -69,8 +69,10 @@
 
 <div class="page-bar">
   <div class="filtered-info span4">
-    <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
-      href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+    {{#if view.showFilteredContent}}
+      <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
+        href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+    {{/if}}
   </div>
   <div class="items-on-page">
     <label>{{t common.show}}: {{view view.rowsPerPageSelectView selectionBinding="view.parentView.displayLength"}}</label>

http://git-wip-us.apache.org/repos/asf/ambari/blob/32c30c8f/ambari-web/app/views/common/table_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/table_view.js b/ambari-web/app/views/common/table_view.js
index b17c011..cc1c2d6 100644
--- a/ambari-web/app/views/common/table_view.js
+++ b/ambari-web/app/views/common/table_view.js
@@ -413,6 +413,26 @@ App.TableView = Em.View.extend(App.UserPref, {
   }.property('filteredCount', 'startIndex', 'endIndex'),
 
   /**
+   * flag to toggle displaying filtered hosts counter
+   */
+  showFilteredContent: function () {
+    var result = false;
+    if (this.get('filterConditions.length') > 0) {
+      this.get('filterConditions').forEach(function(f) {
+        if (f.value) {
+          if (Em.typeOf(f.value) == "array") {
+            if (f.value[0] || f.value[1]) {
+              result = true;
+            }
+          } else {
+            result = true;
+          }
+        }
+      });
+    }
+    return result;
+  }.property('filteredContent'),
+  /**
    * Filter table by filterConditions
    */
   filter: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/32c30c8f/ambari-web/test/views/common/table_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/table_view_test.js b/ambari-web/test/views/common/table_view_test.js
index a7554a6..c311834 100644
--- a/ambari-web/test/views/common/table_view_test.js
+++ b/ambari-web/test/views/common/table_view_test.js
@@ -265,4 +265,25 @@ describe('App.TableView', function () {
 
   });
 
+  describe("#showFilteredContent", function() {
+    beforeEach(function() {
+      view = App.TableView.create({});
+    });
+
+    it('hide clear filters link', function () {
+      view.set('filterConditions', []);
+      expect(view.get('showFilteredContent')).to.be.false;
+    });
+
+    it('shows clear filters link', function () {
+      view.set('filterConditions', [{value: "1"}]);
+      expect(view.get('showFilteredContent')).to.be.true;
+    });
+
+    it('shows clear filters link for array filter', function () {
+      view.set('filterConditions', [{value: ["1", "2"]}]);
+      expect(view.get('showFilteredContent')).to.be.true;
+    });
+  });
+
 });


Mime
View raw message