Update text for status.(top: 重要)

This commit is contained in:
chiu 2020-11-11 16:22:50 +08:00
parent d194f962dd
commit 13b9b850ce
4 changed files with 42 additions and 1 deletions

View File

@ -8,6 +8,9 @@ class AnnouncementSetting
field :email_to, type: Array, :default => ["admins","managers","approvers"] field :email_to, type: Array, :default => ["admins","managers","approvers"]
field :is_display_edit_only, type: Boolean, :default => false field :is_display_edit_only, type: Boolean, :default => false
field :only_manager_can_edit_status, type: Boolean, :default => false field :only_manager_can_edit_status, type: Boolean, :default => false
field :top_text , type: String , localize: true
field :hot_text , type: String , localize: true
field :hidden_text , type: String , localize: true
has_many :anns_status_settings, :autosave => true, :dependent => :destroy has_many :anns_status_settings, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :anns_status_settings, :allow_destroy => true accepts_nested_attributes_for :anns_status_settings, :allow_destroy => true
def self.check_limit_for_user(user_id, b_id = nil) def self.check_limit_for_user(user_id, b_id = nil)

View File

@ -189,4 +189,34 @@ class Bulletin
role_ids = user.member_profile.roles.collect{|v| v.id.to_s} rescue ['visitor'] role_ids = user.member_profile.roles.collect{|v| v.id.to_s} rescue ['visitor']
self.open_comment && (self.comment_end_time.blank? || self.comment_end_time > Time.now) && (self.comment_role.any?{|v| role_ids.include?(v)} || self.comment_role.include?('visitor') || (self.comment_role.include?('all_member') && role_ids[0] != 'visitor')) self.open_comment && (self.comment_end_time.blank? || self.comment_end_time > Time.now) && (self.comment_role.any?{|v| role_ids.include?(v)} || self.comment_role.include?('visitor') || (self.comment_role.include?('all_member') && role_ids[0] != 'visitor'))
end end
def statuses
statuses = []
statuses << top_text if is_top?
statuses << hot_text if is_hot?
statuses << hidden_text if is_hidden?
statuses
end
def statuses_with_classname
statuses = []
statuses << {"name" => top_text, "classname" => "top"} if is_top?
statuses << {"name" => hot_text, "classname" => "hot"} if is_hot?
statuses << {"name" => hidden_text, "classname" => "hidden"} if is_hidden?
statuses
end
def status_for_table
status = ""
status << "<span class='label label-success'>#{top_text}</span> " if self.is_top
status << "<span class='label label-important'>#{hot_text}</span> " if self.is_hot
status << "<span class='label'>#{hidden_text}</span>"if self.is_hidden
status.html_safe
end
def top_text
I18n.t("announcement.status.top")
end
def hot_text
I18n.t("announcement.status.hot")
end
def hidden_text
I18n.t("announcement.status.hidden")
end
end end

View File

@ -137,3 +137,7 @@ en:
show_page: Show pagination show_page: Show pagination
URL: URL URL: URL
copy: Copy copy: Copy
status:
top: Important
hot: Hot
hidden: Hidden

View File

@ -140,3 +140,7 @@ zh_tw:
show_page: 顯示頁碼 show_page: 顯示頁碼
URL: 網址 URL: 網址
copy: 複製 copy: 複製
status:
top: 重要
hot: 熱門
hidden: 隱藏