From e67ca84282ffb5fb8ce127b1b45d92aa5509951f Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 4 Oct 2012 18:20:21 +0800 Subject: [PATCH] object_auth change to reload --- .../admin/object_auths_new_interface_controller.rb | 3 +-- app/models/object_auth.rb | 4 ++++ .../admin/object_auths_new_interface/setting.html.erb | 9 ++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/object_auths_new_interface_controller.rb b/app/controllers/admin/object_auths_new_interface_controller.rb index 66eeec3a..69e94429 100644 --- a/app/controllers/admin/object_auths_new_interface_controller.rb +++ b/app/controllers/admin/object_auths_new_interface_controller.rb @@ -6,7 +6,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController def setting @sys_users = User.all(conditions: {admin: false}).includes(:avatar) @ob_auth = ObjectAuth.find params[:object_auth_id] - @options_from_collection_for_select_ob_auth = [@ob_auth].collect{|oa| [oa.auth_obj.pp_object,oa.id] } + @options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] } @users_array = @ob_auth.privilege_users rescue [] respond_to do |format| @@ -73,7 +73,6 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController end def setup_vars - # binding.pry if request.env['HTTP_REFERER'].split('/')[4] == "object_auths" @app_key = params[:app_key] else diff --git a/app/models/object_auth.rb b/app/models/object_auth.rb index d5cc48de..960509f0 100644 --- a/app/models/object_auth.rb +++ b/app/models/object_auth.rb @@ -5,6 +5,10 @@ class ObjectAuth < PrototypeAuth after_save :check_user_has_app_auth # > - Something.find_with_auth(query) # > - or Something.find(query).auth + def siblings + ObjectAuth.where({obj_authable_type: obj_authable_type,title: title}) + end + def auth_obj class_obj = eval(self.obj_authable_type) class_obj.find self.obj_authable_id diff --git a/app/views/admin/object_auths_new_interface/setting.html.erb b/app/views/admin/object_auths_new_interface/setting.html.erb index 70937731..22c7fd8e 100644 --- a/app/views/admin/object_auths_new_interface/setting.html.erb +++ b/app/views/admin/object_auths_new_interface/setting.html.erb @@ -45,13 +45,8 @@ $(document).ready(function() { } }); - $('#category_id').change(function() { - $.ajax({ - type: 'GET', - dataType: "script", - url:$(this).parents("from").attr("href"), - data:$(this).parents("form").serialize() - }); + $('#ob_auth_id').change(function() { + window.location.href = "/admin/object_auths/"+$(this).val()+"/new_interface?app_key="+$("#app_key").val(); }); }); \ No newline at end of file