summaryrefslogtreecommitdiffstats
path: root/app/helpers/application_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r--app/helpers/application_helper.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index dd152f32c..576b99647 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -170,6 +170,40 @@ module ApplicationHelper
link_to_if version.visible?, format_version_name(version), version_path(version), options
end
+ RECORD_LINK = {
+ 'CustomValue' => -> (custom_value) { link_to_record(custom_value.customized) },
+ 'Document' => -> (document) { link_to(document.title, document_path(document)) },
+ 'Group' => -> (group) { link_to(group.name, group_path(group)) },
+ 'Issue' => -> (issue) { link_to_issue(issue, :subject => false) },
+ 'Message' => -> (message) { link_to_message(message) },
+ 'News' => -> (news) { link_to(news.title, news_path(news)) },
+ 'Project' => -> (project) { link_to_project(project) },
+ 'User' => -> (user) { link_to_user(user) },
+ 'Version' => -> (version) { link_to_version(version) },
+ 'WikiPage' => -> (wiki_page) { link_to(wiki_page.pretty_title, project_wiki_page_path(wiki_page.project, wiki_page.title)) }
+ }
+
+ def link_to_record(record)
+ if link = RECORD_LINK[record.class.name]
+ self.instance_exec(record, &link)
+ end
+ end
+
+ ATTACHMENT_CONTAINER_LINK = {
+ # Custom list, since project/version attachments are listed in the files
+ # view and not in the project/milestone view
+ 'Project' => -> (project) { link_to(l(:project_module_files), project_files_path(project)) },
+ 'Version' => -> (version) { link_to(l(:project_module_files), project_files_path(version.project)) },
+ }
+
+ def link_to_attachment_container(attachment_container)
+ if link = ATTACHMENT_CONTAINER_LINK[attachment_container.class.name] ||
+ RECORD_LINK[attachment_container.class.name]
+ self.instance_exec(attachment_container, &link)
+ end
+ end
+
+
# Helper that formats object for html or text rendering
def format_object(object, html=true, &block)
if block_given?