diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2015-05-12 13:32:35 +0200 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2015-05-18 10:06:54 +0200 |
commit | 6558440736ca0053d98aa289c92563181dc4be80 (patch) | |
tree | a2b2ab441ebfdb9646e56cb81a16091e91464d99 /server | |
parent | 5a92a8bd1b28dde9f2a1f50af53dcc03cec383ab (diff) | |
download | sonarqube-6558440736ca0053d98aa289c92563181dc4be80.tar.gz sonarqube-6558440736ca0053d98aa289c92563181dc4be80.zip |
SONAR-6520 Replace call api/users/search2 instead of api/users/search on frontend
Diffstat (limited to 'server')
6 files changed, 67 insertions, 16 deletions
diff --git a/server/sonar-web/src/main/coffee/issue/views/assign-form-view.coffee b/server/sonar-web/src/main/coffee/issue/views/assign-form-view.coffee index e22f76bdc01..f32d5879224 100644 --- a/server/sonar-web/src/main/coffee/issue/views/assign-form-view.coffee +++ b/server/sonar-web/src/main/coffee/issue/views/assign-form-view.coffee @@ -119,7 +119,7 @@ define [ search: (query) -> if query.length > 1 - $.get "#{baseUrl}/api/users/search", s: query + $.get "#{baseUrl}/api/users/search2", q: query .done (data) => @resetAssignees data.users else diff --git a/server/sonar-web/src/main/coffee/issues/facets/assignee-facet.coffee b/server/sonar-web/src/main/coffee/issues/facets/assignee-facet.coffee index 673cb5db44c..dfeb669741c 100644 --- a/server/sonar-web/src/main/coffee/issues/facets/assignee-facet.coffee +++ b/server/sonar-web/src/main/coffee/issues/facets/assignee-facet.coffee @@ -33,8 +33,18 @@ define [ getUrl: -> - "#{baseUrl}/api/users/search?f=s2" - + "#{baseUrl}/api/users/search2" + + prepareAjaxSearch: -> + quietMillis: 300 + url: @getUrl() + data: (term, page) -> { q: term, p: page } + results: (data) -> + more: false, + results: _.map(data.users, (user) -> + id: user.login, + text: "#{user.name} (#{user.login})" + ) onRender: -> super diff --git a/server/sonar-web/src/main/coffee/issues/facets/custom-values-facet.coffee b/server/sonar-web/src/main/coffee/issues/facets/custom-values-facet.coffee index ce07db1db43..2cb99e56876 100644 --- a/server/sonar-web/src/main/coffee/issues/facets/custom-values-facet.coffee +++ b/server/sonar-web/src/main/coffee/issues/facets/custom-values-facet.coffee @@ -52,12 +52,13 @@ define [ formatSearching: -> t 'select2.searching' formatInputTooShort: -> tp 'select2.tooShort', 2 width: '100%' - ajax: - quietMillis: 300 - url: @getUrl() - data: (term, page) -> { s: term, p: page } - results: (data) -> { more: data.more, results: data.results } + ajax: @prepareAjaxSearch() + prepareAjaxSearch: -> + quietMillis: 300 + url: @getUrl() + data: (term, page) -> { s: term, p: page } + results: (data) -> { more: data.more, results: data.results } addCustomValue: -> property = @model.get 'property' diff --git a/server/sonar-web/src/main/coffee/issues/facets/reporter-facet.coffee b/server/sonar-web/src/main/coffee/issues/facets/reporter-facet.coffee index 0de88bb7ba8..af5be0934e7 100644 --- a/server/sonar-web/src/main/coffee/issues/facets/reporter-facet.coffee +++ b/server/sonar-web/src/main/coffee/issues/facets/reporter-facet.coffee @@ -28,8 +28,18 @@ define [ class extends CustomValuesFacet getUrl: -> - "#{baseUrl}/api/users/search?f=s2" - + "#{baseUrl}/api/users/search2" + + prepareAjaxSearch: -> + quietMillis: 300 + url: @getUrl() + data: (term, page) -> { q: term, p: page } + results: (data) -> + more: false, + results: _.map(data.users, (user) -> + id: user.login, + text: "#{user.name} (#{user.login})" + ) getValuesWithLabels: -> values = @model.getValues() diff --git a/server/sonar-web/src/main/js/navigator/filters/ajax-select-filters.js b/server/sonar-web/src/main/js/navigator/filters/ajax-select-filters.js index db4391eb10b..3f240b0c33e 100644 --- a/server/sonar-web/src/main/js/navigator/filters/ajax-select-filters.js +++ b/server/sonar-web/src/main/js/navigator/filters/ajax-select-filters.js @@ -68,7 +68,17 @@ define([ var UserSuggestions = Suggestions.extend({ url: function() { - return baseUrl + '/api/users/search?f=s2'; + return baseUrl + '/api/users/search2'; + }, + + parse: function(response) { + this.more = false; + this.results = _.map(response.users, function(user) { + return { + id: user.login, + text: user.name + ' (' + user.login + ')' + }; + }); } }); @@ -434,9 +444,9 @@ define([ var that = this; return $j .ajax({ - url: baseUrl + '/api/users/search', + url: baseUrl + '/api/users/search2', type: 'GET', - data: { logins: v } + data: { q: v } }) .done(function (r) { that.choices.add(new Backbone.Model({ @@ -467,9 +477,9 @@ define([ var that = this; return $j .ajax({ - url: baseUrl + '/api/users/search', + url: baseUrl + '/api/users/search2', type: 'GET', - data: { logins: v } + data: { q: v } }) .done(function (r) { that.choices.add(new Backbone.Model({ diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index ff006badfd0..0c156479c54 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -723,8 +723,28 @@ module ApplicationHelper # * <tt>:select2_options</tt> - hash of select2 options # def user_select_tag(name, options={}) - ws_url="#{ApplicationController::root_context}/api/users/search?f=s2" + ws_url="#{ApplicationController::root_context}/api/users/search2" options[:min_length]=2 + options[:select2_ajax_options]={ + 'data' => %{ + function (term, page) { + return { q: term, p: page }; + } + }, + 'results' => %{ + function (data, page) { + return { + more: false, + results: _.map(data.users, function(user) { + return { + id: user.login, + text: '' + user.name + ' (' + user.login + ')' + }; + }) + }; + } + } + } user = options[:selected_user] if user |