<div class="modal-body modal-body-select2">
<div class="modal-error"></div>
- {{#notEmpty qualityProfiles}}
- <table>
- <tr class="property">
- <th><h3>{{t 'coding_rules.quality_profile'}}</h3></th>
- <td>
- {{#if key}}
- {{name}}
- {{else}}
- <select id="coding-rules-quality-profile-activation-select">
- {{#each qualityProfiles}}
- <option value="{{key}}">{{name}}</option>
- {{/each}}
- </select>
- {{/if}}
- </td>
- </tr>
- <tr class="property">
- <th><h3>{{t 'severity'}}</h3></th>
- <td>
- <select id="coding-rules-quality-profile-activation-severity">
- {{#each severities}}
- <option value="{{this}}">{{t 'severity' this}}</option>
+ {{#empty qualityProfiles}}
+ {{#unless change}}
+ <div class="message-notice">{{t 'coding_rules.active_in_all_profiles'}}</div>
+ {{/unless}}
+ {{/empty}}
+
+ <table>
+ <tr class="property">
+ <th><h3>{{t 'coding_rules.quality_profile'}}</h3></th>
+ <td>
+ {{#if key}}
+ {{name}}
+ {{else}}
+ <select id="coding-rules-quality-profile-activation-select">
+ {{#each qualityProfiles}}
+ <option value="{{key}}">{{name}}</option>
{{/each}}
</select>
- </td>
- </tr>
- {{#if isCustomRule}}
- <tr class="property">
- <td colspan="2" class="note">{{t 'coding_rules.custom_rule.activation_notice'}}</td>
- {{else}}
+ {{/if}}
+ </td>
+ </tr>
+ <tr class="property">
+ <th><h3>{{t 'severity'}}</h3></th>
+ <td>
+ <select id="coding-rules-quality-profile-activation-severity">
+ {{#each severities}}
+ <option value="{{this}}">{{t 'severity' this}}</option>
+ {{/each}}
+ </select>
+ </td>
+ </tr>
+ {{#if isCustomRule}}
+ <tr class="property">
+ <td colspan="2" class="note">{{t 'coding_rules.custom_rule.activation_notice'}}</td>
+ {{else}}
{{#each params}}
<tr class="property">
<th><h3>{{key}}</h3></th>
<textarea class="width100" rows="3" name="{{key}}" placeholder="{{defaultValue}}">{{value}}</textarea>
{{else}}
{{#eq type 'BOOLEAN'}}
- <select name="{{key}}" value="{{value}}">
- <option value="{{defaultValue}}">{{t 'default'}} ({{t defaultValue}})</option>
- <option value="true"{{#eq value 'true'}} selected="selected"{{/eq}}>{{t 'true'}}</option>
- <option value="false"{{#eq value 'false'}} selected="selected"{{/eq}}>{{t 'false'}}</option>
- </select>
+ <select name="{{key}}" value="{{value}}">
+ <option value="{{defaultValue}}">{{t 'default'}} ({{t defaultValue}})</option>
+ <option value="true"{{#eq value 'true'}} selected="selected"{{/eq}}>{{t 'true'}}</option>
+ <option value="false"{{#eq value 'false'}} selected="selected"{{/eq}}>{{t 'false'}}</option>
+ </select>
{{else}}
- <input type="text" name="{{key}}" value="{{value}}" placeholder="{{defaultValue}}">
+ <input type="text" name="{{key}}" value="{{value}}" placeholder="{{defaultValue}}">
{{/eq}}
{{/eq}}
<div class="note">{{{htmlDesc}}}</div>
</td>
</tr>
{{/each}}
- {{/if}}
- </table>
- {{else}}
- <div class="message-notice">{{t 'coding_rules.active_in_all_profiles'}}</div>
- {{/notEmpty}}
+ {{/if}}
+ </table>
</div>
<div class="modal-foot">
define([
'components/navigator/workspace-list-item-view',
+ 'coding-rules/rule/profile-activation-view',
'templates/coding-rules'
-], function (WorkspaceListItemView) {
+], function (WorkspaceListItemView, ProfileActivationView) {
return WorkspaceListItemView.extend({
className: 'coding-rule',
events: {
'click': 'selectCurrent',
- 'click .js-rule': 'openRule'
+ 'click .js-rule': 'openRule',
+ 'click .coding-rules-detail-quality-profile-activate': 'activate',
+ 'click .coding-rules-detail-quality-profile-deactivate': 'deactivate'
},
selectCurrent: function () {
this.options.app.controller.showDetails(this.model);
},
+ getActiveProfile: function () {
+ return this.model.get('activeProfile');
+ },
+
+ activate: function () {
+ var activeProfile = this.options.app.state.get('query').qprofile,
+ othersQualityProfiles = _.reject(this.options.app.qualityProfiles, function (profile) {
+ return profile.key === activeProfile;
+ });
+
+ new ProfileActivationView({
+ rule: this.model,
+ collection: new Backbone.Collection(othersQualityProfiles),
+ app: this.options.app,
+ fromList: true
+ }).render();
+ },
+
+ deactivate: function () {
+ var that = this,
+ ruleKey = this.model.get('key'),
+ myProfile = this.model.get('activeProfile');
+ window.confirmDialog({
+ title: t('coding_rules.deactivate'),
+ html: tp('coding_rules.deactivate.confirm'),
+ yesHandler: function () {
+ var p = window.process.addBackgroundProcess();
+ return jQuery.ajax({
+ type: 'POST',
+ url: baseUrl + '/api/qualityprofiles/deactivate_rule',
+ data: {
+ profile_key: myProfile.qProfile,
+ rule_key: ruleKey
+ }
+ }).done(function () {
+ window.process.finishBackgroundProcess(p);
+ var newProfile = _.extend({}, myProfile, { severity: undefined });
+ that.model.set({ activeProfile: newProfile });
+ });
+ }
+ });
+ },
+
serializeData: function () {
- var activeProfiles = this.model.get('activeProfiles'),
- activeProfile = _.isArray(activeProfiles) && activeProfiles.length === 1 ? activeProfiles[0] : null,
+ var activeProfile = this.getActiveProfile(),
selectedProfile = this.options.app.state.get('query').qprofile;
if (selectedProfile != null && activeProfile == null) {
activeProfile = selectedProfile;
"DEPRECATED": "Deprecated",
"READY": "Ready"
},
- "characteristics": {
- "UNDERSTANDABILITY": "Maintainability: Understandability",
- "MAINTAINABILITY": "Maintainability",
- "TIME_ZONE_RELATED_PORTABILITY": "Portability: Time zone related portability",
- "READABILITY": "Maintainability: Readability",
- "SECURITY_FEATURES": "Security: Security features",
- "ARCHITECTURE_RELIABILITY": "Reliability: Architecture related reliability",
- "OS_RELATED_PORTABILITY": "Portability: OS related portability",
- "EXCEPTION_HANDLING": "Reliability: Exception handling",
- "LOGIC_CHANGEABILITY": "Changeability: Logic related changeability",
- "SOFTWARE_RELATED_PORTABILITY": "Portability: Software related portability",
- "INPUT_VALIDATION_AND_REPRESENTATION": "Security: Input validation and representation",
- "LANGUAGE_RELATED_PORTABILITY": "Portability: Language related portability",
- "ERRORS": "Security: Errors",
- "SECURITY": "Security",
- "RELIABILITY": "Reliability",
- "PORTABILITY": "Portability",
- "HARDWARE_RELATED_PORTABILITY": "Portability: Hardware related portability",
- "SYNCHRONIZATION_RELIABILITY": "Reliability: Synchronization related reliability",
- "TRANSPORTABILITY": "Reusability: Transportability",
- "COMPILER_RELATED_PORTABILITY": "Portability: Compiler related portability",
- "RESOURCE_RELIABILITY": "Reliability: Resource",
- "CPU_EFFICIENCY": "Efficiency: Processor use",
- "EFFICIENCY": "Efficiency",
- "CHANGEABILITY": "Changeability",
- "DATA_CHANGEABILITY": "Changeability: Data related changeability",
- "API_ABUSE": "Security: API abuse",
- "ARCHITECTURE_CHANGEABILITY": "Changeability: Architecture related changeability",
- "UNIT_TESTS": "Reliability: Unit tests",
- "INSTRUCTION_RELIABILITY": "Reliability: Instruction related reliability",
- "REUSABILITY": "Reusability",
- "MODULARITY": "Reusability: Modularity",
- "UNIT_TESTABILITY": "Testability: Unit level testability",
- "TESTABILITY": "Testability",
- "INTEGRATION_TESTABILITY": "Testability: Integration level testability",
- "NETWORK_USE": "Efficiency: Network use",
- "MEMORY_EFFICIENCY": "Efficiency: Memory use",
- "DATA_RELIABILITY": "Reliability: Data related reliability",
- "FAULT_TOLERANCE": "Reliability: Fault tolerance",
- "LOGIC_RELIABILITY": "Reliability: Logic related reliability"
- }
+ "characteristics": [
+ {
+ "key": "UNDERSTANDABILITY",
+ "name": "Understandability",
+ "parent": "MAINTAINABILITY"
+ },
+ {
+ "key": "MAINTAINABILITY",
+ "name": "Maintainability"
+ },
+ {
+ "key": "TIME_ZONE_RELATED_PORTABILITY",
+ "name": "Time zone related portability",
+ "parent": "PORTABILITY"
+ },
+ {
+ "key": "READABILITY",
+ "name": "Readability",
+ "parent": "MAINTAINABILITY"
+ },
+ {
+ "key": "SECURITY_FEATURES",
+ "name": "Security features",
+ "parent": "SECURITY"
+ },
+ {
+ "key": "ARCHITECTURE_RELIABILITY",
+ "name": "Architecture related reliability",
+ "parent": "RELIABILITY"
+ },
+ {
+ "key": "OS_RELATED_PORTABILITY",
+ "name": "OS related portability",
+ "parent": "PORTABILITY"
+ },
+ {
+ "key": "EXCEPTION_HANDLING",
+ "name": "Exception handling",
+ "parent": "RELIABILITY"
+ },
+ {
+ "key": "LOGIC_CHANGEABILITY",
+ "name": "Logic related changeability",
+ "parent": "CHANGEABILITY"
+ },
+ {
+ "key": "SOFTWARE_RELATED_PORTABILITY",
+ "name": "Software related portability",
+ "parent": "PORTABILITY"
+ },
+ {
+ "key": "INPUT_VALIDATION_AND_REPRESENTATION",
+ "name": "Input validation and representation",
+ "parent": "SECURITY"
+ },
+ {
+ "key": "LANGUAGE_RELATED_PORTABILITY",
+ "name": "Language related portability",
+ "parent": "PORTABILITY"
+ },
+ {
+ "key": "ERRORS",
+ "name": "Errors",
+ "parent": "SECURITY"
+ },
+ {
+ "key": "SECURITY",
+ "name": "Security"
+ },
+ {
+ "key": "RELIABILITY",
+ "name": "Reliability"
+ },
+ {
+ "key": "PORTABILITY",
+ "name": "Portability"
+ },
+ {
+ "key": "HARDWARE_RELATED_PORTABILITY",
+ "name": "Hardware related portability",
+ "parent": "PORTABILITY"
+ },
+ {
+ "key": "SYNCHRONIZATION_RELIABILITY",
+ "name": "Synchronization related reliability",
+ "parent": "RELIABILITY"
+ },
+ {
+ "key": "TRANSPORTABILITY",
+ "name": "Transportability",
+ "parent": "REUSABILITY"
+ },
+ {
+ "key": "COMPILER_RELATED_PORTABILITY",
+ "name": "Compiler related portability",
+ "parent": "PORTABILITY"
+ },
+ {
+ "key": "RESOURCE_RELIABILITY",
+ "name": "Resource",
+ "parent": "RELIABILITY"
+ },
+ {
+ "key": "CPU_EFFICIENCY",
+ "name": "Processor use",
+ "parent": "EFFICIENCY"
+ },
+ {
+ "key": "EFFICIENCY",
+ "name": "Efficiency"
+ },
+ {
+ "key": "CHANGEABILITY",
+ "name": "Changeability"
+ },
+ {
+ "key": "DATA_CHANGEABILITY",
+ "name": "Data related changeability",
+ "parent": "CHANGEABILITY"
+ },
+ {
+ "key": "API_ABUSE",
+ "name": "API abuse",
+ "parent": "SECURITY"
+ },
+ {
+ "key": "ARCHITECTURE_CHANGEABILITY",
+ "name": "Architecture related changeability",
+ "parent": "CHANGEABILITY"
+ },
+ {
+ "key": "UNIT_TESTS",
+ "name": "Unit tests",
+ "parent": "RELIABILITY"
+ },
+ {
+ "key": "INSTRUCTION_RELIABILITY",
+ "name": "Instruction related reliability",
+ "parent": "RELIABILITY"
+ },
+ {
+ "key": "REUSABILITY",
+ "name": "Reusability"
+ },
+ {
+ "key": "MODULARITY",
+ "name": "Modularity",
+ "parent": "REUSABILITY"
+ },
+ {
+ "key": "UNIT_TESTABILITY",
+ "name": "Unit level testability",
+ "parent": "TESTABILITY"
+ },
+ {
+ "key": "TESTABILITY",
+ "name": "Testability"
+ },
+ {
+ "key": "INTEGRATION_TESTABILITY",
+ "name": "Integration level testability",
+ "parent": "TESTABILITY"
+ },
+ {
+ "key": "NETWORK_USE",
+ "name": "Network use",
+ "parent": "EFFICIENCY"
+ },
+ {
+ "key": "MEMORY_EFFICIENCY",
+ "name": "Memory use",
+ "parent": "EFFICIENCY"
+ },
+ {
+ "key": "DATA_RELIABILITY",
+ "name": "Data related reliability",
+ "parent": "RELIABILITY"
+ },
+ {
+ "key": "FAULT_TOLERANCE",
+ "name": "Fault tolerance",
+ "parent": "RELIABILITY"
+ },
+ {
+ "key": "LOGIC_RELIABILITY",
+ "name": "Logic related reliability",
+ "parent": "RELIABILITY"
+ }
+ ]
}