diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-03-12 12:53:44 +0600 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-03-12 12:53:44 +0600 |
commit | 260814641dc770baefbe787da616cfff9d16eb87 (patch) | |
tree | 266f4fdf2074524913373274faefb7d3c28f3255 /sonar-server/src/main/webapp/javascripts | |
parent | 296c5b86f39c43513ec111afc728a8b2926309c5 (diff) | |
download | sonarqube-260814641dc770baefbe787da616cfff9d16eb87.tar.gz sonarqube-260814641dc770baefbe787da616cfff9d16eb87.zip |
SONAR-5007 Put criteria in order
Diffstat (limited to 'sonar-server/src/main/webapp/javascripts')
7 files changed, 258 insertions, 106 deletions
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee index ec4caa0b769..20400fb62ed 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee @@ -34,6 +34,7 @@ requirejs [ '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' ], ( @@ -52,7 +53,8 @@ requirejs [ BaseFilters, ChoiceFilters, StringFilterView, - QualityProfileFilterView + QualityProfileFilterView, + InheritanceFilterView ) -> # Create a generic error handler for ajax requests @@ -106,7 +108,6 @@ requirejs [ @storeQuery query, @codingRules.sorting @layout.showSpinner 'resultsRegion' - @layout.showSpinner 'facetsRegion' jQuery.ajax url: "#{baseUrl}/api/codingrules/search" data: fetchQuery @@ -170,25 +171,41 @@ requirejs [ @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' @@ -215,10 +232,7 @@ requirejs [ 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' @@ -226,40 +240,37 @@ requirejs [ 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, @@ -282,6 +293,10 @@ requirejs [ 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 diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/app.js b/sonar-server/src/main/webapp/javascripts/coding-rules/app.js index bb0e902cf2b..88547929dd1 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/app.js +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/app.js @@ -22,7 +22,7 @@ } }); - 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) { @@ -75,7 +75,6 @@ } this.storeQuery(query, this.codingRules.sorting); this.layout.showSpinner('resultsRegion'); - this.layout.showSpinner('facetsRegion'); return jQuery.ajax({ url: "" + baseUrl + "/api/codingrules/search", data: fetchQuery @@ -138,26 +137,41 @@ 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'), @@ -186,11 +200,7 @@ 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'), @@ -198,41 +208,38 @@ 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, @@ -256,6 +263,10 @@ 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(); diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee index 1423e37bdb0..d4b84723bff 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee @@ -12,8 +12,38 @@ define ['jquery.mockjax'], -> { 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' @@ -33,9 +63,14 @@ define ['jquery.mockjax'], -> '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' diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js index ad63ef15be6..0c3bdddef30 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js @@ -18,8 +18,42 @@ 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', @@ -36,9 +70,14 @@ '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', diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/filter-bar-view.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/views/filter-bar-view.coffee index f6b7cf4b745..8b662446a99 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/views/filter-bar-view.coffee +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/filter-bar-view.coffee @@ -44,16 +44,17 @@ define [ 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: -> diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/filter-bar-view.js b/sonar-server/src/main/webapp/javascripts/coding-rules/views/filter-bar-view.js index 475ac88981f..0fda961f1fc 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/views/filter-bar-view.js +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/filter-bar-view.js @@ -54,30 +54,32 @@ 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() { diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/filters/inheritance-filter-view.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/views/filters/inheritance-filter-view.coffee new file mode 100644 index 00000000000..20dbbc9155a --- /dev/null +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/filters/inheritance-filter-view.coffee @@ -0,0 +1,49 @@ +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() |