This commit is contained in:
BoHung Chiu 2020-05-15 22:46:28 +08:00
parent 308302fdb9
commit 5ae0c57a1a
1 changed files with 6 additions and 2 deletions

View File

@ -14,12 +14,12 @@ class Admin::AnnouncementsController < OrbitAdminController
def index def index
Bulletin.remove_expired_status Bulletin.remove_expired_status
@tags = @module_app.tags @tags = @module_app.tags
@categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories, @tags)
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified] @table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
if AnnouncementSetting.first.is_display_edit_only && !current_user.is_admin? && !current_user.is_manager?(@module_app) if AnnouncementSetting.first.is_display_edit_only && !current_user.is_admin? && !current_user.is_manager?(@module_app)
current_user_is_sub_manager = !current_user.is_manager?(@module_app) && (current_user.is_sub_manager?(@module_app) || current_user.is_sub_manager_with_role?(@module_app)) rescue false current_user_is_sub_manager = !current_user.is_manager?(@module_app) && (current_user.is_sub_manager?(@module_app) || current_user.is_sub_manager_with_role?(@module_app)) rescue false
if current_user_is_sub_manager if current_user_is_sub_manager
@categories = current_user.approved_categories.select{|c| c.module_app_id == @module_app.id} rescue []
@filter_fields = filter_fields(@categories, @tags)
@bulletins = Bulletin.where(:create_user_id=>current_user.id,:title.ne => "",:is_preview.in=>[false,nil]) @bulletins = Bulletin.where(:create_user_id=>current_user.id,:title.ne => "",:is_preview.in=>[false,nil])
.order_by(sort) .order_by(sort)
.with_categories(filters("category")) .with_categories(filters("category"))
@ -27,8 +27,12 @@ class Admin::AnnouncementsController < OrbitAdminController
.with_status(filters("status")) .with_status(filters("status"))
else else
@bulletins = Bulletin.where(:uid=>nil) @bulletins = Bulletin.where(:uid=>nil)
@categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories, @tags)
end end
else else
@categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories, @tags)
@bulletins = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]) @bulletins = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil])
.order_by(sort) .order_by(sort)
.with_categories(filters("category")) .with_categories(filters("category"))