From b61fbdcc459d3689d24beb618c962e727d276261 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 24 Mar 2014 19:25:10 +0600 Subject: [PATCH] SONAR-5007 Improve QP filter --- .../webapp/coffee/coding-rules/app.coffee | 2 +- ...g-rules-detail-quality-profile-view.coffee | 73 +------------------ .../filters/activation-filter-view.coffee | 30 +++++++- .../quality-profile-filter-view.coffee | 12 ++- .../src/main/webapp/less/coding-rules.less | 7 +- .../main/webapp/less/navigator/filters.less | 5 ++ .../src/main/webapp/less/variables.less | 3 +- .../coding-rules-detail-quality-profile.hbs | 2 +- .../coding-rules/coding-rules-detail.hbs | 8 +- 9 files changed, 63 insertions(+), 79 deletions(-) diff --git a/sonar-server/src/main/webapp/coffee/coding-rules/app.coffee b/sonar-server/src/main/webapp/coffee/coding-rules/app.coffee index 4a05d84b735..b5029b0f577 100644 --- a/sonar-server/src/main/webapp/coffee/coding-rules/app.coffee +++ b/sonar-server/src/main/webapp/coffee/coding-rules/app.coffee @@ -249,7 +249,7 @@ requirejs [ property: 'activation' type: ActivationFilterView enabled: false - optional: true + optional: false multiple: false qualityProfileFilter: @qualityProfileFilter choices: diff --git a/sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee b/sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee index 53709d9de95..2f3ec432cd4 100644 --- a/sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee +++ b/sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee @@ -12,81 +12,13 @@ define [ ui: - update: '.coding-rules-detail-quality-profile-update' - severitySelect: '.coding-rules-detail-quality-profile-severity' - - note: '.coding-rules-detail-quality-profile-note' - noteForm: '.coding-rules-detail-quality-profile-note-form' - noteText: '.coding-rules-detail-quality-profile-note-text' - noteAdd: '.coding-rules-detail-quality-profile-note-add' - noteEdit: '.coding-rules-detail-quality-profile-note-edit' - noteDelete: '.coding-rules-detail-quality-profile-note-delete' - noteCancel: '.coding-rules-detail-quality-profile-note-cancel' - noteSubmit: '.coding-rules-detail-quality-profile-note-submit' - - - events: - 'click @ui.noteAdd': 'editNote' - 'click @ui.noteEdit': 'editNote' - 'click @ui.noteDelete': 'deleteNote' - 'click @ui.noteCancel': 'cancelNote' - 'click @ui.noteSubmit': 'submitNote' - - 'change .coding-rules-detail-parameters select': 'enableUpdate' - 'keyup .coding-rules-detail-parameters input': 'enableUpdate' - - - editNote: -> - @ui.note.hide() - @ui.noteForm.show() - @ui.noteText.focus() - - - deleteNote: -> - @ui.noteText.val '' - @submitNote().done => - @model.unset 'note' - @render() - - - cancelNote: -> - @ui.note.show() - @ui.noteForm.hide() - - - submitNote: -> - @ui.note.html '' - @ui.noteForm.html '' - jQuery.ajax - type: 'POST' - url: "#{baseUrl}/api/codingrules/note" - dataType: 'json' - data: text: @ui.noteText.val() - .done (r) => - @model.set 'note', r.note - @render() + change: '.coding-rules-detail-quality-profile-change' enableUpdate: -> @ui.update.prop 'disabled', false - onRender: -> - @ui.noteForm.hide() - - format = (state) -> - return state.text unless state.id - " #{state.text}" - - @ui.severitySelect.val @model.get 'severity' -# @ui.severitySelect.select2 -# width: '200px' -# minimumResultsForSearch: 999 -# formatResult: format -# formatSelection: format -# escapeMarkup: (m) -> m - - getParent: -> return null unless @model.get 'inherits' @options.qualityProfiles.findWhere(key: @model.get('inherits')).toJSON() @@ -103,5 +35,4 @@ define [ serializeData: -> _.extend super, parent: @getParent() - parameters: @enhanceParameters() - severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'] \ No newline at end of file + parameters: @enhanceParameters() \ No newline at end of file diff --git a/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/activation-filter-view.coffee b/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/activation-filter-view.coffee index 8a4a11d831e..896ee64c050 100644 --- a/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/activation-filter-view.coffee +++ b/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/activation-filter-view.coffee @@ -1,13 +1,41 @@ define [ + 'navigator/filters/choice-filters' 'coding-rules/views/filters/inheritance-filter-view' ], ( + ChoiceFilters InheritanceFilterView ) -> + class DetailsActivationFilterView extends ChoiceFilters.DetailsChoiceFilterView + + onCheck: (e) -> + id = jQuery(e.target).val() + selected = @options.filterView.choices.findWhere checked: true + unless id == selected + @options.filterView.choices.each (item) -> item.set 'checked', item.id == id + else + e.preventDefault() + @updateValue() + @updateLists() + + + class ActivationFilterView extends InheritanceFilterView tooltip: 'coding_rules.filters.activation.help' + initialize: -> + super detailsView: DetailsActivationFilterView + + onChangeQualityProfile: -> qualityProfile = @qualityProfileFilter.get 'value' - if _.isArray(qualityProfile) && qualityProfile.length == 1 then @makeActive() else @makeInactive() \ No newline at end of file + if _.isArray(qualityProfile) && qualityProfile.length == 1 then @makeActive() else @makeInactive() + + + makeActive: -> + @choices.each (item) -> item.set 'checked', item.id == 'active' + @detailsView.updateValue() + @detailsView.updateLists() + @render() + super \ No newline at end of file diff --git a/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee b/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee index ab1c4bd0c93..eff55a9e618 100644 --- a/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee +++ b/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee @@ -16,7 +16,12 @@ define [ initialize: -> super @choices = new QualityProfileSuggestions - @listenTo @model, 'change:value', @updateParentQualityProfile + @listenTo @model, 'change:value', @onValueChange + + + onValueChange: -> + @updateParentQualityProfile() + @highlightContext() updateParentQualityProfile: -> @@ -27,6 +32,11 @@ define [ @model.unset 'parentQualityProfile' + highlightContext: -> + hasContext = _.isArray(@model.get('value')) && @model.get('value').length > 0 + @$el.toggleClass 'navigator-filter-context', hasContext + + createRequest: (v) -> jQuery.ajax url: baseUrl + '/api/qualityprofiles/show' diff --git a/sonar-server/src/main/webapp/less/coding-rules.less b/sonar-server/src/main/webapp/less/coding-rules.less index c5971b0e664..fb84e4f3781 100644 --- a/sonar-server/src/main/webapp/less/coding-rules.less +++ b/sonar-server/src/main/webapp/less/coding-rules.less @@ -36,6 +36,9 @@ .coding-rules-detail-context-actions { margin-bottom: @navigatorPadding; + padding: @navigatorPadding / 2; + background-color: @contextBackground; + border: 1px solid @contextBorder; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; @@ -53,6 +56,8 @@ margin-right: @navigatorPadding; .limited { + display: inline-block; + vertical-align: middle; max-width: 180px; white-space: nowrap; overflow: hidden; @@ -60,7 +65,7 @@ } .limited-big { - width: 480px; + max-width: 480px; } } diff --git a/sonar-server/src/main/webapp/less/navigator/filters.less b/sonar-server/src/main/webapp/less/navigator/filters.less index dc9868f1f97..fbfdf0e3b13 100644 --- a/sonar-server/src/main/webapp/less/navigator/filters.less +++ b/sonar-server/src/main/webapp/less/navigator/filters.less @@ -87,6 +87,11 @@ opacity: 0.5; } +.navigator-filter-context { + background-color: @contextBackground; + border-color: @contextBorder; +} + .navigator-filter-label { display: inline-block; vertical-align: middle; diff --git a/sonar-server/src/main/webapp/less/variables.less b/sonar-server/src/main/webapp/less/variables.less index b43675bf36c..ab56248686b 100644 --- a/sonar-server/src/main/webapp/less/variables.less +++ b/sonar-server/src/main/webapp/less/variables.less @@ -25,7 +25,8 @@ @orange: #f90; @highlighted: @blue; - +@contextBackground: lighten(@green, 40%); +@contextBorder: lighten(@green, 20%); /* diff --git a/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs b/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs index b3962380591..b1633fcfaa5 100644 --- a/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs +++ b/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs @@ -32,7 +32,7 @@
- + {{#if parent}}