]> source.dussan.org Git - sonarqube.git/blob
54d99424a541236445c3682823390a5b09df1862
[sonarqube.git] /
1 // Generated by CoffeeScript 1.6.3
2 (function() {
3   var __hasProp = {}.hasOwnProperty,
4     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
5
6   define(['backbone.marionette', 'common/handlebars-extensions'], function(Marionette) {
7     var CodingRulesQualityProfileActivationView, _ref;
8     return CodingRulesQualityProfileActivationView = (function(_super) {
9       __extends(CodingRulesQualityProfileActivationView, _super);
10
11       function CodingRulesQualityProfileActivationView() {
12         _ref = CodingRulesQualityProfileActivationView.__super__.constructor.apply(this, arguments);
13         return _ref;
14       }
15
16       CodingRulesQualityProfileActivationView.prototype.className = 'modal';
17
18       CodingRulesQualityProfileActivationView.prototype.template = getTemplate('#coding-rules-quality-profile-activation-template');
19
20       CodingRulesQualityProfileActivationView.prototype.ui = {
21         qualityProfileSelect: '#coding-rules-quality-profile-activation-select',
22         qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity',
23         qualityProfileActivate: '#coding-rules-quality-profile-activation-activate'
24       };
25
26       CodingRulesQualityProfileActivationView.prototype.events = {
27         'click #coding-rules-quality-profile-activation-cancel': 'hide',
28         'click @ui.qualityProfileActivate': 'activate'
29       };
30
31       CodingRulesQualityProfileActivationView.prototype.activate = function() {
32         var _this = this;
33         this.$('.modal-foot').html('<i class="spinner"></i>');
34         return jQuery.ajax({
35           type: 'POST',
36           url: "" + baseUrl + "/api/codingrules/activate",
37           data: {
38             id: 1
39           }
40         }).done(function() {
41           jQuery('.navigator-results-list .active').click();
42           return _this.hide();
43         });
44       };
45
46       CodingRulesQualityProfileActivationView.prototype.onRender = function() {
47         var format;
48         this.$el.dialog({
49           dialogClass: 'no-close',
50           width: '600px',
51           draggable: false,
52           autoOpen: false,
53           modal: true,
54           minHeight: 50,
55           resizable: false,
56           title: null
57         });
58         this.ui.qualityProfileSelect.select2({
59           width: '250px',
60           minimumResultsForSearch: 5
61         });
62         format = function(state) {
63           if (!state.id) {
64             return state.text;
65           }
66           return "<i class='icon-severity-" + (state.id.toLowerCase()) + "'></i> " + state.text;
67         };
68         this.ui.qualityProfileSeverity.val(this.model.get('severity'));
69         return this.ui.qualityProfileSeverity.select2({
70           width: '250px',
71           minimumResultsForSearch: 999,
72           formatResult: format,
73           formatSelection: format
74         });
75       };
76
77       CodingRulesQualityProfileActivationView.prototype.show = function() {
78         this.render();
79         return this.$el.dialog('open');
80       };
81
82       CodingRulesQualityProfileActivationView.prototype.hide = function() {
83         return this.$el.dialog('close');
84       };
85
86       CodingRulesQualityProfileActivationView.prototype.getAvailableQualityProfiles = function() {
87         var _this = this;
88         return _.reject(this.options.app.qualityProfiles, function(profile) {
89           return _.findWhere(_this.model.get('qualityProfiles'), {
90             key: profile.key
91           });
92         });
93       };
94
95       CodingRulesQualityProfileActivationView.prototype.serializeData = function() {
96         return _.extend(CodingRulesQualityProfileActivationView.__super__.serializeData.apply(this, arguments), {
97           qualityProfiles: this.getAvailableQualityProfiles(),
98           severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']
99         });
100       };
101
102       return CodingRulesQualityProfileActivationView;
103
104     })(Marionette.ItemView);
105   });
106
107 }).call(this);