]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 Facets UX
authorStas Vilchik <vilchiks@gmail.com>
Tue, 11 Mar 2014 10:00:42 +0000 (16:00 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 11 Mar 2014 10:00:55 +0000 (16:00 +0600)
sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee
sonar-server/src/main/webapp/javascripts/coding-rules/app.js
sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-facets-view.coffee
sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-facets-view.js
sonar-server/src/main/webapp/stylesheets/navigator.css
sonar-server/src/main/webapp/stylesheets/navigator/base.css
sonar-server/src/main/webapp/stylesheets/navigator/base.less

index b8c776fa08b6b100ff0af6566d9989d8d332cdbf..2ac34dbf19752edb4f2a4da5196892db84ae68f9 100644 (file)
@@ -96,7 +96,7 @@ requirejs [
 
 
 
-  App.fetchList = (firstPage) ->
+  App.fetchList = (firstPage, fetchFacets = true) ->
     query = @getQuery()
     fetchQuery = _.extend { pageIndex: @pageIndex }, query
 
@@ -105,10 +105,13 @@ requirejs [
           sort: @codingRules.sorting.sort,
           asc: @codingRules.sorting.asc
 
+    unless fetchFacets
+      _.extend fetchQuery, facets: false
+
     @storeQuery query, @codingRules.sorting
 
     @layout.showSpinner 'resultsRegion'
-    @layout.showSpinner 'facetsRegion'
+    @layout.showSpinner 'facetsRegion' if fetchFacets
     jQuery.ajax
       url: "#{baseUrl}/api/codingrules/search"
       data: fetchQuery
@@ -124,17 +127,18 @@ requirejs [
       @layout.resultsRegion.show @codingRulesListView
       @codingRulesListView.selectFirst()
 
-      @facets.reset r.facets
-      @codingRulesFacetsView = new CodingRulesFacetsView
-        app: @
-        collection: @facets
-      @layout.facetsRegion.show @codingRulesFacetsView
+      if fetchFacets
+        @facets.reset r.facets
+        @codingRulesFacetsView = new CodingRulesFacetsView
+          app: @
+          collection: @facets
+        @layout.facetsRegion.show @codingRulesFacetsView
 
 
 
-  App.fetchFirstPage = ->
+  App.fetchFirstPage = (fetchFacets = true) ->
     @pageIndex = 1
-    App.fetchList true
+    App.fetchList true, fetchFacets
 
 
   App.fetchNextPage = ->
index 129cdaa5dabeda26b49089e28788b29117a7039d..2b238827ade4b4ada0985e8db244104bac3e2079 100644 (file)
         replace: true
       });
     };
-    App.fetchList = function(firstPage) {
+    App.fetchList = function(firstPage, fetchFacets) {
       var fetchQuery, query,
         _this = this;
+      if (fetchFacets == null) {
+        fetchFacets = true;
+      }
       query = this.getQuery();
       fetchQuery = _.extend({
         pageIndex: this.pageIndex
           asc: this.codingRules.sorting.asc
         });
       }
+      if (!fetchFacets) {
+        _.extend(fetchQuery, {
+          facets: false
+        });
+      }
       this.storeQuery(query, this.codingRules.sorting);
       this.layout.showSpinner('resultsRegion');
-      this.layout.showSpinner('facetsRegion');
+      if (fetchFacets) {
+        this.layout.showSpinner('facetsRegion');
+      }
       return jQuery.ajax({
         url: "" + baseUrl + "/api/codingrules/search",
         data: fetchQuery
         });
         _this.layout.resultsRegion.show(_this.codingRulesListView);
         _this.codingRulesListView.selectFirst();
-        _this.facets.reset(r.facets);
-        _this.codingRulesFacetsView = new CodingRulesFacetsView({
-          app: _this,
-          collection: _this.facets
-        });
-        return _this.layout.facetsRegion.show(_this.codingRulesFacetsView);
+        if (fetchFacets) {
+          _this.facets.reset(r.facets);
+          _this.codingRulesFacetsView = new CodingRulesFacetsView({
+            app: _this,
+            collection: _this.facets
+          });
+          return _this.layout.facetsRegion.show(_this.codingRulesFacetsView);
+        }
       });
     };
-    App.fetchFirstPage = function() {
+    App.fetchFirstPage = function(fetchFacets) {
+      if (fetchFacets == null) {
+        fetchFacets = true;
+      }
       this.pageIndex = 1;
-      return App.fetchList(true);
+      return App.fetchList(true, fetchFacets);
     };
     App.fetchNextPage = function() {
       if (this.pageIndex < this.codingRules.paging.pages) {
index b204fe842d6f72654de0e96104c3e7f38bfae52e..0dd3b2d45e67a32c9d5ef7869e54854a6e1a4abc 100644 (file)
@@ -10,3 +10,16 @@ define [
     tagName: 'ul'
     className: 'navigator-facets-list'
     itemView: CodingRulesFacetsItemView
+
+
+    ui:
+      options: '.navigator-facets-list-item-option'
+
+
+    events:
+      'click @ui.options': 'toggleOption'
+
+
+    toggleOption: (e) ->
+      jQuery(e.currentTarget).toggleClass 'active'
+      @options.app.fetchFirstPage false
index 10f877568fdb15fb7be664da4255005f890d2622..6e3d9064121ece492c7d9542956c8ef0399e8af1 100644 (file)
 
       CodingRulesFacetsView.prototype.itemView = CodingRulesFacetsItemView;
 
+      CodingRulesFacetsView.prototype.ui = {
+        options: '.navigator-facets-list-item-option'
+      };
+
+      CodingRulesFacetsView.prototype.events = {
+        'click @ui.options': 'toggleOption'
+      };
+
+      CodingRulesFacetsView.prototype.toggleOption = function(e) {
+        jQuery(e.currentTarget).toggleClass('active');
+        return this.options.app.fetchFirstPage(false);
+      };
+
       return CodingRulesFacetsView;
 
     })(Marionette.CollectionView);
index 3f4111a724a6a908d44fdcbb76578ee8dfe6fb41..3a0c5fd6f2a58e69d9fc50b8746c2fbdf85a843b 100644 (file)
 .navigator-facets-list-item-option:hover .navigator-facets-list-item-option-name {
   text-decoration: underline;
 }
+.navigator-facets-list-item-option.active .navigator-facets-list-item-option-name {
+  font-weight: bold;
+  text-decoration: underline;
+}
 .navigator-facets-list-item-option-stat:before {
   content: "(";
 }
index 869c2fcc2895fa3ee8af6e1e7e26f129677b30b5..75947e16c9d31207f8155150b2c6704cddaf9d74 100644 (file)
 .navigator-facets-list-item-option:hover .navigator-facets-list-item-option-name {
   text-decoration: underline;
 }
+.navigator-facets-list-item-option.active .navigator-facets-list-item-option-name {
+  font-weight: bold;
+  text-decoration: underline;
+}
 .navigator-facets-list-item-option-stat:before {
   content: "(";
 }
index 378a576d37b49c6172dd0804749bb9b9205a6450..f779c3a14486f2b788d06a8898a0da9a9beb38a8 100644 (file)
       text-decoration: underline;
     }
   }
+
+  &.active {
+    .navigator-facets-list-item-option-name {
+      font-weight: bold;
+      text-decoration: underline;
+    }
+  }
 }
 
 .navigator-facets-list-item-option-name {