]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 Update QP section
authorStas Vilchik <vilchiks@gmail.com>
Mon, 24 Mar 2014 14:03:02 +0000 (20:03 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 24 Mar 2014 14:03:13 +0000 (20:03 +0600)
sonar-server/src/main/webapp/coffee/coding-rules/mockjax.coffee
sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee
sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profiles-view.coffee
sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-view.coffee
sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-list-item-view.coffee
sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
sonar-server/src/main/webapp/templates/coding-rules/coding-rules-quality-profile-activation.hbs

index acefc6dd9f108fc7b68b4bd6c992f5256ac31f76..2163fac2a64d843c14cf8f07086192d13783fcc8 100644 (file)
@@ -97,6 +97,7 @@ define ['jquery.mockjax'], ->
         'edit': 'Edit'
         'markdown.helplink': 'Markdown Help'
         'moreCriteria': '+ More Criteria'
+        'save': 'Save'
         'search_verb': 'Search'
         'severity': 'Severity'
         'update': 'Update'
@@ -115,6 +116,7 @@ define ['jquery.mockjax'], ->
         'coding_rules.bulk_change': 'Bulk Change'
         'coding_rules.change_severity': 'Change Severity'
         'coding_rules.change_severity_in': 'Change Severity In'
+        'coding_rules.change_details': 'Change Details of Quality Profile'
         'coding_rules.extend_description': 'Extend Description'
         'coding_rules.deactivate_in': 'Deactivate In'
         'coding_rules.deactivate': 'Deactivate'
@@ -222,7 +224,6 @@ define ['jquery.mockjax'], ->
         key: 'S1190'
         parameters: [
           { key: 'someParameter', type: 'INT', default: 4, description: 'Some parameter description' }
-          { key: 'boolParameter', type: 'BOOL', description: 'Bool parameter description' }
         ]
         description: '''
             <p>
index 2f3ec432cd4791bcae5f58533ca964ba9cfe5a5a..063b8378929db161c31b6c5c957b8ef023036931 100644 (file)
@@ -6,7 +6,7 @@ define [
   Templates
 ) ->
 
-  class CodingRulesDetailQualityProfilesView extends Marionette.ItemView
+  class CodingRulesDetailQualityProfileView extends Marionette.ItemView
     className: 'coding-rules-detail-quality-profile'
     template: Templates['coding-rules-detail-quality-profile']
 
@@ -15,6 +15,15 @@ define [
       change: '.coding-rules-detail-quality-profile-change'
 
 
+    events:
+      'click @ui.change': 'change'
+
+
+    change: ->
+      @options.app.codingRulesQualityProfileActivationView.model = @model
+      @options.app.codingRulesQualityProfileActivationView.show()
+
+
     enableUpdate: ->
       @ui.update.prop 'disabled', false
 
index 0b6f7ec680e8a002e87140c11ad38129a19b456e..71b0b311062683f746b3084db20b28b22d94ff87 100644 (file)
@@ -10,4 +10,5 @@ define [
     itemView: CodingRulesDetailQualityProfileView
 
     itemViewOptions: ->
+      app: @options.app
       qualityProfiles: @collection
\ No newline at end of file
index 641748825c9c4502967540013d5af14a898735ef..4cf361c7a5cfe46b7ed92c5e02cdc33dbd95f246 100644 (file)
@@ -33,7 +33,8 @@ define [
       extendDescriptionSpinner: '#coding-rules-detail-extend-description-spinner'
       cancelExtendDescription: '#coding-rules-detail-extend-description-cancel'
 
-      qualityProfileActivate: '#coding-rules-quality-profile-activate'
+      activateQualityProfile: '#coding-rules-quality-profile-activate'
+      changeQualityProfile: '.coding-rules-detail-quality-profile-update'
 
 
     events:
@@ -44,11 +45,13 @@ define [
       'click @ui.cancelExtendDescription': 'hideExtendDescriptionForm'
       'click @ui.extendDescriptionSubmit': 'submitExtendDescription'
 
-      'click @ui.qualityProfileActivate': 'activateQualityProfile'
+      'click @ui.activateQualityProfile': 'activateQualityProfile'
+      'click @ui.changeQualityProfile': 'changeQualityProfile'
 
 
     initialize: (options) ->
       @qualityProfilesView = new CodingRulesDetailQualityProfilesView
+        app: @options.app
         collection: new Backbone.Collection options.model.get 'qualityProfiles'
 
 
@@ -104,16 +107,25 @@ define [
         @render()
 
 
+    getContextQualilyProfile: ->
+      contextQualityProfile = @options.app.getQualityProfile()
+      _.findWhere @model.get('qualityProfiles'), key: contextQualityProfile
+
+
     activateQualityProfile: ->
-      @options.app.codingRulesQualityProfileActivationView.model = @model
+      @options.app.codingRulesQualityProfileActivationView.model = null
+      @options.app.codingRulesQualityProfileActivationView.show()
+
+
+    changeQualityProfile: ->
+      @options.app.codingRulesQualityProfileActivationView.model = new Backbone.Model @getContextQualilyProfile()
       @options.app.codingRulesQualityProfileActivationView.show()
 
 
     serializeData: ->
       contextQualityProfile = @options.app.getQualityProfile()
-      qualityProfile = _.findWhere @model.get('qualityProfiles'), key: contextQualityProfile
 
       _.extend super,
         contextQualityProfile: contextQualityProfile
         contextQualityProfileName: @options.app.qualityProfileFilter.view.renderValue()
-        qualityProfile: qualityProfile
\ No newline at end of file
+        qualityProfile: @getContextQualilyProfile()
\ No newline at end of file
index 5331efec1e7babbc2138ab6702c230521d78e603..69a9e5fdaff75d845d0be5c7ee35c33c8a339da4 100644 (file)
@@ -27,6 +27,7 @@ define [
         url: "#{baseUrl}/api/codingrules/show"
       .done (r) =>
         @model.set r.codingrule
+        @options.app.codingRulesQualityProfileActivationView.rule = @model
         detailView = new CodingRulesDetailView
           app: @options.app
           model: @model
index f314464e3d79513942bf6faa205e0aaec81e2b90..70aa55a5dafa9b746cecaa4730a74136a2205432 100644 (file)
@@ -52,7 +52,8 @@ define [
         return state.text unless state.id
         "<i class='icon-severity-#{state.id.toLowerCase()}'></i> #{state.text}"
 
-      @ui.qualityProfileSeverity.val @model.get 'severity'
+      severity = if @model then @model.get 'severity' else @rule.get 'severity'
+      @ui.qualityProfileSeverity.val severity
       @ui.qualityProfileSeverity.select2
         width: '250px'
         minimumResultsForSearch: 999
@@ -71,10 +72,14 @@ define [
 
     getAvailableQualityProfiles: ->
       _.reject @options.app.qualityProfiles, (profile) =>
-        _.findWhere @model.get('qualityProfiles'), key: profile.key
+        _.findWhere @rule.get('qualityProfiles'), key: profile.key
 
 
     serializeData: ->
+      parameters = if @model then @model.get('parameters') else @rule.get('parameters')
+
       _.extend super,
+        rule: @rule.toJSON()
+        parameters: parameters
         qualityProfiles: @getAvailableQualityProfiles()
         severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']
index 0360cab6f3b01714301e619234e986cdb3626fb6..cfd8d6df01d0085dabafc8cf90bba491abad177f 100644 (file)
@@ -1,6 +1,10 @@
 <form>
   <div class="modal-head">
-    <h2>{{t 'coding_rules.activate_in_quality_profile'}}</h2>
+    {{#if key}}
+      <h2>{{t 'coding_rules.change_details'}}</h2>
+    {{else}}
+      <h2>{{t 'coding_rules.activate_in_quality_profile'}}</h2>
+    {{/if}}
   </div>
 
   <div class="modal-body">
       <tr class="property">
         <th><h3>{{t 'coding_rules.quality_profile'}}</h3></th>
         <td>
-          <select id="coding-rules-quality-profile-activation-select">
-            {{#each qualityProfiles}}
-              <option value="{{key}}">{{name}}</option>
-            {{/each}}
-          </select>
+          {{#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">
@@ -31,7 +39,7 @@
         <tr class="property">
           <th><h3>{{key}}</h3></th>
           <td>
-            <input type="text" {{#if default}}value="{{default}}"{{/if}}>
+            <input type="text" value="{{value}}" placeholder="{{default}}">
             <div class="note">{{description}}</div>
             {{#if extra}}
               <div class="note">{{extra}}</div>
@@ -43,7 +51,9 @@
   </div>
 
   <div class="modal-foot">
-    <button id="coding-rules-quality-profile-activation-activate">{{t 'coding_rules.activate'}}</button>
+    <button id="coding-rules-quality-profile-activation-activate">
+      {{#if key}}{{t 'save'}}{{else}}{{t 'coding_rules.activate'}}{{/if}}
+    </button>
     <a id="coding-rules-quality-profile-activation-cancel" class="action">{{t 'cancel'}}</a>
   </div>
 </form>
\ No newline at end of file