From 8932615f0599f254ffde33ede5d39e1e2958708f Mon Sep 17 00:00:00 2001 From: Matthew Kaito Juyuan Fu Date: Thu, 16 Feb 2012 14:59:26 +0800 Subject: [PATCH] add "all_user" for app&object auth --- app/controllers/admin/app_auths_controller.rb | 5 ++++- app/controllers/admin/object_auths_controller.rb | 5 ++++- .../admin/components/_user_role_management.html.erb | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb index 56d0ae23..9e980e53 100644 --- a/app/controllers/admin/app_auths_controller.rb +++ b/app/controllers/admin/app_auths_controller.rb @@ -21,7 +21,10 @@ class Admin::AppAuthsController < ApplicationController def create app_auth = AppAuth.find_or_create_by(module_app_id: params[:module_app_id]) - params[:new].each do |item| + auth_all = params[:auth_all] || false + app_auth.update_attribute(:all,auth_all) + new_array = params[:new] || [] + new_array.each do |item| field = item[0] field_value = item[1] if field_value!='' diff --git a/app/controllers/admin/object_auths_controller.rb b/app/controllers/admin/object_auths_controller.rb index 573409b6..a7a8dc41 100644 --- a/app/controllers/admin/object_auths_controller.rb +++ b/app/controllers/admin/object_auths_controller.rb @@ -33,7 +33,10 @@ class Admin::ObjectAuthsController < ApplicationController def create_role object_auth = ObjectAuth.find(params[:id]) - params[:new].each do |item| + auth_all = params[:auth_all] || false + object_auth.update_attribute(:all,auth_all) + new_array = params[:new] || [] + new_array.each do |item| field = item[0] field_value = item[1] if field_value!='' diff --git a/app/views/admin/components/_user_role_management.html.erb b/app/views/admin/components/_user_role_management.html.erb index ed7c3476..99cd72d7 100644 --- a/app/views/admin/components/_user_role_management.html.erb +++ b/app/views/admin/components/_user_role_management.html.erb @@ -1,7 +1,12 @@ +
+

All User

+ <%= form_tag(submit_url) do %> + <%= check_box_tag 'auth_all',true,auth.all %><%= submit_tag 'Add Role' %>
+ <% end %> +
+

User Role

- All User - <%= form_tag(submit_url) do %> <%= collection_select(:new,:role, Role.all, :id, :key, :prompt => true) %> <%= submit_tag 'Add Role' %>