9 class QualityGateDetailConditionView extends Marionette.ItemView
11 template: Handlebars.compile jQuery('#quality-gate-detail-condition-template').html()
12 spinner: '<i class="spinner"></i>'
20 periodSelect: '[name=period]'
21 operatorSelect: '[name=operator]'
22 warningInput: '[name=warning]'
23 errorInput: '[name=error]'
24 actionsBox: '.quality-gate-condition-actions'
25 updateButton: '.update-condition'
29 'click @ui.updateButton': 'saveCondition'
30 'click .delete-condition': 'deleteCondition'
31 'click .add-condition': 'saveCondition'
32 'click .cancel-add-condition': 'cancelAddCondition'
33 'keyup :input': 'enableUpdate'
34 'change :input': 'enableUpdate'
42 metricKey = @model.get('metric')
43 metric = @options.app.metrics.findWhere key: metricKey
44 @model.set { metric: metric.toJSON() }, { silent: true }
48 @ui.periodSelect.val @model.get('period') || '0'
49 @ui.operatorSelect.val @model.get('op')
50 @ui.warningInput.val @model.get('warning')
51 @ui.errorInput.val @model.get('error')
53 @ui.periodSelect.select2
55 minimumResultsForSearch: 999
58 @ui.operatorSelect.select2
60 minimumResultsForSearch: 999
63 @ui.periodSelect.select2('open') if @model.isNew()
67 jQuery(@spinner).prependTo @ui.actionsBox
68 @ui.actionsBox.find(':not(.spinner)').hide()
72 @ui.actionsBox.find('.spinner').remove()
73 @ui.actionsBox.find(':not(.spinner)').show()
79 period: @ui.periodSelect.val()
80 op: @ui.operatorSelect.val()
81 warning: @ui.warningInput.val()
82 error: @ui.errorInput.val()
85 @ui.updateButton.prop 'disabled', true
88 @options.collectionView.updateConditions()
92 if confirm t('are_you_sure')
94 @model.delete().done =>
95 @options.collectionView.updateConditions()
99 cancelAddCondition: ->
104 @ui.updateButton.prop 'disabled', false
108 period = _.findWhere(@options.app.periods, key: '' + this.model.get('period'))
110 canEdit: @options.app.canEdit
111 periods: @options.app.periods
112 periodText: period?.text