]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5091 Force selection of period for new_* metrics, show delta in period label
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Tue, 18 Mar 2014 12:40:20 +0000 (13:40 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Tue, 18 Mar 2014 12:40:27 +0000 (13:40 +0100)
sonar-server/src/main/webapp/WEB-INF/app/views/quality_gates/templates/_quality_gate_detail_condition_template.hbs.erb
sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.coffee
sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-condition-view.js

index 6023e5b4357630ddc9f521b773562a2fa4d3d871..95ace5887a95ac1ee8df85a3ec2d193c6df81c12 100644 (file)
@@ -5,11 +5,13 @@
   <td width="10%" nowrap>
     {{#if canEdit}}
       <select name="period">
-        <option value="0">{{t 'value'}}</option>
-        {{#each periods}}<option value="{{key}}">{{text}}</option>{{/each}}
+        {{#unless isDiffMetric}}<option value="0">{{t 'value'}}</option>{{/unless}}
+        {{#each periods}}<option value="{{key}}">&Delta; {{text}}</option>{{/each}}
       </select>
     {{else}}
-      {{periodText}}
+      {{#if periodText}}&Delta; {{periodText}}
+      {{else}}{{t 'value'}}
+      {{/if}}
     {{/if}}
   </td>
   <td width="10%" nowrap>
index da1b8d46f04d300304e3262dd9931f4c0c679b2f..26f23dbc32ee45bf7dc5b2690e1182a9c488fce1 100644 (file)
@@ -42,6 +42,7 @@ define [
       metricKey = @model.get('metric')
       metric = _.findWhere @options.app.metrics, key: metricKey
       @model.set { metric: metric }, { silent: true }
+      @model.set { isDiffMetric: metric.key.indexOf('new_') == 0 }, { silent: true }
 
 
     onRender: ->
@@ -105,7 +106,7 @@ define [
 
 
     serializeData: ->
-      period = _.findWhere(@options.app.periods, key: '' + this.model.get('period'))
+      period = _.findWhere(@options.app.periods, key: this.model.get('period'))
       _.extend super,
         canEdit: @options.app.canEdit
         periods: @options.app.periods
index 0abc1b0532b242fe7fcfe7203eccf0434e6d4bf5..d18fa24aff083ced719136bf0c88dd60f8799c9f 100644 (file)
@@ -1,16 +1,15 @@
-// Generated by CoffeeScript 1.6.3
+// Generated by CoffeeScript 1.7.1
 (function() {
   var __hasProp = {}.hasOwnProperty,
     __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; };
 
   define(['backbone.marionette', 'handlebars'], function(Marionette, Handlebars) {
-    var QualityGateDetailConditionView, _ref;
+    var QualityGateDetailConditionView;
     return QualityGateDetailConditionView = (function(_super) {
       __extends(QualityGateDetailConditionView, _super);
 
       function QualityGateDetailConditionView() {
-        _ref = QualityGateDetailConditionView.__super__.constructor.apply(this, arguments);
-        return _ref;
+        return QualityGateDetailConditionView.__super__.constructor.apply(this, arguments);
       }
 
       QualityGateDetailConditionView.prototype.tagName = 'tr';
         metric = _.findWhere(this.options.app.metrics, {
           key: metricKey
         });
-        return this.model.set({
+        this.model.set({
           metric: metric
         }, {
           silent: true
         });
+        return this.model.set({
+          isDiffMetric: metric.key.indexOf('new_') === 0
+        }, {
+          silent: true
+        });
       };
 
       QualityGateDetailConditionView.prototype.onRender = function() {
@@ -89,7 +93,6 @@
       };
 
       QualityGateDetailConditionView.prototype.saveCondition = function() {
-        var _this = this;
         this.showSpinner();
         this.model.set({
           period: this.ui.periodSelect.val(),
           warning: this.ui.warningInput.val(),
           error: this.ui.errorInput.val()
         });
-        return this.model.save().always(function() {
-          _this.ui.updateButton.prop('disabled', true);
-          return _this.hideSpinner();
-        }).done(function() {
-          return _this.options.collectionView.updateConditions();
-        });
+        return this.model.save().always((function(_this) {
+          return function() {
+            _this.ui.updateButton.prop('disabled', true);
+            return _this.hideSpinner();
+          };
+        })(this)).done((function(_this) {
+          return function() {
+            return _this.options.collectionView.updateConditions();
+          };
+        })(this));
       };
 
       QualityGateDetailConditionView.prototype.deleteCondition = function() {
-        var _this = this;
         if (confirm(t('are_you_sure'))) {
           this.showSpinner();
-          return this.model["delete"]().done(function() {
-            _this.options.collectionView.updateConditions();
-            return _this.close();
-          });
+          return this.model["delete"]().done((function(_this) {
+            return function() {
+              _this.options.collectionView.updateConditions();
+              return _this.close();
+            };
+          })(this));
         }
       };
 
       QualityGateDetailConditionView.prototype.serializeData = function() {
         var period;
         period = _.findWhere(this.options.app.periods, {
-          key: '' + this.model.get('period')
+          key: this.model.get('period')
         });
         return _.extend(QualityGateDetailConditionView.__super__.serializeData.apply(this, arguments), {
           canEdit: this.options.app.canEdit,