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 @@