diff options
4 files changed, 60 insertions, 2 deletions
diff --git a/server/sonar-web/src/main/coffee/issues/facets/project-facet.coffee b/server/sonar-web/src/main/coffee/issues/facets/project-facet.coffee index 4b4495000ed..a211f3d9571 100644 --- a/server/sonar-web/src/main/coffee/issues/facets/project-facet.coffee +++ b/server/sonar-web/src/main/coffee/issues/facets/project-facet.coffee @@ -1,11 +1,48 @@ define [ 'issues/facets/base-facet' + 'templates/issues' ], ( BaseFacet + Templates ) -> class extends BaseFacet + template: Templates['issues-project-facet'] + + + events: -> + _.extend super, + 'change .js-issues-custom-value': 'addCustomValue' + + + onRender: -> + super + @$('.js-issues-custom-value').select2 + placeholder: 'Add project' + minimumInputLength: 2 + allowClear: false + formatNoMatches: -> t 'select2.noMatches' + formatSearching: -> t 'select2.searching' + formatInputTooShort: -> tp 'select2.tooShort', 2 + width: '100%' + ajax: + quietMillis: 300 + url: "#{baseUrl}/api/resources/search?f=s2&q=TRK&display_uuid=true" + data: (term, page) -> { s: term, p: page } + results: (data) -> { more: data.more, results: data.results } + + + addCustomValue: -> + property = @model.get 'property' + customValue = @$('.js-issues-custom-value').select2 'val' + value = @getValue() + value += ',' if value.length > 0 + value += customValue + obj = {} + obj[property] = value + @options.app.state.updateFilter obj + getValuesWithLabels: -> values = @model.getValues() diff --git a/server/sonar-web/src/main/hbs/issues/facets/issues-project-facet.hbs b/server/sonar-web/src/main/hbs/issues/facets/issues-project-facet.hbs new file mode 100644 index 00000000000..af181c52f8b --- /dev/null +++ b/server/sonar-web/src/main/hbs/issues/facets/issues-project-facet.hbs @@ -0,0 +1,14 @@ +{{> '_issues-facet-header'}} + +<div class="issues-facet-list"> + <div class="issues-facet-custom-value"> + <input type="hidden" class="js-issues-custom-value"> + </div> + + {{#each values}} + <a class="facet issues-facet js-issues-facet" data-value="{{val}}"> + <span class="facet-name">{{default label val}}</span> + <span class="facet-stat">{{count}}</span> + </a> + {{/each}} +</div> diff --git a/server/sonar-web/src/main/less/issues.less b/server/sonar-web/src/main/less/issues.less index 20634f1d5c0..a2437f077a6 100644 --- a/server/sonar-web/src/main/less/issues.less +++ b/server/sonar-web/src/main/less/issues.less @@ -126,6 +126,12 @@ padding: 0 10px 16px; } +.issues-facet-custom-value { + margin-right: 22px; + padding: 0 0 5px; + font-size: @baseFontSize; +} + .issues-facet-input { width: @sideWidth * 0.4; // .box-sizing(border-box); diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb index 1bca9a153f1..263be493f14 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb @@ -30,6 +30,7 @@ class Api::ResourcesController < Api::ApiController page=(params[:p] ? params[:p].to_i : 1) page_size=(params[:ps] ? params[:ps].to_i : 10) display_key=params[:display_key]||false + display_uuid=params[:display_uuid]||false if params[:q] qualifiers=params[:q].split(',') elsif params[:qp] @@ -70,7 +71,7 @@ class Api::ResourcesController < Api::ApiController resources=[] unless resource_ids.empty? - resources=Project.all(:select => 'id,qualifier,name,long_name,kee', :conditions => ['id in (?) and enabled=?', resource_ids, true]) + resources=Project.all(:select => 'id,qualifier,name,long_name,kee,uuid', :conditions => ['id in (?) and enabled=?', resource_ids, true]) end if select2_format @@ -85,7 +86,7 @@ class Api::ResourcesController < Api::ApiController else json = { :more => (page * page_size)<total, - :results => resources.map { |resource| {:id => display_key ? resource.key : resource.id, :text => resource.name(true)} } + :results => resources.map { |resource| {:id => display_uuid ? resource.uuid : (display_key ? resource.key : resource.id), :text => resource.name(true)} } } end else |