]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 Improve QP filter
authorStas Vilchik <vilchiks@gmail.com>
Mon, 24 Mar 2014 13:25:10 +0000 (19:25 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 24 Mar 2014 13:25:21 +0000 (19:25 +0600)
sonar-server/src/main/webapp/coffee/coding-rules/app.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/filters/activation-filter-view.coffee
sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee
sonar-server/src/main/webapp/less/coding-rules.less
sonar-server/src/main/webapp/less/navigator/filters.less
sonar-server/src/main/webapp/less/variables.less
sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs
sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail.hbs

index 4a05d84b73538409d52b21196ea4fb0c9758343d..b5029b0f577e974c17ae69035cf580e883da15c6 100644 (file)
@@ -249,7 +249,7 @@ requirejs [
       property: 'activation'
       type: ActivationFilterView
       enabled: false
-      optional: true
+      optional: false
       multiple: false
       qualityProfileFilter: @qualityProfileFilter
       choices:
index 53709d9de9552016523d738320a11bf1b73d29f6..2f3ec432cd4791bcae5f58533ca964ba9cfe5a5a 100644 (file)
@@ -12,81 +12,13 @@ define [
 
 
     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()
@@ -103,5 +35,4 @@ define [
     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
index 8a4a11d831e16f13284c84b0e0320af619c5c82a..896ee64c050f2ab34ee6fa96349cdaee4eb56b16 100644 (file)
@@ -1,13 +1,41 @@
 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
index ab1c4bd0c93901fe7bd4ceab1e64e835c6c76467..eff55a9e61856c505d18778efbb5b5a1f6bbf48d 100644 (file)
@@ -16,7 +16,12 @@ define [
     initialize: ->
       super
       @choices = new QualityProfileSuggestions
-      @listenTo @model, 'change:value', @updateParentQualityProfile
+      @listenTo @model, 'change:value', @onValueChange
+
+
+    onValueChange: ->
+      @updateParentQualityProfile()
+      @highlightContext()
 
 
     updateParentQualityProfile: ->
@@ -27,6 +32,11 @@ define [
         @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'
index c5971b0e664f43abccc4d863e3b505717c71396e..fb84e4f37816251445f65f7fa259caacd1c0251a 100644 (file)
@@ -36,6 +36,9 @@
 
 .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;
@@ -53,6 +56,8 @@
   margin-right: @navigatorPadding;
 
   .limited {
+    display: inline-block;
+    vertical-align: middle;
     max-width: 180px;
     white-space: nowrap;
     overflow: hidden;
@@ -60,7 +65,7 @@
   }
 
   .limited-big {
-    width: 480px;
+    max-width: 480px;
   }
 }
 
index dc9868f1f97c5377320be87ddd779367ebc8feb1..fbfdf0e3b13cafef61872727bd252061246bf6bf 100644 (file)
   opacity: 0.5;
 }
 
+.navigator-filter-context {
+  background-color: @contextBackground;
+  border-color: @contextBorder;
+}
+
 .navigator-filter-label {
   display: inline-block;
   vertical-align: middle;
index b43675bf36c662d5664d8aaa275a43255b8d8a72..ab56248686b80ef80150331758a475509a3f9a53 100644 (file)
@@ -25,7 +25,8 @@
 @orange: #f90;
 
 @highlighted: @blue;
-
+@contextBackground: lighten(@green, 40%);
+@contextBorder: lighten(@green, 20%);
 
 
 /*
index b3962380591d2fee9ae2a4319a2070225472134c..b1633fcfaa53c65f93a445a55f1daa21733a2d70 100644 (file)
@@ -32,7 +32,7 @@
 
     <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'}}
index 05b9d52bcb6030e0bc746861eb3ee57d1484985f..4b36a41182b2e3ecb5d0e308f1963a7c9cc7c078 100644 (file)
@@ -1,5 +1,5 @@
 {{#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>