summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/groups_controller.rb32
-rw-r--r--app/views/groups/add_users.js.erb4
-rw-r--r--app/views/groups/destroy_membership.js.erb1
-rw-r--r--app/views/groups/edit_membership.js.erb6
-rw-r--r--app/views/groups/remove_user.js.erb1
5 files changed, 19 insertions, 25 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index e4613b5e3..2e57d179a 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -90,16 +90,11 @@ class GroupsController < ApplicationController
end
def add_users
- users = User.find_all_by_id(params[:user_id] || params[:user_ids])
- @group.users << users if request.post?
+ @users = User.find_all_by_id(params[:user_id] || params[:user_ids])
+ @group.users << @users if request.post?
respond_to do |format|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
- format.js {
- render(:update) {|page|
- page.replace_html "tab-content-users", :partial => 'groups/users'
- users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") }
- }
- }
+ format.js
format.api { render_api_ok }
end
end
@@ -108,7 +103,7 @@ class GroupsController < ApplicationController
@group.users.delete(User.find(params[:user_id])) if request.delete?
respond_to do |format|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
- format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} }
+ format.js
format.api { render_api_ok }
end
end
@@ -122,21 +117,8 @@ class GroupsController < ApplicationController
@membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
@membership.save if request.post?
respond_to do |format|
- if @membership.valid?
- format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
- format.js {
- render(:update) {|page|
- page.replace_html "tab-content-memberships", :partial => 'groups/memberships'
- page.visual_effect(:highlight, "member-#{@membership.id}")
- }
- }
- else
- format.js {
- render(:update) {|page|
- page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
- }
- }
- end
+ format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
+ format.js
end
end
@@ -144,7 +126,7 @@ class GroupsController < ApplicationController
Member.find(params[:membership_id]).destroy if request.post?
respond_to do |format|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
- format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'groups/memberships'} }
+ format.js
end
end
diff --git a/app/views/groups/add_users.js.erb b/app/views/groups/add_users.js.erb
new file mode 100644
index 000000000..35d432760
--- /dev/null
+++ b/app/views/groups/add_users.js.erb
@@ -0,0 +1,4 @@
+Element.update('tab-content-users', '<%= escape_javascript(render :partial => 'groups/users') %>');
+<% @users.each do |user| %>
+ new Effect.Highlight('user-<%= user.id %>');
+<% end %>
diff --git a/app/views/groups/destroy_membership.js.erb b/app/views/groups/destroy_membership.js.erb
new file mode 100644
index 000000000..3e03eb817
--- /dev/null
+++ b/app/views/groups/destroy_membership.js.erb
@@ -0,0 +1 @@
+Element.update('tab-content-memberships', '<%= escape_javascript(render :partial => 'groups/memberships') %>');
diff --git a/app/views/groups/edit_membership.js.erb b/app/views/groups/edit_membership.js.erb
new file mode 100644
index 000000000..b693a7f90
--- /dev/null
+++ b/app/views/groups/edit_membership.js.erb
@@ -0,0 +1,6 @@
+<% if @membership.valid? %>
+ Element.update('tab-content-memberships', '<%= escape_javascript(render :partial => 'groups/memberships') %>');
+ new Effect.Highlight('member-<%= @membership.id %>');
+<% else %>
+ alert('<%= escape_javascript(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', '))) %>');
+<% end %>
diff --git a/app/views/groups/remove_user.js.erb b/app/views/groups/remove_user.js.erb
new file mode 100644
index 000000000..b383830b2
--- /dev/null
+++ b/app/views/groups/remove_user.js.erb
@@ -0,0 +1 @@
+Element.update('tab-content-users', '<%= escape_javascript(render :partial => 'groups/users') %>');