1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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']
|