From 10f42f67e9c38287cb0fed03d704954bcca5e3b5 Mon Sep 17 00:00:00 2001 From: bohung Date: Wed, 24 Mar 2021 18:05:19 +0800 Subject: [PATCH] Update description. --- app/controllers/announcements_controller.rb | 6 +++--- app/models/bulletin_file.rb | 10 +++++++++- app/views/admin/announcements/_form.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 3e5d3e4..37fbf12 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -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 "" diff --git a/app/models/bulletin_file.rb b/app/models/bulletin_file.rb index f6ade0a..4d70e74 100644 --- a/app/models/bulletin_file.rb +++ b/app/models/bulletin_file.rb @@ -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 diff --git a/app/views/admin/announcements/_form.html.erb b/app/views/admin/announcements/_form.html.erb index fced971..91f9af2 100644 --- a/app/views/admin/announcements/_form.html.erb +++ b/app/views/admin/announcements/_form.html.erb @@ -426,7 +426,7 @@
- +
<%= t("announcement.file_description_hint") %>
<% if @bulletin && !@bulletin.bulletin_files.blank? %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 8144bc7..8fd908e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index f07f209..81d9ab4 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -97,6 +97,7 @@ zh_tw: no_avilb_cate_for_posting: 沒有可以張貼的類別 file: 附加檔案 file_description: 檔案描述 + file_description_hint: '檔案描述將會顯示在前台檔案連結的title(把滑鼠放在連結上會出現的文字)' file_name: 檔案名稱 frontend: bulletins: 公告前台