]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6156 update the search input to use new WS
authorStas Vilchik <vilchiks@gmail.com>
Fri, 6 Feb 2015 15:25:21 +0000 (16:25 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 11 Feb 2015 16:27:14 +0000 (17:27 +0100)
server/sonar-web/src/main/coffee/issues/app-context.coffee
server/sonar-web/src/main/coffee/issues/facets/project-facet.coffee

index be0bf3815d0e744911ac838701ea7988f9396166..e2d9d32e95bcada61997bb0a81d660776579b143 100644 (file)
@@ -63,6 +63,7 @@ requirejs [
     @state = new State
       isContext: true,
       contextQuery: @getContextQuery()
+      contextComponentUuid: window.config.resource
       contextComponentName: window.config.resourceName
       contextComponentQualifier: window.config.resourceQualifier
     @updateContextFacets()
index 76875d2e6e14f7d4f2d4748d28a430382d4bd5c9..3d8588683e61c4d36e269134523cc5ecc952103e 100644 (file)
@@ -8,7 +8,41 @@ define [
   class extends CustomValuesFacet
 
     getUrl: ->
-      "#{baseUrl}/api/resources/search?f=s2&q=TRK&display_uuid=true"
+      q = @options.app.state.get 'contextComponentQualifier'
+      if q == 'VW' || q == 'SVW'
+        "#{baseUrl}/api/components/search"
+      else
+        "#{baseUrl}/api/resources/search?f=s2&q=TRK&display_uuid=true"
+
+
+    prepareSearch: ->
+      q = @options.app.state.get 'contextComponentQualifier'
+      if q == 'VW' || q == 'SVW'
+        @prepareSearchForViews()
+      else super
+
+
+    prepareSearchForViews: ->
+      componentUuid = this.options.app.state.get 'contextComponentUuid'
+      @$('.js-custom-value').select2
+        placeholder: 'Search...'
+        minimumInputLength: 2
+        allowClear: false
+        formatNoMatches: -> t 'select2.noMatches'
+        formatSearching: -> t 'select2.searching'
+        formatInputTooShort: -> tp 'select2.tooShort', 2
+        width: '100%'
+        ajax:
+          quietMillis: 300
+          url: @getUrl()
+          data: (term, page) ->
+            q: term
+            componentUuid: componentUuid
+            p: page
+            ps: 25
+          results: (data) ->
+            more: data.p * data.ps < data.total,
+            results: data.components.map (c) -> id: c.uuid, text: c.name
 
 
     getValuesWithLabels: ->