From d5d08fef74e081bbbfdf94c8a0d9ebec9358016f Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Mon, 16 Dec 2013 15:15:07 +0100 Subject: [PATCH] Document path in the view headers unified --- app/views/dmsf/_path.html.erb | 37 +++++++++++++++++++++ app/views/dmsf/edit.html.erb | 12 +------ app/views/dmsf/email_entries.html.erb | 9 +---- app/views/dmsf/show.html.erb | 9 +---- app/views/dmsf_files/show.html.erb | 12 +------ app/views/dmsf_files_copy/new.html.erb | 12 +------ app/views/dmsf_folders_copy/new.html.erb | 8 +---- app/views/dmsf_upload/upload_files.html.erb | 11 ++---- config/routes.rb | 2 +- 9 files changed, 46 insertions(+), 66 deletions(-) create mode 100644 app/views/dmsf/_path.html.erb diff --git a/app/views/dmsf/_path.html.erb b/app/views/dmsf/_path.html.erb new file mode 100644 index 00000000..68c9d5a0 --- /dev/null +++ b/app/views/dmsf/_path.html.erb @@ -0,0 +1,37 @@ +<%# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2013 Karel Pičman +# +# 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.%> + +

+ <% if folder %> + <%= link_to l(:link_documents), dmsf_path(:id => @project) %> + <% folder.dmsf_path.each do |path_element| %> + / + <% if !filename && path_element == folder.dmsf_path.last %> + <%= h(path_element.title) %> + <% else %> + <%= link_to h(path_element.title), dmsf_path(:id => @project, :folder_id => path_element) %> + <% end %> + <% end %> + <% else %> + <%= l(:link_documents) %> + <% end %> + <% if filename %> + / + <%= h(filename) %> + <% end %> +

diff --git a/app/views/dmsf/edit.html.erb b/app/views/dmsf/edit.html.erb index ef6cf8a1..8aac34da 100644 --- a/app/views/dmsf/edit.html.erb +++ b/app/views/dmsf/edit.html.erb @@ -25,17 +25,7 @@ :title => l(:title_copy)) if @folder.id %> -<% create = @pathfolder == @parent %> - -

- <% path = @pathfolder ? @pathfolder.dmsf_path : [] %> - <%= link_to l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> @project } %> - <% path.each do |path_element| %> - / - <%= link_to h(path_element.title), {:controller => 'dmsf', :action => 'show', :id=> @project, :folder_id => path_element} %> - <% end %> - <%= "/ #{l(:heading_new_folder)}" if create %> -

+<%= render(:partial => 'path', :locals => {:folder => @pathfolder, :filename => @pathfolder == @parent ? l(:heading_new_folder) : nil}) %> <%= form_for(@folder, :url => {:action => create ? 'create' : 'save', :id => @project, :folder_id => @folder, :parent_id => @parent}, :html => {:method=>:post}) do |f| %> diff --git a/app/views/dmsf/email_entries.html.erb b/app/views/dmsf/email_entries.html.erb index a01a92a4..fcd71c98 100644 --- a/app/views/dmsf/email_entries.html.erb +++ b/app/views/dmsf/email_entries.html.erb @@ -22,14 +22,7 @@
-

- <% path = @folder ? @folder.dmsf_path : [] %> - <%= link_to l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> @project } %> - <% path.each do |path_element| %> - / - <%= link_to h(path_element.title), {:controller => 'dmsf', :action => 'show', :id=> @project, :folder_id => path_element} %> - <% end %> -

+<%= render(:partial => 'path', :locals => {:folder => @folder}) %>

<%= l(:heading_send_documents_by_email) %>

diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index 343a414c..81e0e3f9 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -65,14 +65,7 @@ <% end %> -

- <% path = @folder ? @folder.dmsf_path : [] %> - <%= link_to l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> @project } %> - <% path.each do |path_element| %> - / - <%= link_to h(path_element.title), {:controller => 'dmsf', :action => 'show', :id=> @project, :folder_id => path_element} %> - <% end %> -

+<%= render(:partial => 'path', :locals => {:folder => @folder}) %>
diff --git a/app/views/dmsf_files/show.html.erb b/app/views/dmsf_files/show.html.erb index 4723eab3..0914a36d 100644 --- a/app/views/dmsf_files/show.html.erb +++ b/app/views/dmsf_files/show.html.erb @@ -60,17 +60,7 @@ <%= link_to(image_tag('copy.png'), {:controller => :dmsf_files_copy, :action => 'new', :id => @file }, :title => l(:title_copy_or_move)) %>
-

- <% path = @file.folder ? @file.folder.dmsf_path : [] %> - <%= link_to l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> @project } %> - <% path.each do |path_element| %> - / - <%= link_to h(path_element.title), {:controller => 'dmsf', :action => 'show', :id=> @project, :folder_id => path_element} %> - <% end %> - / - <%= h(@file.last_revision.title) %> - <%= image_tag('notify.png', :plugin => 'redmine_dmsf', :title => l(:title_notifications_active)) if @file.notification %> -

+<%= render(:partial => '/dmsf/path', :locals => {:folder => @file.folder, :filename => @file.title}) %> <%= error_messages_for('file') %> <%= error_messages_for('revision') %> diff --git a/app/views/dmsf_files_copy/new.html.erb b/app/views/dmsf_files_copy/new.html.erb index 0c3d096f..0b565840 100644 --- a/app/views/dmsf_files_copy/new.html.erb +++ b/app/views/dmsf_files_copy/new.html.erb @@ -22,17 +22,7 @@
-

- <% path = @file.folder ? @file.folder.dmsf_path : [] %> - <%= link_to l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> @project } %> - <% path.each do |path_element| %> - / - <%= link_to h(path_element.title), {:controller => 'dmsf', :action => 'show', :id=> @project, :folder_id => path_element} %> - <% end %> - / - <%= link_to(h(@file.title), {:controller => 'dmsf_files', :action => 'show', :id=> @file}) %> - <%= image_tag('notify.png', :plugin => 'redmine_dmsf', :title => l(:title_notifications_active)) if @file.notification %> -

+<%= render(:partial => 'path', :locals => {:folder => @file.folder, :filename => @file.title}) %> <% if DmsfFile.allowed_target_projects_on_copy.present? %> <%= form_tag({:action => 'create', :id => @file}, :id => 'copyForm') do |f| %> diff --git a/app/views/dmsf_folders_copy/new.html.erb b/app/views/dmsf_folders_copy/new.html.erb index 9be97821..74f864e3 100644 --- a/app/views/dmsf_folders_copy/new.html.erb +++ b/app/views/dmsf_folders_copy/new.html.erb @@ -21,13 +21,7 @@
-

- <%= link_to l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> @project } %> - <% @folder.dmsf_path.each do |path_element| %> - / - <%= link_to h(path_element.title), {:controller => 'dmsf', :action => 'show', :id=> @project, :folder_id => path_element} %> - <% end %> -

+<%= render(:partial => 'path', :locals => {:folder => @folder}) %> <% unless DmsfFolder.allowed_target_projects_on_copy.blank? %> <%= form_tag({:action => 'copy_to', :id => @folder}, :id => 'copyForm') do |f| %> diff --git a/app/views/dmsf_upload/upload_files.html.erb b/app/views/dmsf_upload/upload_files.html.erb index 3d02bf2c..ef25b385 100644 --- a/app/views/dmsf_upload/upload_files.html.erb +++ b/app/views/dmsf_upload/upload_files.html.erb @@ -22,17 +22,10 @@
-

- <% path = @folder ? @folder.dmsf_path : [] %> - <%= link_to l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> @project } %> - <% path.each do |path_element| %> - / - <%= link_to h(path_element.title), {:controller => 'dmsf', :action => 'show', :id=> @project, :folder_id => path_element} %> - <% end %> -

+<%= render(:partial => 'path', :locals => {:folder => @folder}) %>
-<%= textilizable(@folder.description) unless @folder.nil? %> + <%= textilizable(@folder.description) if @folder %>

<%=l(:heading_uploaded_files)%>

diff --git a/config/routes.rb b/config/routes.rb index 0a5207de..cf2edc0a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,7 +36,7 @@ RedmineApp::Application.routes.draw do post '/projects/:id/dmsf/entries/email', :controller => 'dmsf', :action => 'entries_email' post '/projects/:id/dmsf/lock', :controller => 'dmsf', :action => 'lock' post '/projects/:id/dmsf/unlock', :controller => 'dmsf', :action => 'unlock' - get '/projects/:id/dmsf/', :controller => 'dmsf', :action => 'show' + get '/projects/:id/dmsf/', :controller => 'dmsf', :action => 'show', :as => 'dmsf' get '/projects/:id/dmsf/new', :controller => 'dmsf', :action => 'new' get '/projects/:id/dmsf/edit', :controller=> 'dmsf', :action => 'edit' get '/projects/:id/dmsf/edit/root', :controller=> 'dmsf', :action => 'edit_root'