diff options
Diffstat (limited to 'sonar-server/src/main/coffee/coding-rules/views/actions-view.coffee')
-rw-r--r-- | sonar-server/src/main/coffee/coding-rules/views/actions-view.coffee | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/sonar-server/src/main/coffee/coding-rules/views/actions-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/actions-view.coffee new file mode 100644 index 00000000000..96e306ed8e8 --- /dev/null +++ b/sonar-server/src/main/coffee/coding-rules/views/actions-view.coffee @@ -0,0 +1,62 @@ +define [ + 'backbone.marionette' + 'templates/coding-rules' +], ( + Marionette + Templates +) -> + + class CodingRulesStatusView extends Marionette.ItemView + template: Templates['coding-rules-actions'] + + + collectionEvents: + 'all': 'render' + + + ui: + orderChoices: '.navigator-actions-order-choices' + bulkChange: '.navigator-actions-bulk' + + + events: + 'click .navigator-actions-order': 'toggleOrderChoices' + 'click @ui.orderChoices': 'sort' + 'click @ui.bulkChange': 'bulkChange' + + + onRender: -> + unless @collection.sorting.sortText + @collection.sorting.sortText = @$('[data-sort=' + @collection.sorting.sort + ']:first').text() + @render() + + + toggleOrderChoices: (e) -> + e.stopPropagation() + @ui.orderChoices.toggleClass 'open' + if @ui.orderChoices.is '.open' + jQuery('body').on 'click.coding_rules_actions', => + @ui.orderChoices.removeClass 'open' + + + sort: (e) -> + e.stopPropagation() + @ui.orderChoices.removeClass 'open' + jQuery('body').off 'click.coding_rules_actions' + el = jQuery(e.target) + sort = el.data 'sort' + asc = el.data 'asc' + if sort != null && asc != null + @collection.sorting = sort: sort, sortText: el.text(), asc: asc + @options.app.fetchFirstPage() + + + bulkChange: (e) -> + e.stopPropagation() + @options.app.codingRulesBulkChangeDropdownView.toggle() + + + serializeData: -> + _.extend super, + paging: @collection.paging + sorting: @collection.sorting |