diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-17 16:15:28 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-18 10:47:27 +0200 |
commit | 890ab0b59cdb3902f4869eabf8ca534814f1b3dd (patch) | |
tree | 0ed74726957e590f6506e378366ea15bf21bfcbd /server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js | |
parent | ce60ac8d2e137f33bb111668e54e78c195c73d79 (diff) | |
download | sonarqube-890ab0b59cdb3902f4869eabf8ca534814f1b3dd.tar.gz sonarqube-890ab0b59cdb3902f4869eabf8ca534814f1b3dd.zip |
migrate js apps to es2015 modules
Diffstat (limited to 'server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js')
-rw-r--r-- | server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js | 250 |
1 files changed, 126 insertions, 124 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js index 7e025519094..40e09aed4a4 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js @@ -1,138 +1,140 @@ -define([ - './profile-activation-view', - '../templates' -], function (ProfileActivationView) { +import $ from 'jquery'; +import _ from 'underscore'; +import Backbone from 'backbone'; +import Marionette from 'backbone.marionette'; +import ProfileActivationView from './profile-activation-view'; +import '../templates'; - return Marionette.ItemView.extend({ - tagName: 'tr', - template: Templates['coding-rules-rule-profile'], +export default Marionette.ItemView.extend({ + tagName: 'tr', + template: Templates['coding-rules-rule-profile'], - modelEvents: { - 'change': 'render' - }, + modelEvents: { + 'change': 'render' + }, - ui: { - change: '.coding-rules-detail-quality-profile-change', - revert: '.coding-rules-detail-quality-profile-revert', - deactivate: '.coding-rules-detail-quality-profile-deactivate' - }, + ui: { + change: '.coding-rules-detail-quality-profile-change', + revert: '.coding-rules-detail-quality-profile-revert', + deactivate: '.coding-rules-detail-quality-profile-deactivate' + }, - events: { - 'click @ui.change': 'change', - 'click @ui.revert': 'revert', - 'click @ui.deactivate': 'deactivate' - }, + events: { + 'click @ui.change': 'change', + 'click @ui.revert': 'revert', + 'click @ui.deactivate': 'deactivate' + }, - onRender: function () { - this.$('[data-toggle="tooltip"]').tooltip({ - container: 'body' - }); - }, + onRender: function () { + this.$('[data-toggle="tooltip"]').tooltip({ + container: 'body' + }); + }, - change: function () { - var that = this, - activationView = new ProfileActivationView({ - model: this.model, - collection: this.model.collection, - rule: this.options.rule, - app: this.options.app - }); - activationView.on('profileActivated', function () { - that.options.refreshActives(); - }); - activationView.render(); - }, + change: function () { + var that = this, + activationView = new ProfileActivationView({ + model: this.model, + collection: this.model.collection, + rule: this.options.rule, + app: this.options.app + }); + activationView.on('profileActivated', function () { + that.options.refreshActives(); + }); + activationView.render(); + }, - revert: function () { - var that = this, - ruleKey = this.options.rule.get('key'); - window.confirmDialog({ - title: t('coding_rules.revert_to_parent_definition'), - html: tp('coding_rules.revert_to_parent_definition.confirm', this.getParent().name), - yesHandler: function () { - return jQuery.ajax({ - type: 'POST', - url: baseUrl + '/api/qualityprofiles/activate_rule', - data: { - profile_key: that.model.get('qProfile'), - rule_key: ruleKey, - reset: true - } - }).done(function () { - that.options.refreshActives(); - }); - } - }); - }, - - deactivate: function () { - var that = this, - ruleKey = this.options.rule.get('key'); - window.confirmDialog({ - title: t('coding_rules.deactivate'), - html: tp('coding_rules.deactivate.confirm'), - yesHandler: function () { - return jQuery.ajax({ - type: 'POST', - url: baseUrl + '/api/qualityprofiles/deactivate_rule', - data: { - profile_key: that.model.get('qProfile'), - rule_key: ruleKey - } - }).done(function () { - that.options.refreshActives(); - }); - } - }); - }, - - enableUpdate: function () { - return this.ui.update.prop('disabled', false); - }, - - getParent: function () { - if (!(this.model.get('inherit') && this.model.get('inherit') !== 'NONE')) { - return null; + revert: function () { + var that = this, + ruleKey = this.options.rule.get('key'); + window.confirmDialog({ + title: t('coding_rules.revert_to_parent_definition'), + html: tp('coding_rules.revert_to_parent_definition.confirm', this.getParent().name), + yesHandler: function () { + return $.ajax({ + type: 'POST', + url: baseUrl + '/api/qualityprofiles/activate_rule', + data: { + profile_key: that.model.get('qProfile'), + rule_key: ruleKey, + reset: true + } + }).done(function () { + that.options.refreshActives(); + }); } - var myProfile = _.findWhere(this.options.app.qualityProfiles, { - key: this.model.get('qProfile') - }), - parentKey = myProfile.parentKey, - parent = _.extend({}, _.findWhere(this.options.app.qualityProfiles, { - key: parentKey - })), - parentActiveInfo = this.model.collection.findWhere({ qProfile: parentKey }) || new Backbone.Model(); - _.extend(parent, parentActiveInfo.toJSON()); - return parent; - }, + }); + }, - enhanceParameters: function () { - var parent = this.getParent(), - params = _.sortBy(this.model.get('params'), 'key'); - if (!parent) { - return params; + deactivate: function () { + var that = this, + ruleKey = this.options.rule.get('key'); + window.confirmDialog({ + title: t('coding_rules.deactivate'), + html: tp('coding_rules.deactivate.confirm'), + yesHandler: function () { + return $.ajax({ + type: 'POST', + url: baseUrl + '/api/qualityprofiles/deactivate_rule', + data: { + profile_key: that.model.get('qProfile'), + rule_key: ruleKey + } + }).done(function () { + that.options.refreshActives(); + }); } - return params.map(function (p) { - var parentParam = _.findWhere(parent.params, { key: p.key }); - if (parentParam != null) { - return _.extend(p, { - original: _.findWhere(parent.params, { key: p.key }).value - }); - } else { - return p; - } - }); - }, + }); + }, - serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { - canWrite: this.options.app.canWrite, - parent: this.getParent(), - parameters: this.enhanceParameters(), - templateKey: this.options.rule.get('templateKey'), - isTemplate: this.options.rule.get('isTemplate') - }); + enableUpdate: function () { + return this.ui.update.prop('disabled', false); + }, + + getParent: function () { + if (!(this.model.get('inherit') && this.model.get('inherit') !== 'NONE')) { + return null; } - }); + var myProfile = _.findWhere(this.options.app.qualityProfiles, { + key: this.model.get('qProfile') + }), + parentKey = myProfile.parentKey, + parent = _.extend({}, _.findWhere(this.options.app.qualityProfiles, { + key: parentKey + })), + parentActiveInfo = this.model.collection.findWhere({ qProfile: parentKey }) || new Backbone.Model(); + _.extend(parent, parentActiveInfo.toJSON()); + return parent; + }, + enhanceParameters: function () { + var parent = this.getParent(), + params = _.sortBy(this.model.get('params'), 'key'); + if (!parent) { + return params; + } + return params.map(function (p) { + var parentParam = _.findWhere(parent.params, { key: p.key }); + if (parentParam != null) { + return _.extend(p, { + original: _.findWhere(parent.params, { key: p.key }).value + }); + } else { + return p; + } + }); + }, + + serializeData: function () { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + canWrite: this.options.app.canWrite, + parent: this.getParent(), + parameters: this.enhanceParameters(), + templateKey: this.options.rule.get('templateKey'), + isTemplate: this.options.rule.get('isTemplate') + }); + } }); + + |