The parent folder link

This commit is contained in:
Karel Picman 2017-07-11 13:40:51 +02:00
parent 5f59309eb7
commit 97114d4a28
5 changed files with 79 additions and 12 deletions

View File

@ -0,0 +1,31 @@
<%
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011-17 Karel Picman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%>
<% dmsf_file_or_folder = object %>
<% if dmsf_file_or_folder.dmsf_folder_id %>
<% dmsf_folder = DmsfFolder.find_by_id dmsf_file_or_folder.dmsf_folder_id %>
<% title = dmsf_folder.title if dmsf_folder %>
<% else %>
<% title = dmsf_file_or_folder.project.name %>
<% end %>
<%= link_to(h(title), dmsf_folder_path(:id => dmsf_file_or_folder.project,
:folder_id => dmsf_file_or_folder.dmsf_folder_id), :class => 'icon icon-folder') %>

View File

@ -63,6 +63,7 @@ require 'redmine_dmsf/hooks/views/issue_view_hooks'
require 'redmine_dmsf/hooks/views/custom_field_view_hooks'
require 'redmine_dmsf/hooks/views/search_view_hooks'
require 'redmine_dmsf/hooks/helpers/issues_helper_hooks'
require 'redmine_dmsf/hooks/helpers/search_helper_hooks'
# Macros
require 'redmine_dmsf/macros'

View File

@ -22,7 +22,7 @@ module RedmineDmsf
module Hooks
include Redmine::Hook
class HellperIssuesHook < RedmineDmsf::Hooks::Listener
class HelperIssuesHook < RedmineDmsf::Hooks::Listener
def helper_issues_show_detail_after_setting(context)
if context.is_a?(Hash)

View File

@ -0,0 +1,41 @@
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011-17 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module RedmineDmsf
module Hooks
include Redmine::Hook
class SearchHelperHook < RedmineDmsf::Hooks::Listener
def helper_easy_extensions_search_helper_patch(context={})
case context[:entity].event_type
when 'dmsf-file', 'dmsf-folder'
str = context[:controller].send(:render_to_string, :partial => 'search/container',
:locals => { :object => context[:entity] })
if str
context[:additional_result] << str
end
end
end
end
end
end

View File

@ -22,18 +22,12 @@ module RedmineDmsf
class ViewSearchFormHook < Redmine::Hook::ViewListener
def view_search_index_container(context={})
if context && context[:object].is_a?(DmsfFile)
dmsf_file = context[:object]
title = ''
if dmsf_file.dmsf_folder_id
dmsf_folder = DmsfFolder.find_by_id dmsf_file.dmsf_folder_id
title = dmsf_folder.title if dmsf_folder
else
title = dmsf_file.project.name
if context[:object].is_a?(DmsfFile) || context[:object].is_a?(DmsfFolder)
str = context[:controller].send(:render_to_string, :partial => 'search/container',
:locals => { :object => context[:object] })
if str
" #{str} /"
end
link_to(h(title),
dmsf_folder_path(:id => dmsf_file.project, :folder_id => dmsf_file.dmsf_folder_id),
:class => 'icon icon-folder') + ' / '
end
end