<script id="coding-rules-layout" type="text/x-handlebars-template">
<div class="navigator-header"></div>
<div class="navigator-filters"></div>
- <div class="navigator-facets"></div>
<div class="navigator-actions"></div>
<div class="navigator-results"></div>
<div class="navigator-details"></div>
'coding-rules/views/actions-view',
'coding-rules/views/filter-bar-view',
'coding-rules/views/coding-rules-list-view',
- 'coding-rules/views/coding-rules-facets-view',
# filters
'navigator/filters/base-filters',
CodingRulesActionsView,
CodingRulesFilterBarView,
CodingRulesListView,
- CodingRulesFacetsView,
# filters
BaseFilters,
- App.fetchList = (firstPage, fetchFacets = true) ->
+ App.fetchList = (firstPage) ->
query = @getQuery()
fetchQuery = _.extend { pageIndex: @pageIndex }, query
sort: @codingRules.sorting.sort,
asc: @codingRules.sorting.asc
- unless fetchFacets
- _.extend fetchQuery, facets: false
-
@storeQuery query, @codingRules.sorting
@layout.showSpinner 'resultsRegion'
- @layout.showSpinner 'facetsRegion' if fetchFacets
+ @layout.showSpinner 'facetsRegion'
jQuery.ajax
url: "#{baseUrl}/api/codingrules/search"
data: fetchQuery
@layout.resultsRegion.show @codingRulesListView
@codingRulesListView.selectFirst()
- if fetchFacets
- @facets.reset r.facets
- @codingRulesFacetsView = new CodingRulesFacetsView
- app: @
- collection: @facets
- @layout.facetsRegion.show @codingRulesFacetsView
-
- App.fetchFirstPage = (fetchFacets = true) ->
+ App.fetchFirstPage = ->
@pageIndex = 1
- App.fetchList true, fetchFacets
+ App.fetchList true
App.fetchNextPage = ->
# Define coding rules
App.addInitializer ->
@codingRules = new Backbone.Collection
- @facets = new Backbone.Collection
# Construct status bar
}
});
- requirejs(['backbone', 'backbone.marionette', 'coding-rules/layout', 'coding-rules/router', 'coding-rules/views/header-view', 'coding-rules/views/actions-view', 'coding-rules/views/filter-bar-view', 'coding-rules/views/coding-rules-list-view', 'coding-rules/views/coding-rules-facets-view', 'navigator/filters/base-filters', 'navigator/filters/choice-filters', 'navigator/filters/string-filters', 'coding-rules/views/filters/quality-profile-filter-view', 'coding-rules/mockjax'], function(Backbone, Marionette, CodingRulesLayout, CodingRulesRouter, CodingRulesHeaderView, CodingRulesActionsView, CodingRulesFilterBarView, CodingRulesListView, CodingRulesFacetsView, BaseFilters, ChoiceFilters, StringFilterView, QualityProfileFilterView) {
+ requirejs(['backbone', 'backbone.marionette', 'coding-rules/layout', 'coding-rules/router', 'coding-rules/views/header-view', 'coding-rules/views/actions-view', 'coding-rules/views/filter-bar-view', 'coding-rules/views/coding-rules-list-view', 'navigator/filters/base-filters', 'navigator/filters/choice-filters', 'navigator/filters/string-filters', 'coding-rules/views/filters/quality-profile-filter-view', 'coding-rules/mockjax'], function(Backbone, Marionette, CodingRulesLayout, CodingRulesRouter, CodingRulesHeaderView, CodingRulesActionsView, CodingRulesFilterBarView, CodingRulesListView, BaseFilters, ChoiceFilters, StringFilterView, QualityProfileFilterView) {
var App, appXHR;
jQuery.ajaxSetup({
error: function(jqXHR) {
replace: true
});
};
- App.fetchList = function(firstPage, fetchFacets) {
+ App.fetchList = function(firstPage) {
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');
- if (fetchFacets) {
- this.layout.showSpinner('facetsRegion');
- }
+ this.layout.showSpinner('facetsRegion');
return jQuery.ajax({
url: "" + baseUrl + "/api/codingrules/search",
data: fetchQuery
collection: _this.codingRules
});
_this.layout.resultsRegion.show(_this.codingRulesListView);
- _this.codingRulesListView.selectFirst();
- if (fetchFacets) {
- _this.facets.reset(r.facets);
- _this.codingRulesFacetsView = new CodingRulesFacetsView({
- app: _this,
- collection: _this.facets
- });
- return _this.layout.facetsRegion.show(_this.codingRulesFacetsView);
- }
+ return _this.codingRulesListView.selectFirst();
});
};
- App.fetchFirstPage = function(fetchFacets) {
- if (fetchFacets == null) {
- fetchFacets = true;
- }
+ App.fetchFirstPage = function() {
this.pageIndex = 1;
- return App.fetchList(true, fetchFacets);
+ return App.fetchList(true);
};
App.fetchNextPage = function() {
if (this.pageIndex < this.codingRules.paging.pages) {
return this.layout.headerRegion.show(this.codingRulesHeaderView);
});
App.addInitializer(function() {
- this.codingRules = new Backbone.Collection;
- return this.facets = new Backbone.Collection;
+ return this.codingRules = new Backbone.Collection;
});
App.addInitializer(function() {
this.codingRulesActionsView = new CodingRulesActionsView({
resultsRegion: '.navigator-results'
detailsRegion: '.navigator-details'
filtersRegion: '.navigator-filters'
- facetsRegion: '.navigator-facets'
onRender: ->
actionsRegion: '.navigator-actions',
resultsRegion: '.navigator-results',
detailsRegion: '.navigator-details',
- filtersRegion: '.navigator-filters',
- facetsRegion: '.navigator-facets'
+ filtersRegion: '.navigator-filters'
};
AppLayout.prototype.onRender = function() {
paging:
total: 5
fTotal: '5'
- facets: [
- { name: 'Language', options: ['Java', 'JavaScript'] }
- { name: 'Repository', options: ['PMD', 'PMD Unit Tests', 'Checkstyle'] }
- { name: 'Tags', options: ['brain-overload', 'bug', 'comment', 'convention', 'error-handling', 'formatting', 'java8'] }
- ]
paging: {
total: 5,
fTotal: '5'
- },
- facets: [
- {
- name: 'Language',
- options: ['Java', 'JavaScript']
- }, {
- name: 'Repository',
- options: ['PMD', 'PMD Unit Tests', 'Checkstyle']
- }, {
- name: 'Tags',
- options: ['brain-overload', 'bug', 'comment', 'convention', 'error-handling', 'formatting', 'java8']
- }
- ]
+ }
})
});
jQuery.mockjax({
+++ /dev/null
-define [
- 'backbone.marionette',
- 'common/handlebars-extensions'
-], (
- Marionette,
-) ->
-
- class CodingRulesFacetsView extends Marionette.ItemView
- tagName: 'li'
- className: 'navigator-facets-list-item'
- template: getTemplate '#coding-rules-facets-item-template'
+++ /dev/null
-// Generated by CoffeeScript 1.6.3
-(function() {
- var __hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
-
- define(['backbone.marionette', 'common/handlebars-extensions'], function(Marionette) {
- var CodingRulesFacetsView, _ref;
- return CodingRulesFacetsView = (function(_super) {
- __extends(CodingRulesFacetsView, _super);
-
- function CodingRulesFacetsView() {
- _ref = CodingRulesFacetsView.__super__.constructor.apply(this, arguments);
- return _ref;
- }
-
- CodingRulesFacetsView.prototype.tagName = 'li';
-
- CodingRulesFacetsView.prototype.className = 'navigator-facets-list-item';
-
- CodingRulesFacetsView.prototype.template = getTemplate('#coding-rules-facets-item-template');
-
- return CodingRulesFacetsView;
-
- })(Marionette.ItemView);
- });
-
-}).call(this);
+++ /dev/null
-define [
- 'backbone.marionette',
- 'coding-rules/views/coding-rules-facets-item-view'
-], (
- Marionette,
- CodingRulesFacetsItemView
-) ->
-
- class CodingRulesFacetsView extends Marionette.CollectionView
- 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
+++ /dev/null
-// Generated by CoffeeScript 1.6.3
-(function() {
- var __hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
-
- define(['backbone.marionette', 'coding-rules/views/coding-rules-facets-item-view'], function(Marionette, CodingRulesFacetsItemView) {
- var CodingRulesFacetsView, _ref;
- return CodingRulesFacetsView = (function(_super) {
- __extends(CodingRulesFacetsView, _super);
-
- function CodingRulesFacetsView() {
- _ref = CodingRulesFacetsView.__super__.constructor.apply(this, arguments);
- return _ref;
- }
-
- CodingRulesFacetsView.prototype.tagName = 'ul';
-
- CodingRulesFacetsView.prototype.className = 'navigator-facets-list';
-
- 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);
- });
-
-}).call(this);
.coding-rules-page .navigator-results .spinner {
margin: 10px;
}
-.coding-rules-page .navigator-actions,
-.coding-rules-page .navigator-details {
- top: 194px;
-}
-.coding-rules-page .navigator-results {
- top: 224px;
-}
/*
* Detail
*/
margin: @navigatorPadding;
}
- .navigator-actions,
- .navigator-details {
- top: @navigatorTopOffset + @navigatorHeaderHeight + @navigatorFiltersHeight + @navigatorFacetsHeight;
- }
-
- .navigator-results {
- top: @navigatorTopOffset + @navigatorHeaderHeight + @navigatorFiltersHeight + @navigatorFacetsHeight +
- @navigatorStatusHeight;
- }
-
}