diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2013-12-04 21:19:20 +0600 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2013-12-04 21:19:25 +0600 |
commit | 6d609d45f0b29b6efcafe6dcbc210a61139cb902 (patch) | |
tree | 574b9725e5ab045be8dd9dac5bfb7010c6b88f71 | |
parent | ac68ccda4c2c654fd68213b0d6de20a2ad820778 (diff) | |
download | sonarqube-6d609d45f0b29b6efcafe6dcbc210a61139cb902.tar.gz sonarqube-6d609d45f0b29b6efcafe6dcbc210a61139cb902.zip |
Update select list component
3 files changed, 22 insertions, 14 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/groups/_select_user.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/groups/_select_user.html.erb index 3c6ac099a0a..13a9ec4551a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/groups/_select_user.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/groups/_select_user.html.erb @@ -1,24 +1,28 @@ <div class="modal-head"> - <h2>Group: <%= h @group.name -%></h2> + <h2>Group: <%= h @group.name -%></h2> </div> <div class="modal-body"> - <div id="select-list-group-<%= @group.id -%>"></div> + <div id="select-list-group"></div> </div> <div class="modal-foot"> - <%= link_to 'Close', { :controller => 'groups', :action => 'index', :id => nil}, { :class => 'action' } %><br/> + <%= link_to 'Close', { :controller => 'groups', :action => 'index', :id => nil}, { :class => 'action' } %><br/> </div> <script> var selectList = new SelectList({ - el: '#select-list-group-<%= @group.id -%>', + el: '#select-list-group', width: '100%', format: function (item) { return item.name + ' <div class="subtitle">' + item.login + '</div>'; }, - searchUrl: baseUrl + '/groups/search_users?group=<%= @group.id -%>', - selectUrl: baseUrl + '/groups/add_member?group=<%= @group.id -%>', - deselectUrl: baseUrl + '/groups/remove_member?group=<%= @group.id -%>', + searchUrl: baseUrl + '/groups/search_users?group=<%= @group.name -%>', + selectUrl: baseUrl + '/groups/add_member', + deselectUrl: baseUrl + '/groups/remove_member', + extra: { + group: '<%= @group.name -%>' + }, selectParameter: 'user', + selectParameterValue: 'login', labels: { selected: 'Members', deselected: 'Non-members', diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/users/_select_group.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/users/_select_group.html.erb index b97df868285..9f7eef14f5c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/users/_select_group.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/users/_select_group.html.erb @@ -3,7 +3,7 @@ </div> <div class="modal-body"> - <div id="select-list-user-<%= @user.id -%>"></div> + <div id="select-list-user"></div> </div> <div class="modal-foot"> @@ -12,13 +12,17 @@ <script> var selectList = new SelectList({ - el: '#select-list-user-<%= @user.id -%>', + el: '#select-list-user', width: '100%', format: function (item) { return item.name; }, - searchUrl: baseUrl + '/user_groups/search?login=<%= @user.login -%>', - selectUrl: baseUrl + '/groups/add_member?user=<%= @user.id -%>', - deselectUrl: baseUrl + '/groups/remove_member?user=<%= @user.id -%>', + searchUrl: baseUrl + '/user_groups/search?user=<%= @user.login -%>', + selectUrl: baseUrl + '/groups/add_member', + deselectUrl: baseUrl + '/groups/remove_member', + extra: { + user: '<%= @user.login -%>' + }, selectParameter: 'group', + selectParameterValue: 'name', labels: { selected: 'Member of', deselected: 'Not member of', diff --git a/sonar-server/src/main/webapp/javascripts/select-list.js b/sonar-server/src/main/webapp/javascripts/select-list.js index 5898e05140b..5df1e412c08 100644 --- a/sonar-server/src/main/webapp/javascripts/select-list.js +++ b/sonar-server/src/main/webapp/javascripts/select-list.js @@ -94,9 +94,9 @@ var selected = this.model.get('selected'), that = this, url = selected ? this.settings.deselectUrl : this.settings.selectUrl, - data = {}; + data = $.extend({}, this.settings.extra || {}); - data[this.settings.selectParameter] = this.model.id; + data[this.settings.selectParameter] = this.model.get(this.settings.selectParameterValue); $.ajax({ url: url, |