diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb
index 26925aee8..c0507e671 100644
--- a/app/views/layouts/_side_bar.html.erb
+++ b/app/views/layouts/_side_bar.html.erb
@@ -75,3 +75,8 @@
<%#= content_tag :li, link_to(t('admin.tags'), admin_asset_tags_path), :class => active_for_action('/admin/asset_tags', 'index') %>
<%# end -%>
<%# end -%>
+
+ <% flash.each do |key, msg| %>
+ <%= content_tag :span, msg, :class => [key, "notice label label-warning"] %>
+ <% end%>
+
\ No newline at end of file
diff --git a/lib/orbit_core_lib.rb b/lib/orbit_core_lib.rb
index f3cd2cd51..8e333b7e2 100644
--- a/lib/orbit_core_lib.rb
+++ b/lib/orbit_core_lib.rb
@@ -14,7 +14,7 @@ module OrbitCoreLib
query1 = auth_object_space.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: user.id)
query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role.id}).excludes(blocked_user_ids: user.id)
result = (query1 + query2).uniq
- result.collect{|t| t.obj_authable}
+ result.collect{|t| t.obj_authable}.delete_if{|val| val==nil}
end
end
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
index b1ce17186..9ba78b90d 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
@@ -107,13 +107,20 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
# DELETE /bulletins/1
# DELETE /bulletins/1.xml
def destroy
- @bulletin_category = BulletinCategory.find(params[:id])
- @bulletin_category.destroy
+ @bulletin_category = BulletinCategory.find(params[:id]).first
+ @bulletin_category.disable = @bulletin_category.disable ? false : true
- respond_to do |format|
- format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) }
- # format.xml { head :ok }
- format.js
+ if @bulletin_category.save!
+ respond_to do |format|
+ flash[:notice] = t("bulletin_category.update_success")
+ # flash[:error] += @bulletin_category.disable ? t("bulletin_category.disable_change_to_true") : t("bulletin_category.disable_change_to_false")
+ format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) }
+ # format.xml { head :ok }
+ format.js
+ end
+ else
+ flash[:error] = t("bulletin_category.update_failed")
+ format.html { render :action => "index" }
end
end
end
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb
index f47b41bbc..1b6b43362 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb
@@ -3,6 +3,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
layout 'new_admin'
before_filter :authenticate_user!
+ before_filter :get_categorys ,:only => [ :new,:edit,:update]
# before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
@@ -83,15 +84,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# @bulletin.bulletin_files.build
# @bulletin.bulletin_files.new
- if get_categorys.empty?
- flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
- redirect_to :action => :index
- else
get_tags
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @bulletin }
- end
end
end
@@ -105,7 +101,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
- get_categorys
get_tags
end
end
@@ -268,7 +263,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
format.xml { head :ok }
else
get_tags
- get_categorys
+
format.html { render :action => "edit" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end
@@ -333,9 +328,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin_categorys = []
#@unit_list_for_anc = UnitListForAnc.all
if(is_manager? || is_admin?)
- @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
+ @bulletin_categorys = (id ? BulletinCategory.available.find(id).to_a : BulletinCategory.available)
elsif is_sub_manager?
- @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit')
+ @bulletin_categorys = BulletinCategory.available.authed_for_user(current_user,'submit')
+ end
+ if @bulletin_categorys.empty? && params[:action] != "index"
+ flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
+ redirect_to :action => :index
end
end
diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb
index 926049854..ea413b542 100644
--- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb
+++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb
@@ -13,4 +13,8 @@ include ActionView::Helpers::UrlHelper
link_to t('announcement.bulletin.cate_auth'),admin_object_auth_ob_auth_path(oa)
end
+ def show_toggle_archive_btn(bulletin_category)
+ bulletin_category.disable ? t("bulletin_category.disable_change_to_true") : t("bulletin_category.disable_change_to_false")
+ end
+
end
\ No newline at end of file
diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb
index feb39edbd..a5686cc1c 100644
--- a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb
+++ b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb
@@ -14,11 +14,22 @@ class BulletinCategory
field :key
field :display
-
+ field :disable,type: Boolean,:default => false
+
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
- has_many :bulletins,:dependent => :destroy
+ has_many :bulletins
+ scope :available,where(disable: false)
+
+ def self.find(*args)
+ if args ==[:all]
+ unscoped
+ else
+ unscoped.find(args)
+ end
+ end
+
def pp_object
i18n_variable[I18n.locale]
end
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb
index 6b98e4661..58a9a5f9b 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb
@@ -6,7 +6,7 @@
<% if is_admin?%>
- <%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %>
- - <%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %>
+ - <%= link_to show_toggle_archive_btn(bulletin_category) , panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true,:class=> "archive_toggle" %>
<% end %>
<%if is_manager? || is_admin? %>
- <%= show_anc_cate_permission_link(bulletin_category) %>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/destroy.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/destroy.js.erb
index 882b13d22..e7f791906 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/destroy.js.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/destroy.js.erb
@@ -1 +1 @@
-$("#<%= dom_id @bulletin_category %>").remove();
\ No newline at end of file
+$("#<%= dom_id @bulletin_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@bulletin_category) %> ");
\ No newline at end of file
diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml
index af1364a9f..6aa1d15b8 100644
--- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml
+++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml
@@ -79,6 +79,7 @@ zh_tw:
fact_check: 公告審核
delete: 刪除
edit: 編輯
+
# action: 行動
# add_language: 新增語言
# admin: 管理
@@ -178,6 +179,10 @@ zh_tw:
bulletin_category:
edit: 修改
delete: 刪除
+ update_success: 分類更新成功
+ update_failed: 分類更新失敗
+ disable_change_to_false: 設為停用
+ disable_change_to_true: 重新啓用
# Chinese (Taiwan) translations for Ruby on Rails
# by tsechingho (http://github.com/tsechingho)