Update description.

This commit is contained in:
BoHung Chiu 2021-03-24 18:05:19 +08:00
parent 20cccf9ed2
commit 10f42f67e9
5 changed files with 15 additions and 5 deletions

View File

@ -25,7 +25,7 @@ class AnnouncementsController < ApplicationController
}
end
locale = OrbitHelper.get_site_locale.to_s
files = a.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } if file.enabled_for?(locale) } rescue []
files = a.bulletin_files.map{|file| { "file_url" => file.file.url + "\" title=\"#{file.file_title}", "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } if file.enabled_for?(locale) } rescue []
files.delete(nil)
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
author = User.find(a.create_user_id).member_profile.name rescue ""
@ -254,7 +254,7 @@ class AnnouncementsController < ApplicationController
"url" => OrbitHelper.page_for_tag(tag)
} } rescue []
files = announcement.bulletin_files.map do |file|
{ "file_url" => "/xhr/announcements/file/#{file.id}/#{file['file']}",
{ "file_url" => "/xhr/announcements/file/#{file.id}/#{file['file']}" + "\" title=\"#{file.file_title}",
"file_title" => (file.title.blank? ? URI.unescape(File.basename(file.file.path)) : file.title rescue '') } if file.enabled_for?(locale)
end rescue []
files.delete(nil)
@ -411,7 +411,7 @@ class AnnouncementsController < ApplicationController
}
end
locale = I18n.locale.to_s
files = a.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } if file.enabled_for?(locale) } rescue []
files = a.bulletin_files.map{|file| { "file_url" => file.file.url + "\" title=\"#{file.file_title}", "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } if file.enabled_for?(locale) } rescue []
files.delete(nil)
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
author = User.find(a.create_user_id).member_profile.name rescue ""

View File

@ -12,7 +12,15 @@ class BulletinFile
field :privacy_type, type: String, default: 'public'
belongs_to :bulletin
def file_title
if self.description.present?
return self.description
elsif self.title.present?
return self.title
else
return File.basename(self.file.path)
end
end
def enabled_for?(lang)
if lang.nil?
return true

View File

@ -426,7 +426,7 @@
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<div id="file_description_hint"><%= t("announcement.file_description_hint") %></div>
<!-- Exist -->
<% if @bulletin && !@bulletin.bulletin_files.blank? %>
<div class="exist">

View File

@ -94,6 +94,7 @@ en:
editing_announcement_category: Edit Category
file: Attachment
file_description: File Description
file_description_hint: 'File Description will display in the title of file link.(When placing mouse on the link,the title will display)'
file_name: File Name
frontend:
bulletins: Announcement front-end

View File

@ -97,6 +97,7 @@ zh_tw:
no_avilb_cate_for_posting: 沒有可以張貼的類別
file: 附加檔案
file_description: 檔案描述
file_description_hint: '檔案描述將會顯示在前台檔案連結的title(把滑鼠放在連結上會出現的文字)'
file_name: 檔案名稱
frontend:
bulletins: 公告前台