aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee')
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee79
1 files changed, 79 insertions, 0 deletions
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
new file mode 100644
index 00000000000..d85a41e3294
--- /dev/null
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
@@ -0,0 +1,79 @@
+define [
+ 'backbone.marionette',
+ 'common/handlebars-extensions'
+], (
+ Marionette
+) ->
+
+ class CodingRulesQualityProfileActivationView extends Marionette.ItemView
+ className: 'modal'
+ template: getTemplate '#coding-rules-quality-profile-activation-template'
+
+
+ ui:
+ qualityProfileSelect: '#coding-rules-quality-profile-activation-select'
+ qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity'
+ qualityProfileActivate: '#coding-rules-quality-profile-activation-activate'
+
+
+ events:
+ 'click #coding-rules-quality-profile-activation-cancel': 'hide'
+ 'click @ui.qualityProfileActivate': 'activate'
+
+
+ activate: ->
+ @$('.modal-foot').html '<i class="spinner"></i>'
+ jQuery.ajax
+ type: 'POST'
+ url: "#{baseUrl}/api/codingrules/activate"
+ data: id: 1
+ .done =>
+ jQuery('.navigator-results-list .active').click()
+ @hide()
+
+
+ onRender: ->
+ @$el.dialog
+ dialogClass: 'no-close',
+ width: '600px',
+ draggable: false,
+ autoOpen: false,
+ modal: true,
+ minHeight: 50,
+ resizable: false,
+ title: null
+
+ @ui.qualityProfileSelect.select2
+ width: '250px'
+ minimumResultsForSearch: 5
+
+ format = (state) ->
+ return state.text unless state.id
+ "<i class='icon-severity-#{state.id.toLowerCase()}'></i> #{state.text}"
+
+ @ui.qualityProfileSeverity.val @model.get 'severity'
+ @ui.qualityProfileSeverity.select2
+ width: '250px'
+ minimumResultsForSearch: 999
+ formatResult: format
+ formatSelection: format
+
+
+ show: ->
+ @render()
+ @$el.dialog 'open'
+
+
+ hide: ->
+ @$el.dialog 'close'
+
+
+ getAvailableQualityProfiles: ->
+ _.reject @options.app.qualityProfiles, (profile) =>
+ _.findWhere @model.get('qualityProfiles'), key: profile.key
+
+
+ serializeData: ->
+ _.extend super,
+ qualityProfiles: @getAvailableQualityProfiles()
+ severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']