<%= render :partial => '/coding_rules/templates/coding_rules_list_item_template.hbs' -%>
<%= render :partial => '/coding_rules/templates/coding_rules_list_empty_template.hbs' -%>
<%= render :partial => '/coding_rules/templates/coding_rules_detail_template.hbs' -%>
+<%= render :partial => '/coding_rules/templates/coding_rules_detail_quality_profile_template.hbs' -%>
<%= render :partial => '/coding_rules/templates/coding_rules_facets_item_template.hbs' -%>
<%= render :partial => '/coding_rules/templates/coding_rules_bulk_change_template.hbs' -%>
--- /dev/null
+<script id="coding-rules-detail-quality-profile-template" type="text/x-handlebars-template">
+ <div class="coding-rules-detail-quality-profile-name">{{name}}</div>
+
+ {{#if parent}}
+ <div class="coding-rules-detail-quality-profile-inheritance">
+ <i class="icon-inheritance"></i> {{t 'coding_rules.inherits'}} <strong>{{parent.name}}</strong>
+ </div>
+ {{/if}}
+
+ <ul class="coding-rules-detail-parameters coding-rules-detail-quality-profile-parameters">
+ <li class="coding-rules-detail-parameter">
+ <h3 class="coding-rules-detail-parameter-name">{{t 'severity'}}</h3>
+ <div class="coding-rules-detail-parameter-description">
+ <select class="coding-rules-detail-quality-profile-severity">
+ {{#each severities}}
+ <option value="{{this}}">{{t 'severity' this}}</option>
+ {{/each}}
+ </select>
+ {{#if parent}}
+ {{#notEq severity parent.severity}}
+ {{t 'coding_rules.original'}} {{severityIcon parent.severity}}{{t 'severity' parent.severity}}
+ {{/notEq}}
+ {{/if}}
+ </div>
+ </li>
+ {{#each parameters}}
+ <li class="coding-rules-detail-parameter">
+ <h3 class="coding-rules-detail-parameter-name">{{key}}</h3>
+ <div class="coding-rules-detail-parameter-description">
+ <input type="text" value="{{value}}">
+ {{#if ../parent}}
+ {{#notEq value original}}
+ {{t 'coding_rules.original'}} {{original}}
+ {{/notEq}}
+ {{/if}}
+ </div>
+ </li>
+ {{/each}}
+ </ul>
+
+ <div class="button-group coding-rules-detail-quality-profile-actions">
+ <button>{{t 'update'}}</button>
+ {{#if parent}}
+ <button class="button-red">{{t 'coding_rules.revert_to_parent_definition'}}</button>
+ {{/if}}
+ <button class="button-red">{{t 'coding_rules.deactivate_quality_profile'}}</button>
+ </div>
+</script>
{{/if}}
- {{!--
- <h3 class="coding-rules-detail-header coding-rules-detail-quality-profiles-header">
- {{t 'coding_rules.quality_profiles'}}
-
- <div class="button-group coding-rules-detail-quality-profiles-activation">
- <button>{{t 'coding_rules.activate_quality_profile'}}</button>
- </div>
- </h3>
-
- <ul class="coding-rules-detail-quality-profiles">
- {{#each qualityProfiles}}
- <li class="coding-rules-detail-quality-profile">
- <div class="coding-rules-detail-quality-profile-name">{{name}}</div>
- <div class="coding-rules-detail-quality-profile-severity">{{severityIcon severity}}{{t 'severity' severity}}</div>
- <ul class="coding-rules-detail-quality-profile-parameters">
- {{#each parameters}}
- <li class="coding-rules-detail-quality-profile-parameter">
- {{#if ../canUpdate}}
- <label class="coding-rules-detail-quality-profile-parameter-key">{{key}}</label>
- <input class="coding-rules-detail-quality-profile-parameter-value" type="text" value="{{value}}">
- <div class="button-group coding-rules-detail-quality-profile-parameter-actions">
- <button class="coding-rules-detail-quality-profile-parameter-update">{{t 'update'}}</button>
- </div>
- {{else}}
- {{key}}: {{value}}
- {{/if}}
- </li>
- {{/each}}
- </ul>
- {{#if canDeactivate}}
- <div class="button-group coding-rules-detail-quality-profile-actions">
- <button class="button-red">{{t 'coding_rules.deactivate_quality_profile'}}</button>
- </div>
- {{/if}}
- </li>
- {{/each}}
- </ul>
- --}}
+ <h3 class="coding-rules-detail-title">{{t 'coding_rules.quality_profiles'}}</h3>
+ <div id="coding-rules-detail-quality-profiles"></div>
</script>
'done': 'Done'
'moreCriteria': '+ More Criteria'
'search_verb': 'Search'
+ 'severity': 'Severity'
'update': 'Update'
'severity.BLOCKER': 'Blocker'
'coding_rules.extend_description': 'Extend Description'
'coding_rules.deactivate_quality_profile': 'Deactivate'
'coding_rules.found': 'Found'
+ 'coding_rules.inherits': 'Inherits'
'coding_rules.key': 'Key:'
'coding_rules.new_search': 'New Search'
'coding_rules.no_results': 'No Coding Rules'
'coding_rules.order': 'Order'
'coding_rules.ordered_by': 'Ordered By'
+ 'coding_rules.original': 'Original:'
'coding_rules.page': 'Coding Rules'
'coding_rules.parameters': 'Parameters'
'coding_rules.parameters.default_value': 'Default Value:'
'coding_rules.quality_profiles': 'Quality Profiles'
'coding_rules.repository': 'Repository:'
+ 'coding_rules.revert_to_parent_definition': 'Revert to Parent Definition'
'coding_rules._rules': 'rule(s)'
'coding_rules.select_tag': 'Select Tag'
qualityProfiles: [
{
name: 'SonarWay'
+ key: 'sonarway'
severity: 'MINOR'
canDeactivate: true
canUpdate: true
parameters: [
{ key: 'max', value: 8 }
]
-
},
{
name: 'Quality Profile 1'
+ key: 'qualityprofile1'
severity: 'MAJOR'
canDeactivate: false
canUpdate: false
parameters: [
{ key: 'max', value: 6 }
]
-
+ inherits: 'sonarway'
}
]
'done': 'Done',
'moreCriteria': '+ More Criteria',
'search_verb': 'Search',
+ 'severity': 'Severity',
'update': 'Update',
'severity.BLOCKER': 'Blocker',
'severity.CRITICAL': 'Critical',
'coding_rules.extend_description': 'Extend Description',
'coding_rules.deactivate_quality_profile': 'Deactivate',
'coding_rules.found': 'Found',
+ 'coding_rules.inherits': 'Inherits',
'coding_rules.key': 'Key:',
'coding_rules.new_search': 'New Search',
'coding_rules.no_results': 'No Coding Rules',
'coding_rules.order': 'Order',
'coding_rules.ordered_by': 'Ordered By',
+ 'coding_rules.original': 'Original:',
'coding_rules.page': 'Coding Rules',
'coding_rules.parameters': 'Parameters',
'coding_rules.parameters.default_value': 'Default Value:',
'coding_rules.quality_profiles': 'Quality Profiles',
'coding_rules.repository': 'Repository:',
+ 'coding_rules.revert_to_parent_definition': 'Revert to Parent Definition',
'coding_rules._rules': 'rule(s)',
'coding_rules.select_tag': 'Select Tag',
'coding_rules.filters.availableSince': 'Available Since',
qualityProfiles: [
{
name: 'SonarWay',
+ key: 'sonarway',
severity: 'MINOR',
canDeactivate: true,
canUpdate: true,
]
}, {
name: 'Quality Profile 1',
+ key: 'qualityprofile1',
severity: 'MAJOR',
canDeactivate: false,
canUpdate: false,
key: 'max',
value: 6
}
- ]
+ ],
+ inherits: 'sonarway'
}
]
}
--- /dev/null
+define [
+ 'backbone.marionette',
+ 'common/handlebars-extensions'
+], (
+ Marionette
+) ->
+
+ class CodingRulesDetailQualityProfilesView extends Marionette.ItemView
+ className: 'coding-rules-detail-quality-profile'
+ template: getTemplate '#coding-rules-detail-quality-profile-template'
+
+
+ ui:
+ severitySelect: '.coding-rules-detail-quality-profile-severity'
+
+
+ onRender: ->
+ 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()
+
+
+ enhanceParameters: ->
+ parent = @getParent()
+ parameters = @model.get 'parameters'
+ return parameters unless parent
+ parameters.map (p) ->
+ _.extend p, original: _.findWhere(parent.parameters, key: p.key).value
+
+
+ serializeData: ->
+ _.extend super,
+ parent: @getParent()
+ parameters: @enhanceParameters()
+ severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']
\ No newline at end of file
--- /dev/null
+// Generated by CoffeeScript 1.6.3
+(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', 'common/handlebars-extensions'], function(Marionette) {
+ var CodingRulesDetailQualityProfilesView, _ref;
+ return CodingRulesDetailQualityProfilesView = (function(_super) {
+ __extends(CodingRulesDetailQualityProfilesView, _super);
+
+ function CodingRulesDetailQualityProfilesView() {
+ _ref = CodingRulesDetailQualityProfilesView.__super__.constructor.apply(this, arguments);
+ return _ref;
+ }
+
+ CodingRulesDetailQualityProfilesView.prototype.className = 'coding-rules-detail-quality-profile';
+
+ CodingRulesDetailQualityProfilesView.prototype.template = getTemplate('#coding-rules-detail-quality-profile-template');
+
+ CodingRulesDetailQualityProfilesView.prototype.ui = {
+ severitySelect: '.coding-rules-detail-quality-profile-severity'
+ };
+
+ CodingRulesDetailQualityProfilesView.prototype.onRender = function() {
+ var format;
+ format = function(state) {
+ if (!state.id) {
+ return state.text;
+ }
+ return "<i class='icon-severity-" + (state.id.toLowerCase()) + "'></i> " + state.text;
+ };
+ this.ui.severitySelect.val(this.model.get('severity'));
+ return this.ui.severitySelect.select2({
+ width: '200px',
+ minimumResultsForSearch: 999,
+ formatResult: format,
+ formatSelection: format,
+ escapeMarkup: function(m) {
+ return m;
+ }
+ });
+ };
+
+ CodingRulesDetailQualityProfilesView.prototype.getParent = function() {
+ if (!this.model.get('inherits')) {
+ return null;
+ }
+ return this.options.qualityProfiles.findWhere({
+ key: this.model.get('inherits')
+ }).toJSON();
+ };
+
+ CodingRulesDetailQualityProfilesView.prototype.enhanceParameters = function() {
+ var parameters, parent;
+ parent = this.getParent();
+ parameters = this.model.get('parameters');
+ if (!parent) {
+ return parameters;
+ }
+ return parameters.map(function(p) {
+ return _.extend(p, {
+ original: _.findWhere(parent.parameters, {
+ key: p.key
+ }).value
+ });
+ });
+ };
+
+ CodingRulesDetailQualityProfilesView.prototype.serializeData = function() {
+ return _.extend(CodingRulesDetailQualityProfilesView.__super__.serializeData.apply(this, arguments), {
+ parent: this.getParent(),
+ parameters: this.enhanceParameters(),
+ severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']
+ });
+ };
+
+ return CodingRulesDetailQualityProfilesView;
+
+ })(Marionette.ItemView);
+ });
+
+}).call(this);
--- /dev/null
+define [
+ 'backbone.marionette'
+ 'coding-rules/views/coding-rules-detail-quality-profile-view'
+], (
+ Marionette,
+ CodingRulesDetailQualityProfileView
+) ->
+
+ class CodingRulesDetailQualityProfilesView extends Marionette.CollectionView
+ itemView: CodingRulesDetailQualityProfileView
+
+ itemViewOptions: ->
+ qualityProfiles: @collection
\ No newline at end of file
--- /dev/null
+// Generated by CoffeeScript 1.6.3
+(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', 'coding-rules/views/coding-rules-detail-quality-profile-view'], function(Marionette, CodingRulesDetailQualityProfileView) {
+ var CodingRulesDetailQualityProfilesView, _ref;
+ return CodingRulesDetailQualityProfilesView = (function(_super) {
+ __extends(CodingRulesDetailQualityProfilesView, _super);
+
+ function CodingRulesDetailQualityProfilesView() {
+ _ref = CodingRulesDetailQualityProfilesView.__super__.constructor.apply(this, arguments);
+ return _ref;
+ }
+
+ CodingRulesDetailQualityProfilesView.prototype.itemView = CodingRulesDetailQualityProfileView;
+
+ CodingRulesDetailQualityProfilesView.prototype.itemViewOptions = function() {
+ return {
+ qualityProfiles: this.collection
+ };
+ };
+
+ return CodingRulesDetailQualityProfilesView;
+
+ })(Marionette.CollectionView);
+ });
+
+}).call(this);
define [
+ 'backbone',
'backbone.marionette',
+ 'coding-rules/views/coding-rules-detail-quality-profiles-view'
'common/handlebars-extensions'
], (
- Marionette
+ Backbone,
+ Marionette,
+ CodingRulesDetailQualityProfilesView
) ->
- class CodingRulesDetailView extends Marionette.ItemView
+ class CodingRulesDetailView extends Marionette.Layout
template: getTemplate '#coding-rules-detail-template'
+ regions:
+ qualityProfilesRegion: '#coding-rules-detail-quality-profiles'
+
+
ui:
tagsChange: '.coding-rules-detail-tags-change'
tagInput: '.coding-rules-detail-tag-input'
'click @ui.extendDescriptionSubmit': 'submitExtendDescription'
+ initialize: (options) ->
+ @qualityProfilesView = new CodingRulesDetailQualityProfilesView
+ collection: new Backbone.Collection options.model.get 'qualityProfiles'
+
+
onRender: ->
+ @qualityProfilesRegion.show @qualityProfilesView
+
@ui.tagInput.select2
tags: _.difference @options.app.tags, @model.get 'tags'
width: '500px'
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', 'common/handlebars-extensions'], function(Marionette) {
+ define(['backbone', 'backbone.marionette', 'coding-rules/views/coding-rules-detail-quality-profiles-view', 'common/handlebars-extensions'], function(Backbone, Marionette, CodingRulesDetailQualityProfilesView) {
var CodingRulesDetailView, _ref;
return CodingRulesDetailView = (function(_super) {
__extends(CodingRulesDetailView, _super);
CodingRulesDetailView.prototype.template = getTemplate('#coding-rules-detail-template');
+ CodingRulesDetailView.prototype.regions = {
+ qualityProfilesRegion: '#coding-rules-detail-quality-profiles'
+ };
+
CodingRulesDetailView.prototype.ui = {
tagsChange: '.coding-rules-detail-tags-change',
tagInput: '.coding-rules-detail-tag-input',
'click @ui.extendDescriptionSubmit': 'submitExtendDescription'
};
+ CodingRulesDetailView.prototype.initialize = function(options) {
+ return this.qualityProfilesView = new CodingRulesDetailQualityProfilesView({
+ collection: new Backbone.Collection(options.model.get('qualityProfiles'))
+ });
+ };
+
CodingRulesDetailView.prototype.onRender = function() {
var qp;
+ this.qualityProfilesRegion.show(this.qualityProfilesView);
this.ui.tagInput.select2({
tags: _.difference(this.options.app.tags, this.model.get('tags')),
width: '500px'
return CodingRulesDetailView;
- })(Marionette.ItemView);
+ })(Marionette.Layout);
});
}).call(this);
font-size: 0;
}
.coding-rules-detail-quality-profile {
- display: inline-block;
- vertical-align: top;
- width: 240px;
- margin-right: 20px;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- font-size: 13px;
+ border: 1px solid transparent;
}
.coding-rules-detail-quality-profile.active {
- background-color: #CAE3F2;
border-color: #4b9fd5;
}
.coding-rules-detail-quality-profile.active .coding-rules-detail-quality-profile-name {
background-color: #4b9fd5;
color: #fff;
}
-.coding-rules-detail-quality-profile-severity {
- padding: 5px;
- font-size: 11px;
+.coding-rules-detail-quality-profile + .coding-rules-detail-quality-profile {
+ margin-top: 20px;
}
.coding-rules-detail-quality-profile-name {
padding: 5px;
.coding-rules-detail-quality-profile-actions {
padding: 5px;
}
-.coding-rules-detail-quality-profile-parameters {
- padding: 5px;
-}
-.coding-rules-detail-quality-profile-parameter {
- white-space: nowrap;
-}
-.coding-rules-detail-quality-profile-parameter-key,
-.coding-rules-detail-quality-profile-parameter-value,
-.coding-rules-detail-quality-profile-parameter-actions {
+.coding-rules-detail-quality-profile-parameters .coding-rules-detail-parameter-name,
+.coding-rules-detail-quality-profile-parameters .coding-rules-detail-parameter-description {
vertical-align: middle;
}
-.coding-rules-detail-quality-profile-parameter-key:after {
- content: ":";
+.coding-rules-detail-quality-profile-parameters .coding-rules-detail-parameter-description input {
+ width: 200px;
}
-.coding-rules-detail-quality-profile-parameter-value {
- width: 110px;
+.coding-rules-detail-quality-profile-inheritance {
+ margin: 10px 0;
}
-.coding-rules-detail-quality-profile-parameter-actions {
- float: right;
+.coding-rules-detail-quality-profile-inheritance strong {
+ font-weight: bold;
}
.coding-rules-detail-quality-profiles-activation {
margin-top: -3px;
}
.coding-rules-detail-quality-profile {
- display: inline-block;
- vertical-align: top;
- width: 240px;
- margin-right: 2 * @navigatorPadding;
- .box-sizing(border-box);
- font-size: @baseFontSize;
+ border: 1px solid transparent;
&.active {
- background-color: #CAE3F2;
border-color: @highlighted;
.coding-rules-detail-quality-profile-name {
}
}
-.coding-rules-detail-quality-profile-severity {
- padding: @navigatorPadding / 2;
- font-size: @smallFontSize;
+.coding-rules-detail-quality-profile + .coding-rules-detail-quality-profile {
+ margin-top: 2 * @navigatorPadding;
}
.coding-rules-detail-quality-profile-name {
}
.coding-rules-detail-quality-profile-parameters {
- padding: @navigatorPadding / 2;
-}
-.coding-rules-detail-quality-profile-parameter {
- white-space: nowrap;
-}
-
-.coding-rules-detail-quality-profile-parameter-key,
-.coding-rules-detail-quality-profile-parameter-value,
-.coding-rules-detail-quality-profile-parameter-actions {
- vertical-align: middle;
-}
+ .coding-rules-detail-parameter-name,
+ .coding-rules-detail-parameter-description {
+ vertical-align: middle;
+ }
-.coding-rules-detail-quality-profile-parameter-key {
- &:after {
- content: ":";
+ .coding-rules-detail-parameter-description input {
+ width: 200px;
}
}
-.coding-rules-detail-quality-profile-parameter-value {
- width: 110px;
-}
+.coding-rules-detail-quality-profile-inheritance {
+ margin: @navigatorPadding 0;
-.coding-rules-detail-quality-profile-parameter-actions {
- float: right;
+ strong { font-weight: bold; }
}
.coding-rules-detail-quality-profiles-activation {
}
.icon-inheritance:before {
content: "\f126";
+ font-size: 16px;
}
.icon-plus:before {
content: "\f067";
}
.icon-inheritance:before {
content: "\f126";
+ font-size: @iconFontSize;
}
.icon-plus:before {
content: "\f067";