Commit 1bec32a8a5e694e41679e5a9075758720888728f

Authored by Rodrigo Souto
1 parent d8cedf7d

Fixing pre-population on add members

app/controllers/my_profile/profile_members_controller.rb
@@ -32,7 +32,6 @@ class ProfileMembersController < MyProfileController @@ -32,7 +32,6 @@ class ProfileMembersController < MyProfileController
32 32
33 def last_admin 33 def last_admin
34 @roles = [Profile::Roles.admin(environment.id)] 34 @roles = [Profile::Roles.admin(environment.id)]
35 - @pre_population = [].to_json  
36 end 35 end
37 36
38 def add_role 37 def add_role
app/views/profile_members/_manage_roles.html.erb
@@ -13,11 +13,11 @@ @@ -13,11 +13,11 @@
13 13
14 <% @roles.each do |role| %> 14 <% @roles.each do |role| %>
15 <% search_url = url_for(:action => 'search_user', :profile => profile.identifier, :role => role.id) %> 15 <% search_url = url_for(:action => 'search_user', :profile => profile.identifier, :role => role.id) %>
16 - <% @pre_population ||= profile.members_by_role_to_json(role) %> 16 + <% pre_population = params[:action] == 'last_admin' ? [].to_json : profile.members_by_role_to_json(role) %>
17 <script type="text/javascript"> 17 <script type="text/javascript">
18 jQuery(<%= ('#search_' + role.key).to_json %>) 18 jQuery(<%= ('#search_' + role.key).to_json %>)
19 .tokenInput("<%= search_url %>", { 19 .tokenInput("<%= search_url %>", {
20 - prePopulate: <%= @pre_population %>, 20 + prePopulate: <%= pre_population %>,
21 hintText: <%= _('Type in a search term for users').to_json %>, 21 hintText: <%= _('Type in a search term for users').to_json %>,
22 noResultsText: <%= _('No results').to_json %>, 22 noResultsText: <%= _('No results').to_json %>,
23 searchingText: <%= _('Searching...').to_json %>, 23 searchingText: <%= _('Searching...').to_json %>,