diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-05-23 11:03:34 +0200 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-05-23 11:08:30 +0200 |
commit | ee745227117605345cfbd379b69ecf564a77cfd9 (patch) | |
tree | d39d0e106c7f6ef22b0a99c30ddb9b44f8709a06 /sonar-server/src/main/coffee | |
parent | 7edc60c990bd81f14c8840b63ce05443e1770a28 (diff) | |
download | sonarqube-ee745227117605345cfbd379b69ecf564a77cfd9.tar.gz sonarqube-ee745227117605345cfbd379b69ecf564a77cfd9.zip |
SONAR-5007 SONAR-5012 Full handling of facets
Diffstat (limited to 'sonar-server/src/main/coffee')
5 files changed, 44 insertions, 19 deletions
diff --git a/sonar-server/src/main/coffee/coding-rules/app.coffee b/sonar-server/src/main/coffee/coding-rules/app.coffee index 848322fbca3..230bdd4e489 100644 --- a/sonar-server/src/main/coffee/coding-rules/app.coffee +++ b/sonar-server/src/main/coffee/coding-rules/app.coffee @@ -166,6 +166,14 @@ requirejs [ + App.facetLabel = (property, value) -> + return value unless App.facetPropertyToLabels[property] + if App.facetPropertyToLabels[property][value] + return App.facetPropertyToLabels[property][value] + else + return _.findWhere(App.facetPropertyToLabels[property], key: value).name + + App.fetchFirstPage = (fromFacets = false) -> @pageIndex = 1 App.fetchList true, fromFacets @@ -257,7 +265,6 @@ requirejs [ name: t 'coding_rules.filters.tag' property: 'tags' type: TagFilterView - choices: @tags @filters.add new BaseFilters.Filter name: t 'coding_rules.filters.characteristic' @@ -352,10 +359,13 @@ requirejs [ App.languages = r.languages App.repositories = r.repositories App.statuses = r.statuses - App.tags = r.tags App.characteristics = r.characteristics window.messages = r.messages + App.facetPropertyToLabels = + 'languages': App.languages + 'repositories': App.repositories + # Remove the initial spinner jQuery('#coding-rules-page-loader').remove() diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-facets-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-facets-view.coffee index a9e16014042..1d66c2ee5a5 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-facets-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-facets-view.coffee @@ -19,6 +19,16 @@ define [ 'click @ui.options': 'selectOption' + initialize: -> + super() + that = @ + @options.collection.each (facet) -> + property = facet.get 'property' + facet.set 'property_message', 'coding_rules.facets.' + property + _.each(facet.get('values'), (value) -> + value.text = that.options.app.facetLabel(property, value.val) + ) + selectOption: (e) -> option = jQuery(e.currentTarget) option.toggleClass 'active' diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-item-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-item-view.coffee index 31648dc10f3..e8a3a82f32c 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-item-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-list-item-view.coffee @@ -27,6 +27,7 @@ define [ url: "#{baseUrl}/api/rules/show" data: key: @model.get('key') + actives: true .done (r) => @model.set r.rule @options.app.codingRulesQualityProfileActivationView.rule = @model diff --git a/sonar-server/src/main/coffee/coding-rules/views/filters/activation-filter-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/filters/activation-filter-view.coffee index 896ee64c050..eb603c6ec06 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/filters/activation-filter-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/filters/activation-filter-view.coffee @@ -34,8 +34,8 @@ define [ makeActive: -> - @choices.each (item) -> item.set 'checked', item.id == 'active' + @choices.each (item) -> item.set 'checked', item.id == 'true' @detailsView.updateValue() @detailsView.updateLists() @render() - super
\ No newline at end of file + super diff --git a/sonar-server/src/main/coffee/coding-rules/views/filters/tag-filter-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/filters/tag-filter-view.coffee index 772c093329b..606d2182fb7 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/filters/tag-filter-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/filters/tag-filter-view.coffee @@ -1,23 +1,27 @@ define [ - 'navigator/filters/ajax-select-filters' + 'navigator/filters/choice-filters' ], ( - AjaxSelectFilters + ChoiceFilters ) -> - class TagSuggestions extends AjaxSelectFilters.Suggestions + class TagFilterView extends ChoiceFilters.ChoiceFilterView - url: -> - "#{baseUrl}/api/rules/tags" + initialize: -> + super() + @loadTags() + # TODO Register an event handler to reload tags when they are modified on a rule - parse: (r) -> - return _.map(r.tags, (tag) -> - new Backbone.Model - id: tag - text: tag - ) - class TagFilterView extends AjaxSelectFilters.AjaxSelectFilterView + loadTags: -> + tagsXHR = jQuery.ajax + url: "#{baseUrl}/api/rules/tags" - initialize: -> - super - @choices = new TagSuggestions + that = @ + jQuery.when(tagsXHR).done (r) -> + that.choices = new Backbone.Collection( + _.map(r.tags, (tag) -> + new Backbone.Model + id: tag + text: tag + )) + that.render() |