From 87ebcc48e7a0b9f32deed5f04ad2c7455b821604 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 10 May 2012 11:51:44 +0800 Subject: [PATCH 1/2] Appauth new interface for setting managers. Fix showing sidebar for News and Announcement when setting managers at module app page. --- app/assets/javascripts/.DS_Store | Bin 6148 -> 6148 bytes app/assets/javascripts/inc/search.js | 34 --------- .../admin/module_apps_controller.rb | 4 ++ .../new_interface_module_apps_controller.rb | 66 ++++++++++++++++++ app/helpers/application_helper.rb | 4 +- .../_modal_list.html.erb | 42 +++++++++++ .../_privilege_user.html.erb | 25 +++++++ .../setting.html.erb | 56 +++++++++++++++ .../new_interface_module_apps/setting.js.erb | 2 + .../update_setting.js.erb | 1 + .../user_list.js.erb | 2 + app/views/layouts/_side_bar.html.erb | 8 +-- dump.rdb | Bin 1530 -> 716 bytes 13 files changed, 204 insertions(+), 40 deletions(-) delete mode 100644 app/assets/javascripts/inc/search.js create mode 100644 app/controllers/admin/new_interface_module_apps_controller.rb create mode 100644 app/views/admin/new_interface_module_apps/_modal_list.html.erb create mode 100644 app/views/admin/new_interface_module_apps/_privilege_user.html.erb create mode 100644 app/views/admin/new_interface_module_apps/setting.html.erb create mode 100644 app/views/admin/new_interface_module_apps/setting.js.erb create mode 100644 app/views/admin/new_interface_module_apps/update_setting.js.erb create mode 100644 app/views/admin/new_interface_module_apps/user_list.js.erb diff --git a/app/assets/javascripts/.DS_Store b/app/assets/javascripts/.DS_Store index 51582ef8aa6a5ea474683aee9d3de008e14c257f..9134f2a58171c1a69637b1eef035b67fcfa72004 100644 GIT binary patch delta 139 zcmZoMXfc=|#>B)qu~2NHo+2a5#DLw41(+BaStj!^$_QpMV(ZFfgp2 zY{{6cBT-##WM-(NU}9oWtD{hDZf*c%o0`B`mu~2NHo+2aj#DLw5%#(STWH!HLl49L_f%z!oW_AvK4xp0F2bsS! VPv#e~g1?m;q!45S;)3 diff --git a/app/assets/javascripts/inc/search.js b/app/assets/javascripts/inc/search.js deleted file mode 100644 index 70507fc6..00000000 --- a/app/assets/javascripts/inc/search.js +++ /dev/null @@ -1,34 +0,0 @@ -// JavaScript Document - -// can copy code to any of ur desired javascsript - -//extended jquery to search fast. -$.extend($.expr[':'], { - 'containsi': function (elem, i, match, array) { - return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; - } -}); -var interval,sval; -$(document).ready(function(){ - $("#user_filter").keyup(function(){ - sval = $(this).val(); - $(".checkbox").popover("hide"); - $("div.checkblock").hide(); - clearInterval(interval); - interval = setInterval(waitForSearch,1000); - }) -}) -var waitForSearch = function(){ - if(sval){ - var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length - if(totalfoundbyname!=0){ - $("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show(); - }else if(totalfoundbyname==0){ - $("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show(); - } - }else{ - $(".checkbox").popover('hide'); - $("div.checkblock").show(); - } - clearInterval(interval); -} \ No newline at end of file diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index e44be291..c6a8d2b2 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -17,6 +17,10 @@ class Admin::ModuleAppsController < ApplicationController end end + def module_auth_proc + @module_app = ModuleApp.find(params[:id]) + end + def edit @module_app = ModuleApp.find(params[:id]) end diff --git a/app/controllers/admin/new_interface_module_apps_controller.rb b/app/controllers/admin/new_interface_module_apps_controller.rb new file mode 100644 index 00000000..6603334c --- /dev/null +++ b/app/controllers/admin/new_interface_module_apps_controller.rb @@ -0,0 +1,66 @@ +class Admin::NewInterfaceModuleAppsController < ApplicationController + before_filter :authenticate_user! + before_filter :is_admin? + include AdminHelper + + layout "new_admin" + + def setting + @sys_users = User.all + @module_app = ModuleApp.find(params[:module_app_id]) + @options_from_collection_for_select_bulletin_categorys = [@module_app].collect{|ma| [ma.title,ma.id] } + # if params.has_key? :category + # @bulletin_category = BulletinCategory.find params[:category][:id] + # else + # @bulletin_category = @bulletin_categorys.first + # end + @users_array = @module_app.managing_users rescue [] + + respond_to do |format| + format.html + format.js + end + end + + def update_setting + module_app = update_setting_by_params + if module_app.save! + flash[:notice] = "Update Done" + else + flash[:notice] = "Update Failed" + end + end + + def user_list + @module_app = ModuleApp.find params[:module_app][:id] + end + + protected + def update_setting_by_params + ma = ModuleApp.find params[:module_app][:id] + user_sat = User.find params[:users].keys + users_to_new = user_sat - ma.managing_users + users_to_remove = ma.managing_users - user_sat + + users_to_new.each do |new_user| + ma.assign_manager(new_user,current_user) + end + + users_to_remove.each do |remove_user| + ma.remove_manager(remove_user) + end + ma + end + + def get_categorys(id = nil) + @bulletin_categorys = [] + if(is_manager? || is_admin?) + @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) + elsif is_sub_manager? + @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') + end + end + + + +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 74d3e662..844fbe14 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -68,9 +68,9 @@ module ApplicationHelper end end - def active_sys_call_for_app(controller_name,action_name,app_title) + def active_sys_call_for_app(controller_name,action_name,app_title,field = :id) unless active_for_action(controller_name,action_name).nil? - app = ModuleApp.find params[:id] + app = ModuleApp.find params[field] app.title == app_title ? 'active' : nil else nil diff --git a/app/views/admin/new_interface_module_apps/_modal_list.html.erb b/app/views/admin/new_interface_module_apps/_modal_list.html.erb new file mode 100644 index 00000000..b5b0ebcd --- /dev/null +++ b/app/views/admin/new_interface_module_apps/_modal_list.html.erb @@ -0,0 +1,42 @@ +<% if module_app -%> + +