property: 'activation'
type: ActivationFilterView
enabled: false
- optional: true
+ optional: false
multiple: false
qualityProfileFilter: @qualityProfileFilter
choices:
ui:
- update: '.coding-rules-detail-quality-profile-update'
- severitySelect: '.coding-rules-detail-quality-profile-severity'
-
- note: '.coding-rules-detail-quality-profile-note'
- noteForm: '.coding-rules-detail-quality-profile-note-form'
- noteText: '.coding-rules-detail-quality-profile-note-text'
- noteAdd: '.coding-rules-detail-quality-profile-note-add'
- noteEdit: '.coding-rules-detail-quality-profile-note-edit'
- noteDelete: '.coding-rules-detail-quality-profile-note-delete'
- noteCancel: '.coding-rules-detail-quality-profile-note-cancel'
- noteSubmit: '.coding-rules-detail-quality-profile-note-submit'
-
-
- events:
- 'click @ui.noteAdd': 'editNote'
- 'click @ui.noteEdit': 'editNote'
- 'click @ui.noteDelete': 'deleteNote'
- 'click @ui.noteCancel': 'cancelNote'
- 'click @ui.noteSubmit': 'submitNote'
-
- 'change .coding-rules-detail-parameters select': 'enableUpdate'
- 'keyup .coding-rules-detail-parameters input': 'enableUpdate'
-
-
- editNote: ->
- @ui.note.hide()
- @ui.noteForm.show()
- @ui.noteText.focus()
-
-
- deleteNote: ->
- @ui.noteText.val ''
- @submitNote().done =>
- @model.unset 'note'
- @render()
-
-
- cancelNote: ->
- @ui.note.show()
- @ui.noteForm.hide()
-
-
- submitNote: ->
- @ui.note.html '<i class="spinner"></i>'
- @ui.noteForm.html '<i class="spinner"></i>'
- jQuery.ajax
- type: 'POST'
- url: "#{baseUrl}/api/codingrules/note"
- dataType: 'json'
- data: text: @ui.noteText.val()
- .done (r) =>
- @model.set 'note', r.note
- @render()
+ change: '.coding-rules-detail-quality-profile-change'
enableUpdate: ->
@ui.update.prop 'disabled', false
- onRender: ->
- @ui.noteForm.hide()
-
- format = (state) ->
- return state.text unless state.id
- "<i class='icon-severity-#{state.id.toLowerCase()}'></i> #{state.text}"
-
- @ui.severitySelect.val @model.get 'severity'
-# @ui.severitySelect.select2
-# width: '200px'
-# minimumResultsForSearch: 999
-# formatResult: format
-# formatSelection: format
-# escapeMarkup: (m) -> m
-
-
getParent: ->
return null unless @model.get 'inherits'
@options.qualityProfiles.findWhere(key: @model.get('inherits')).toJSON()
serializeData: ->
_.extend super,
parent: @getParent()
- parameters: @enhanceParameters()
- severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']
\ No newline at end of file
+ parameters: @enhanceParameters()
\ No newline at end of file
define [
+ 'navigator/filters/choice-filters'
'coding-rules/views/filters/inheritance-filter-view'
], (
+ ChoiceFilters
InheritanceFilterView
) ->
+ class DetailsActivationFilterView extends ChoiceFilters.DetailsChoiceFilterView
+
+ onCheck: (e) ->
+ id = jQuery(e.target).val()
+ selected = @options.filterView.choices.findWhere checked: true
+ unless id == selected
+ @options.filterView.choices.each (item) -> item.set 'checked', item.id == id
+ else
+ e.preventDefault()
+ @updateValue()
+ @updateLists()
+
+
+
class ActivationFilterView extends InheritanceFilterView
tooltip: 'coding_rules.filters.activation.help'
+ initialize: ->
+ super detailsView: DetailsActivationFilterView
+
+
onChangeQualityProfile: ->
qualityProfile = @qualityProfileFilter.get 'value'
- if _.isArray(qualityProfile) && qualityProfile.length == 1 then @makeActive() else @makeInactive()
\ No newline at end of file
+ if _.isArray(qualityProfile) && qualityProfile.length == 1 then @makeActive() else @makeInactive()
+
+
+ makeActive: ->
+ @choices.each (item) -> item.set 'checked', item.id == 'active'
+ @detailsView.updateValue()
+ @detailsView.updateLists()
+ @render()
+ super
\ No newline at end of file
initialize: ->
super
@choices = new QualityProfileSuggestions
- @listenTo @model, 'change:value', @updateParentQualityProfile
+ @listenTo @model, 'change:value', @onValueChange
+
+
+ onValueChange: ->
+ @updateParentQualityProfile()
+ @highlightContext()
updateParentQualityProfile: ->
@model.unset 'parentQualityProfile'
+ highlightContext: ->
+ hasContext = _.isArray(@model.get('value')) && @model.get('value').length > 0
+ @$el.toggleClass 'navigator-filter-context', hasContext
+
+
createRequest: (v) ->
jQuery.ajax
url: baseUrl + '/api/qualityprofiles/show'
.coding-rules-detail-context-actions {
margin-bottom: @navigatorPadding;
+ padding: @navigatorPadding / 2;
+ background-color: @contextBackground;
+ border: 1px solid @contextBorder;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-right: @navigatorPadding;
.limited {
+ display: inline-block;
+ vertical-align: middle;
max-width: 180px;
white-space: nowrap;
overflow: hidden;
}
.limited-big {
- width: 480px;
+ max-width: 480px;
}
}
opacity: 0.5;
}
+.navigator-filter-context {
+ background-color: @contextBackground;
+ border-color: @contextBorder;
+}
+
.navigator-filter-label {
display: inline-block;
vertical-align: middle;
@orange: #f90;
@highlighted: @blue;
-
+@contextBackground: lighten(@green, 40%);
+@contextBorder: lighten(@green, 20%);
/*
<td class="coding-rules-detail-quality-profile-actions">
<div class="button-group">
- <button class="coding-rules-detail-quality-profile-update">{{t 'change'}}</button>
+ <button class="coding-rules-detail-quality-profile-change">{{t 'change'}}</button>
{{#if parent}}
<button class="coding-rules-detail-quality-profile-revert button-red">
{{t 'coding_rules.revert_to_parent_definition'}}
{{#if contextQualityProfile}}
- <div class="coding-rules-detail-context-actions admin">
+ <div class="coding-rules-detail-context-actions">
<table class="width100">
<tbody>
<tr>
</span>
{{/each}}
- {{#if note}}<span class="coding-rules-detail-context-actions-item">{{{note.html}}}</span>{{/if}}
+ {{#if note}}
+ <span class="coding-rules-detail-context-actions-item">
+ <span class="limited limited-big">{{{note.html}}}</span>
+ </span>
+ {{/if}}
{{/with}}
{{/if}}
</td>