'navigator/filters/choice-filters',
'navigator/filters/string-filters',
'coding-rules/views/filters/quality-profile-filter-view',
+ 'coding-rules/views/filters/inheritance-filter-view',
'coding-rules/mockjax'
], (
BaseFilters,
ChoiceFilters,
StringFilterView,
- QualityProfileFilterView
+ QualityProfileFilterView,
+ InheritanceFilterView
) ->
# Create a generic error handler for ajax requests
@storeQuery query, @codingRules.sorting
@layout.showSpinner 'resultsRegion'
- @layout.showSpinner 'facetsRegion'
jQuery.ajax
url: "#{baseUrl}/api/codingrules/search"
data: fetchQuery
@filters = new BaseFilters.Filters
@filters.add new BaseFilters.Filter
- name: t 'coding_rules.filters.name_key'
- property: 'searchtext'
+ name: t 'coding_rules.filters.name'
+ property: 'name'
type: StringFilterView
enabled: true
optional: false
+ @filters.add new BaseFilters.Filter
+ name: t 'coding_rules.filters.key'
+ property: 'key'
+ type: StringFilterView
+ enabled: true
+ optional: false
+
+ @filters.add new BaseFilters.Filter
+ name: t 'coding_rules.filters.description'
+ property: 'description'
+ type: StringFilterView
+ enabled: true
+ optional: false
+
+ @filters.add new BaseFilters.Filter
+ name: t 'coding_rules.filters.language'
+ property: 'languages'
+ type: ChoiceFilters.ChoiceFilterView
+ enabled: true
+ optional: false
+ choices: @languages
+
@filters.add new BaseFilters.Filter
name: t 'coding_rules.filters.repository'
property: 'repositories'
type: ChoiceFilters.ChoiceFilterView
enabled: true
optional: false
- choices:
- 'checkstyle': 'Checkstyle'
- 'common-java': 'Common SonarQube'
- 'findbugs': 'FindBugs'
- 'pmd': 'PMD'
- 'pmd-unit-tests': 'PMD Unit Tests'
- 'squid': 'SonarQube'
+ choices: @repositories
@filters.add new BaseFilters.Filter
name: t 'coding_rules.filters.severity'
type: ChoiceFilters.ChoiceFilterView
enabled: true
optional: false
- choices:
- 'BETA': 'Beta'
- 'DEPRECATED': 'Deprecated'
- 'READY': 'Ready'
+ choices: @statuses
@filters.add new BaseFilters.Filter
name: t 'coding_rules.filters.tag'
type: ChoiceFilters.ChoiceFilterView
enabled: true
optional: false
- choices:
- 'brain-overload': 'brain-overload'
- 'bug': 'bug'
- 'comment': 'comment'
- 'convention': 'convention'
- 'error-handling': 'error-handling'
- 'formatting': 'formatting'
- 'java8': 'java8'
- 'multithreading': 'multithreading'
- 'naming': 'naming'
- 'pitfall': 'pitfall'
- 'security': 'security'
- 'size': 'size'
- 'unused': 'unused'
- 'unused-code': 'unused-code'
+ choices: @tags
@activeInFilter = new BaseFilters.Filter
- name: t 'coding_rules.filters.active_in'
- property: 'active_in'
+ name: t 'coding_rules.filters.in_quality_profile'
+ property: 'in_quality_profile'
type: QualityProfileFilterView
- single: true
+ multiple: false
enabled: true
optional: false
@filters.add @activeInFilter
@inactiveInFilter = new BaseFilters.Filter
- name: t 'coding_rules.filters.inactive_in'
- property: 'inactive_in'
+ name: t 'coding_rules.filters.out_of_quality_profile'
+ property: 'out_of_quality_profile'
type: QualityProfileFilterView
- single: true
+ multiple: false
enabled: true
optional: false
@filters.add @inactiveInFilter
+ @filters.add new BaseFilters.Filter
+ name: t 'coding_rules.filters.inheritance'
+ property: 'inheritance'
+ type: InheritanceFilterView
+ enabled: true
+ optional: false
+ qualityProfileFilter: @activeInFilter
+ choices:
+ 'option1': 'Option 1'
+ 'option2': 'Option 2'
+
@filterBarView = new CodingRulesFilterBarView
app: @
collection: @filters,
App.appState = new Backbone.Model
App.state = new Backbone.Model
App.qualityProfiles = r.qualityprofiles
+ App.languages = r.languages
+ App.repositories = r.repositories
+ App.statuses = r.statuses
+ App.tags = r.tags
window.messages = r.messages
# Remove the initial spinner
}
});
- 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) {
+ 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/views/filters/inheritance-filter-view', 'coding-rules/mockjax'], function(Backbone, Marionette, CodingRulesLayout, CodingRulesRouter, CodingRulesHeaderView, CodingRulesActionsView, CodingRulesFilterBarView, CodingRulesListView, BaseFilters, ChoiceFilters, StringFilterView, QualityProfileFilterView, InheritanceFilterView) {
var App, appXHR;
jQuery.ajaxSetup({
error: function(jqXHR) {
}
this.storeQuery(query, this.codingRules.sorting);
this.layout.showSpinner('resultsRegion');
- this.layout.showSpinner('facetsRegion');
return jQuery.ajax({
url: "" + baseUrl + "/api/codingrules/search",
data: fetchQuery
App.addInitializer(function() {
this.filters = new BaseFilters.Filters;
this.filters.add(new BaseFilters.Filter({
- name: t('coding_rules.filters.name_key'),
- property: 'searchtext',
+ name: t('coding_rules.filters.name'),
+ property: 'name',
type: StringFilterView,
enabled: true,
optional: false
}));
+ this.filters.add(new BaseFilters.Filter({
+ name: t('coding_rules.filters.key'),
+ property: 'key',
+ type: StringFilterView,
+ enabled: true,
+ optional: false
+ }));
+ this.filters.add(new BaseFilters.Filter({
+ name: t('coding_rules.filters.description'),
+ property: 'description',
+ type: StringFilterView,
+ enabled: true,
+ optional: false
+ }));
+ this.filters.add(new BaseFilters.Filter({
+ name: t('coding_rules.filters.language'),
+ property: 'languages',
+ type: ChoiceFilters.ChoiceFilterView,
+ enabled: true,
+ optional: false,
+ choices: this.languages
+ }));
this.filters.add(new BaseFilters.Filter({
name: t('coding_rules.filters.repository'),
property: 'repositories',
type: ChoiceFilters.ChoiceFilterView,
enabled: true,
optional: false,
- choices: {
- 'checkstyle': 'Checkstyle',
- 'common-java': 'Common SonarQube',
- 'findbugs': 'FindBugs',
- 'pmd': 'PMD',
- 'pmd-unit-tests': 'PMD Unit Tests',
- 'squid': 'SonarQube'
- }
+ choices: this.repositories
}));
this.filters.add(new BaseFilters.Filter({
name: t('coding_rules.filters.severity'),
type: ChoiceFilters.ChoiceFilterView,
enabled: true,
optional: false,
- choices: {
- 'BETA': 'Beta',
- 'DEPRECATED': 'Deprecated',
- 'READY': 'Ready'
- }
+ choices: this.statuses
}));
this.filters.add(new BaseFilters.Filter({
name: t('coding_rules.filters.tag'),
type: ChoiceFilters.ChoiceFilterView,
enabled: true,
optional: false,
- choices: {
- 'brain-overload': 'brain-overload',
- 'bug': 'bug',
- 'comment': 'comment',
- 'convention': 'convention',
- 'error-handling': 'error-handling',
- 'formatting': 'formatting',
- 'java8': 'java8',
- 'multithreading': 'multithreading',
- 'naming': 'naming',
- 'pitfall': 'pitfall',
- 'security': 'security',
- 'size': 'size',
- 'unused': 'unused',
- 'unused-code': 'unused-code'
- }
+ choices: this.tags
}));
this.activeInFilter = new BaseFilters.Filter({
- name: t('coding_rules.filters.active_in'),
- property: 'active_in',
+ name: t('coding_rules.filters.in_quality_profile'),
+ property: 'in_quality_profile',
type: QualityProfileFilterView,
- single: true,
+ multiple: false,
enabled: true,
optional: false
});
this.filters.add(this.activeInFilter);
this.inactiveInFilter = new BaseFilters.Filter({
- name: t('coding_rules.filters.inactive_in'),
- property: 'inactive_in',
+ name: t('coding_rules.filters.out_of_quality_profile'),
+ property: 'out_of_quality_profile',
type: QualityProfileFilterView,
- single: true,
+ multiple: false,
enabled: true,
optional: false
});
this.filters.add(this.inactiveInFilter);
+ this.filters.add(new BaseFilters.Filter({
+ name: t('coding_rules.filters.inheritance'),
+ property: 'inheritance',
+ type: InheritanceFilterView,
+ enabled: true,
+ optional: false,
+ qualityProfileFilter: this.activeInFilter,
+ choices: {
+ 'option1': 'Option 1',
+ 'option2': 'Option 2'
+ }
+ }));
this.filterBarView = new CodingRulesFilterBarView({
app: this,
collection: this.filters,
App.appState = new Backbone.Model;
App.state = new Backbone.Model;
App.qualityProfiles = r.qualityprofiles;
+ App.languages = r.languages;
+ App.repositories = r.repositories;
+ App.statuses = r.statuses;
+ App.tags = r.tags;
window.messages = r.messages;
jQuery('#coding-rules-page-loader').remove();
return App.start();
{ name: 'Sonar Way', lang: 'JavaScript' }
{ name: 'Quality Profile 1', lang: 'Java' }
]
+ languages:
+ java: 'Java'
+ javascript: 'JavaScript'
+ repositories:
+ 'checkstyle': 'Checkstyle'
+ 'common-java': 'Common SonarQube'
+ 'findbugs': 'FindBugs'
+ 'pmd': 'PMD'
+ 'pmd-unit-tests': 'PMD Unit Tests'
+ 'squid': 'SonarQube'
+ statuses:
+ 'BETA': 'Beta'
+ 'DEPRECATED': 'Deprecated'
+ 'READY': 'Ready'
+ tags:
+ 'brain-overload': 'brain-overload'
+ 'bug': 'bug'
+ 'comment': 'comment'
+ 'convention': 'convention'
+ 'error-handling': 'error-handling'
+ 'formatting': 'formatting'
+ 'java8': 'java8'
+ 'multithreading': 'multithreading'
+ 'naming': 'naming'
+ 'pitfall': 'pitfall'
+ 'security': 'security'
+ 'size': 'size'
+ 'unused': 'unused'
+ 'unused-code': 'unused-code'
messages:
'all': 'All'
+ 'any': 'Any'
'bulk_change': 'Bulk Change'
'moreCriteria': '+ More Criteria'
'search_verb': 'Search'
'coding_rules.activate_quality_profile': 'Activate Quality Profile'
'coding_rules.deactivate_quality_profile': 'Deactivate'
- 'coding_rules.filters.active_in': 'Active In'
- 'coding_rules.filters.inactive_in': 'Inactive In'
- 'coding_rules.filters.name_key': 'Name/Key'
+ 'coding_rules.filters.description': 'Description'
+ 'coding_rules.filters.in_quality_profile': 'In Quality Profile'
+ 'coding_rules.filters.inheritance': 'Inheritance'
+ 'coding_rules.filters.inheritance.inactive': 'Inheritance criteria is available when a quality profile is selected'
+ 'coding_rules.filters.key': 'Key'
+ 'coding_rules.filters.language': 'Language'
+ 'coding_rules.filters.name': 'Name'
+ 'coding_rules.filters.out_of_quality_profile': 'Out of Quality Profile'
'coding_rules.filters.repository': 'Repository'
'coding_rules.filters.severity': 'Severity'
'coding_rules.filters.status': 'Status'
lang: 'Java'
}
],
+ languages: {
+ java: 'Java',
+ javascript: 'JavaScript'
+ },
+ repositories: {
+ 'checkstyle': 'Checkstyle',
+ 'common-java': 'Common SonarQube',
+ 'findbugs': 'FindBugs',
+ 'pmd': 'PMD',
+ 'pmd-unit-tests': 'PMD Unit Tests',
+ 'squid': 'SonarQube'
+ },
+ statuses: {
+ 'BETA': 'Beta',
+ 'DEPRECATED': 'Deprecated',
+ 'READY': 'Ready'
+ },
+ tags: {
+ 'brain-overload': 'brain-overload',
+ 'bug': 'bug',
+ 'comment': 'comment',
+ 'convention': 'convention',
+ 'error-handling': 'error-handling',
+ 'formatting': 'formatting',
+ 'java8': 'java8',
+ 'multithreading': 'multithreading',
+ 'naming': 'naming',
+ 'pitfall': 'pitfall',
+ 'security': 'security',
+ 'size': 'size',
+ 'unused': 'unused',
+ 'unused-code': 'unused-code'
+ },
messages: {
'all': 'All',
+ 'any': 'Any',
'bulk_change': 'Bulk Change',
'moreCriteria': '+ More Criteria',
'search_verb': 'Search',
'coding_rules.quality_profiles': 'Quality Profiles',
'coding_rules.activate_quality_profile': 'Activate Quality Profile',
'coding_rules.deactivate_quality_profile': 'Deactivate',
- 'coding_rules.filters.active_in': 'Active In',
- 'coding_rules.filters.inactive_in': 'Inactive In',
- 'coding_rules.filters.name_key': 'Name/Key',
+ 'coding_rules.filters.description': 'Description',
+ 'coding_rules.filters.in_quality_profile': 'In Quality Profile',
+ 'coding_rules.filters.inheritance': 'Inheritance',
+ 'coding_rules.filters.inheritance.inactive': 'Inheritance criteria is available when a quality profile is selected',
+ 'coding_rules.filters.key': 'Key',
+ 'coding_rules.filters.language': 'Language',
+ 'coding_rules.filters.name': 'Name',
+ 'coding_rules.filters.out_of_quality_profile': 'Out of Quality Profile',
'coding_rules.filters.repository': 'Repository',
'coding_rules.filters.severity': 'Severity',
'coding_rules.filters.status': 'Status',
changeEnabled: ->
- disabledFilters = _.reject @collection.where(enabled: false), (filter) ->
- filter.get('type') == MoreCriteriaFilters.MoreCriteriaFilterView
+ if @moreCriteriaFilter?
+ disabledFilters = _.reject @collection.where(enabled: false), (filter) ->
+ filter.get('type') == MoreCriteriaFilters.MoreCriteriaFilterView
- if disabledFilters.length == 0
- @moreCriteriaFilter.set { enabled: false }, { silent: true }
- else
- @moreCriteriaFilter.set { enabled: true }, { silent: true }
+ if disabledFilters.length == 0
+ @moreCriteriaFilter.set { enabled: false }, { silent: true }
+ else
+ @moreCriteriaFilter.set { enabled: true }, { silent: true }
- @moreCriteriaFilter.set { filters: disabledFilters }, { silent: true }
- @moreCriteriaFilter.trigger 'change:filters'
+ @moreCriteriaFilter.set { filters: disabledFilters }, { silent: true }
+ @moreCriteriaFilter.trigger 'change:filters'
search: ->
CodingRulesFilterBarView.prototype.changeEnabled = function() {
var disabledFilters;
- disabledFilters = _.reject(this.collection.where({
- enabled: false
- }), function(filter) {
- return filter.get('type') === MoreCriteriaFilters.MoreCriteriaFilterView;
- });
- if (disabledFilters.length === 0) {
- this.moreCriteriaFilter.set({
+ if (this.moreCriteriaFilter != null) {
+ disabledFilters = _.reject(this.collection.where({
enabled: false
- }, {
- silent: true
+ }), function(filter) {
+ return filter.get('type') === MoreCriteriaFilters.MoreCriteriaFilterView;
});
- } else {
+ if (disabledFilters.length === 0) {
+ this.moreCriteriaFilter.set({
+ enabled: false
+ }, {
+ silent: true
+ });
+ } else {
+ this.moreCriteriaFilter.set({
+ enabled: true
+ }, {
+ silent: true
+ });
+ }
this.moreCriteriaFilter.set({
- enabled: true
+ filters: disabledFilters
}, {
silent: true
});
+ return this.moreCriteriaFilter.trigger('change:filters');
}
- this.moreCriteriaFilter.set({
- filters: disabledFilters
- }, {
- silent: true
- });
- return this.moreCriteriaFilter.trigger('change:filters');
};
CodingRulesFilterBarView.prototype.search = function() {
--- /dev/null
+define [
+ 'navigator/filters/choice-filters'
+], (
+ ChoiceFilters
+) ->
+
+ class InheritanceFilterView extends ChoiceFilters.ChoiceFilterView
+
+ initialize: ->
+ super
+ @qualityProfileFilter = @model.get 'qualityProfileFilter'
+ @listenTo @qualityProfileFilter, 'change:value', @onChangeQualityProfile
+ @onChangeQualityProfile()
+
+
+ onChangeQualityProfile: ->
+ qualityProfile = @qualityProfileFilter.get 'value'
+ if _.isArray(qualityProfile) && qualityProfile.length == 1
+ @makeActive()
+ else
+ @makeInactive()
+
+
+ makeActive: ->
+ @model.set inactive: false, title: ''
+ @model.trigger 'change:enabled'
+ @$el.removeClass('navigator-filter-inactive').prop 'title', ''
+
+
+ makeInactive: ->
+ @model.set inactive: true, title: t 'coding_rules.filters.inheritance.inactive'
+ @model.trigger 'change:enabled'
+ @choices.each (model) -> model.set 'checked', false
+ @detailsView.updateLists()
+ @detailsView.updateValue()
+ @$el.addClass('navigator-filter-inactive').prop 'title', t 'coding_rules.filters.inheritance.inactive'
+
+
+ showDetails: ->
+ super unless @$el.is '.navigator-filter-inactive'
+
+
+ restore: (value) ->
+ value = value.split(',') if _.isString(value)
+ if @choices && value.length > 0
+ @model.set value: value, enabled: true
+ @onChangeQualityProfile
+ else
+ @clear()