diff --git a/app/assets/javascripts/inc/permission-checkbox.js b/app/assets/javascripts/inc/permission-checkbox.js index fc91b857..23716f68 100644 --- a/app/assets/javascripts/inc/permission-checkbox.js +++ b/app/assets/javascripts/inc/permission-checkbox.js @@ -1,4 +1,7 @@ $(document).ready(function() { + permissionCheckbox(); +}); +function permissionCheckbox(){ $('.check[checked="checked"]').parents(".checkbox").addClass("checked") $(".checkbox").click(function(){ if($(this).children(".check").attr("checked")){ @@ -16,4 +19,4 @@ $(document).ready(function() { placement: 'bottom', delay: { show: 100, hide: 300 }, }); -}); \ No newline at end of file +}; \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index 0578cfc3..2d10dd75 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -5,19 +5,13 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle def setting @bulletin_categorys = BulletinCategory.all - if params.has_key?(:category_id) - first_category = BulletinCategory.find params[:category_id] - if params[:commit] == 'Update' - privilege_users = params[:users].collect{|key,value| User.find key } rescue [] - preload_object_auth_ary = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check') - preload_object_auth = preload_object_auth_ary.first - preload_object_auth.privilege_users = privilege_users - preload_object_auth.save! - end + @options_from_collection_for_select_bulletin_categorys = @bulletin_categorys.collect{|bc| [bc.i18n_variable[I18n.locale],bc.id] } + if params.has_key? :category + @bulletin_category = BulletinCategory.find params[:category][:id] else - first_category = @bulletin_categorys.first - end - preload_object_auth = first_category.object_auths.where(title: 'fact_check').empty?? (first_category.object_auths.create! :title=> 'fact_check') : first_category.object_auths.where(title: 'fact_check') + @bulletin_category = @bulletin_categorys.first + end + preload_object_auth = @bulletin_category.object_auths.where(title: 'fact_check').empty?? (@bulletin_category.object_auths.create! :title=> 'fact_check') : @bulletin_category.object_auths.where(title: 'fact_check') @users_array = preload_object_auth.first.privilege_users rescue [] respond_to do |format| format.html @@ -26,11 +20,16 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle end def update_setting - + object_auth = update_setting_by_params + if object_auth.save! + flash[:notice] = "Update Done" + else + flash[:notice] = "Update Failed" + end end def user_list - @bulletin_category = BulletinCategory.find params[:category_id] + @bulletin_category = BulletinCategory.find params[:category][:id] end # def index # get_categorys(params[:bulletin_category_id]) @@ -68,6 +67,15 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle # # end protected + def update_setting_by_params + category = BulletinCategory.find params[:category][:id] + privilege_users = params[:users].collect{|key,value| User.find key } rescue [] + object_auth_ary = category.object_auths.where(title: 'fact_check') || (category.object_auths.create :title=> 'fact_check') + object_auth = object_auth_ary.first + object_auth.privilege_users = privilege_users + object_auth + end + def get_categorys(id = nil) @bulletin_categorys = [] if(is_manager? || is_admin?) diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_privilege_user.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_privilege_user.html.erb index 659fbc43..f4bd4707 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_privilege_user.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_privilege_user.html.erb @@ -1,24 +1,24 @@ <%= content_tag :div ,:id => "users_checkbox_ary",:class => 'clear' do -%> <% sys_users = User.all -%> - <% sys_users.each do |user| -%> + <% sys_users.each do |sys_user| -%>