diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-03-17 15:35:50 +0600 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-03-17 15:35:50 +0600 |
commit | e82196bec265eb030e9fadfa21ca35877cf568b1 (patch) | |
tree | ca251cd324babc51bd853b61880f195f95c6aab5 /sonar-server/src/main/webapp/javascripts | |
parent | 6212cee9c5e178809f25b9cd9a506167953de9c2 (diff) | |
download | sonarqube-e82196bec265eb030e9fadfa21ca35877cf568b1.tar.gz sonarqube-e82196bec265eb030e9fadfa21ca35877cf568b1.zip |
SONAR-5007 Display details of a rule and actions relating to it
Diffstat (limited to 'sonar-server/src/main/webapp/javascripts')
4 files changed, 189 insertions, 1 deletions
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee index 0a03ca2ce21..0b79a6bb09a 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee @@ -48,6 +48,8 @@ define ['jquery.mockjax'], -> 'apply': 'Apply' 'bulk_change': 'Bulk Change' 'cancel': 'Cancel' + 'change': 'Change' + 'done': 'Done' 'moreCriteria': '+ More Criteria' 'search_verb': 'Search' 'update': 'Update' @@ -60,6 +62,7 @@ define ['jquery.mockjax'], -> 'coding_rules.activate_quality_profile': 'Activate Quality Profile' 'coding_rules.bulk_change': 'Bulk Change' + 'coding_rules.extend_description': 'Extend Description' 'coding_rules.deactivate_quality_profile': 'Deactivate' 'coding_rules.found': 'Found' 'coding_rules.new_search': 'New Search' @@ -69,6 +72,7 @@ define ['jquery.mockjax'], -> 'coding_rules.page': 'Coding Rules' 'coding_rules.quality_profiles': 'Quality Profiles' 'coding_rules._rules': 'rule(s)' + 'coding_rules.select_tag': 'Select Tag' 'coding_rules.filters.availableSince': 'Available Since' 'coding_rules.filters.description': 'Description' @@ -172,6 +176,7 @@ define ['jquery.mockjax'], -> public int[][] getMatrix() { /* ... */ } // Compliant </pre>''' extra: '''<p>This note is here <b>only for test purposes</b>.</p>''' + extraRaw: '''This note is here *only for test purposes*.''' qualityProfiles: [ { @@ -198,11 +203,24 @@ define ['jquery.mockjax'], -> + # POST /api/codingrules/extend_description + jQuery.mockjax + url: "#{baseUrl}/api/codingrules/extend_description" + responseText: JSON.stringify + extra: '''<p>This note is here <i>only for test purposes</i>.</p>''' + extraRaw: '''This note is here *only for test purposes*.''' + + # POST /api/codingrules/bulk_change jQuery.mockjax url: "#{baseUrl}/api/codingrules/bulk_change" + # POST /api/codingrules/set_tags + jQuery.mockjax + url: "#{baseUrl}/api/codingrules/set_tags" + + # GET /api/qualityprofiles/list jQuery.mockjax url: "#{baseUrl}/api/qualityprofiles/list" diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js index f1c82651d74..623c2a80ca9 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js @@ -64,6 +64,8 @@ 'apply': 'Apply', 'bulk_change': 'Bulk Change', 'cancel': 'Cancel', + 'change': 'Change', + 'done': 'Done', 'moreCriteria': '+ More Criteria', 'search_verb': 'Search', 'update': 'Update', @@ -74,6 +76,7 @@ 'severity.INFO': 'Info', 'coding_rules.activate_quality_profile': 'Activate Quality Profile', 'coding_rules.bulk_change': 'Bulk Change', + 'coding_rules.extend_description': 'Extend Description', 'coding_rules.deactivate_quality_profile': 'Deactivate', 'coding_rules.found': 'Found', 'coding_rules.new_search': 'New Search', @@ -83,6 +86,7 @@ 'coding_rules.page': 'Coding Rules', 'coding_rules.quality_profiles': 'Quality Profiles', 'coding_rules._rules': 'rule(s)', + 'coding_rules.select_tag': 'Select Tag', 'coding_rules.filters.availableSince': 'Available Since', 'coding_rules.filters.description': 'Description', 'coding_rules.filters.in_quality_profile': 'In Quality Profile', @@ -167,6 +171,7 @@ ], description: '<p>\nAccording to the Java Language Specification:\n</p>\n\n<pre>For compatibility with older versions of the Java SE platform,\nthe declaration of a method that returns an array is allowed to place (some or all of)\nthe empty bracket pairs that form the declaration of the array type after\nthe formal parameter list. This obsolescent syntax should not be used in new code.\n</pre>\n\n<p>The following code snippet illustrates this rule:</p>\n\n<pre>public int getVector()[] { /* ... */ } // Non-Compliant\n\npublic int[] getVector() { /* ... */ } // Compliant\n\npublic int[] getMatrix()[] { /* ... */ } // Non-Compliant\n\npublic int[][] getMatrix() { /* ... */ } // Compliant\n</pre>', extra: '<p>This note is here <b>only for test purposes</b>.</p>', + extraRaw: 'This note is here *only for test purposes*.', qualityProfiles: [ { name: 'SonarWay', @@ -196,9 +201,19 @@ }) }); jQuery.mockjax({ + url: "" + baseUrl + "/api/codingrules/extend_description", + responseText: JSON.stringify({ + extra: '<p>This note is here <i>only for test purposes</i>.</p>', + extraRaw: 'This note is here *only for test purposes*.' + }) + }); + jQuery.mockjax({ url: "" + baseUrl + "/api/codingrules/bulk_change" }); jQuery.mockjax({ + url: "" + baseUrl + "/api/codingrules/set_tags" + }); + jQuery.mockjax({ url: "" + baseUrl + "/api/qualityprofiles/list", responseText: JSON.stringify({ more: false, diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee index 9ff525e9a62..2c0e74937e3 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee @@ -2,13 +2,86 @@ define [ 'backbone.marionette', 'common/handlebars-extensions' ], ( - Marionette, + Marionette ) -> class CodingRulesDetailView extends Marionette.ItemView template: getTemplate '#coding-rules-detail-template' + ui: + tagsChange: '.coding-rules-detail-tags-change' + tagInput: '.coding-rules-detail-tag-input' + tagsEdit: '.coding-rules-detail-tag-edit' + tagsEditDone: '.coding-rules-detail-tag-edit-done' + tagsList: '.coding-rules-detail-tag-list' + + descriptionExtra: '#coding-rules-detail-description-extra' + extendDescriptionLink: '#coding-rules-detail-extend-description' + extendDescriptionForm: '#coding-rules-detail-extend-description-form' + extendDescriptionSubmit: '#coding-rules-detail-extend-description-submit' + extendDescriptionText: '#coding-rules-detail-extend-description-text' + extendDescriptionSpinner: '#coding-rules-detail-extend-description-spinner' + cancelExtendDescription: '#coding-rules-detail-extend-description-cancel' + + + events: + 'click @ui.tagsChange': 'changeTags' + 'click @ui.tagsEditDone': 'editDone' + + 'click @ui.extendDescriptionLink': 'showExtendDescriptionForm' + 'click @ui.cancelExtendDescription': 'hideExtendDescriptionForm' + 'click @ui.extendDescriptionSubmit': 'submitExtendDescription' + + onRender: -> + @ui.tagInput.select2 + tags: _.difference @options.app.tags, @model.get 'tags' + width: '500px' + @ui.tagsEdit.hide() + + @ui.extendDescriptionForm.hide() + @ui.extendDescriptionSpinner.hide() + qp = @options.app.getActiveQualityProfile() @$('.coding-rules-detail-quality-profile').first().addClass 'active' if qp? + + + changeTags: -> + @ui.tagsEdit.show() + @ui.tagsList.hide() + + + editDone: -> + @ui.tagsEdit.html '<i class="spinner"></i>' + tags = @ui.tagInput.val() + jQuery.ajax + type: 'POST' + url: "#{baseUrl}/api/codingrules/set_tags" + data: tags: tags + .done => + @model.set 'tags', tags.split ',' + @render() + + + showExtendDescriptionForm: -> + @ui.descriptionExtra.hide() + @ui.extendDescriptionForm.show() + + + hideExtendDescriptionForm: -> + @ui.descriptionExtra.show() + @ui.extendDescriptionForm.hide() + + + submitExtendDescription: -> + @ui.extendDescriptionForm.hide() + @ui.extendDescriptionSpinner.show() + jQuery.ajax + type: 'POST' + url: "#{baseUrl}/api/codingrules/extend_description" + dataType: 'json' + data: text: @ui.extendDescriptionText.val() + .done (r) => + @model.set extra: r.extra, extraRaw: r.extraRaw + @render()
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js index ae0db796904..9e1a0c335ff 100644 --- a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js +++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js @@ -15,14 +15,96 @@ CodingRulesDetailView.prototype.template = getTemplate('#coding-rules-detail-template'); + CodingRulesDetailView.prototype.ui = { + tagsChange: '.coding-rules-detail-tags-change', + tagInput: '.coding-rules-detail-tag-input', + tagsEdit: '.coding-rules-detail-tag-edit', + tagsEditDone: '.coding-rules-detail-tag-edit-done', + tagsList: '.coding-rules-detail-tag-list', + descriptionExtra: '#coding-rules-detail-description-extra', + extendDescriptionLink: '#coding-rules-detail-extend-description', + extendDescriptionForm: '#coding-rules-detail-extend-description-form', + extendDescriptionSubmit: '#coding-rules-detail-extend-description-submit', + extendDescriptionText: '#coding-rules-detail-extend-description-text', + extendDescriptionSpinner: '#coding-rules-detail-extend-description-spinner', + cancelExtendDescription: '#coding-rules-detail-extend-description-cancel' + }; + + CodingRulesDetailView.prototype.events = { + 'click @ui.tagsChange': 'changeTags', + 'click @ui.tagsEditDone': 'editDone', + 'click @ui.extendDescriptionLink': 'showExtendDescriptionForm', + 'click @ui.cancelExtendDescription': 'hideExtendDescriptionForm', + 'click @ui.extendDescriptionSubmit': 'submitExtendDescription' + }; + CodingRulesDetailView.prototype.onRender = function() { var qp; + this.ui.tagInput.select2({ + tags: _.difference(this.options.app.tags, this.model.get('tags')), + width: '500px' + }); + this.ui.tagsEdit.hide(); + this.ui.extendDescriptionForm.hide(); + this.ui.extendDescriptionSpinner.hide(); qp = this.options.app.getActiveQualityProfile(); if (qp != null) { return this.$('.coding-rules-detail-quality-profile').first().addClass('active'); } }; + CodingRulesDetailView.prototype.changeTags = function() { + this.ui.tagsEdit.show(); + return this.ui.tagsList.hide(); + }; + + CodingRulesDetailView.prototype.editDone = function() { + var tags, + _this = this; + this.ui.tagsEdit.html('<i class="spinner"></i>'); + tags = this.ui.tagInput.val(); + return jQuery.ajax({ + type: 'POST', + url: "" + baseUrl + "/api/codingrules/set_tags", + data: { + tags: tags + } + }).done(function() { + _this.model.set('tags', tags.split(',')); + return _this.render(); + }); + }; + + CodingRulesDetailView.prototype.showExtendDescriptionForm = function() { + this.ui.descriptionExtra.hide(); + return this.ui.extendDescriptionForm.show(); + }; + + CodingRulesDetailView.prototype.hideExtendDescriptionForm = function() { + this.ui.descriptionExtra.show(); + return this.ui.extendDescriptionForm.hide(); + }; + + CodingRulesDetailView.prototype.submitExtendDescription = function() { + var _this = this; + this.ui.extendDescriptionForm.hide(); + this.ui.extendDescriptionSpinner.show(); + return jQuery.ajax({ + type: 'POST', + url: "" + baseUrl + "/api/codingrules/extend_description", + dataType: 'json', + data: { + text: this.ui.extendDescriptionText.val() + } + }).done(function(r) { + _this.model.set({ + extra: r.extra, + extraRaw: r.extraRaw + }); + return _this.render(); + }); + }; + return CodingRulesDetailView; })(Marionette.ItemView); |