From cbbb923550c2c3f516b943088411484c85c66cd3 Mon Sep 17 00:00:00 2001 From: "Karel.Picman" Date: Thu, 21 Oct 2021 09:42:11 +0200 Subject: [PATCH] Folder's description in the upload form --- app/controllers/dmsf_upload_controller.rb | 6 +++- app/views/dmsf/_description.html.erb | 35 +++++++++++++++++++++ app/views/dmsf/_main.html.erb | 14 +-------- app/views/dmsf_upload/multi_upload.html.erb | 3 ++ app/views/dmsf_upload/upload_files.html.erb | 6 +--- 5 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 app/views/dmsf/_description.html.erb diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index 377a5f45..63d2a44c 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -29,6 +29,7 @@ class DmsfUploadController < ApplicationController before_action :authorize_global, only: [:upload, :delete_dmsf_attachment, :delete_dmsf_link_attachment] before_action :find_folder, except: [:upload, :commit, :delete_dmsf_attachment, :delete_dmsf_link_attachment] before_action :permissions, except: [:upload, :commit, :delete_dmsf_attachment, :delete_dmsf_link_attachment] + before_action :wiki, only: [:multi_upload, :upload_files] helper :all helper :dmsf_workflows @@ -41,7 +42,6 @@ class DmsfUploadController < ApplicationController end def upload_files - @wiki = Setting.text_formatting != 'HTML' uploaded_files = params[:dmsf_attachments] @uploads = [] if uploaded_files @@ -145,4 +145,8 @@ class DmsfUploadController < ApplicationController render_403 end + def wiki + @wiki = Setting.text_formatting != 'HTML' + end + end diff --git a/app/views/dmsf/_description.html.erb b/app/views/dmsf/_description.html.erb new file mode 100644 index 00000000..654805c0 --- /dev/null +++ b/app/views/dmsf/_description.html.erb @@ -0,0 +1,35 @@ +<% +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-21 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 @project %> +
+ <% if @wiki %> +
+ <%= textilizable @folder ? @folder.description : @project.dmsf_description %> +
+ <% else %> +
+ <%= h @folder ? @folder.description : @project.dmsf_description %> +
+ <% end %> +
+<% end %> diff --git a/app/views/dmsf/_main.html.erb b/app/views/dmsf/_main.html.erb index ea84fd45..61bb1fae 100644 --- a/app/views/dmsf/_main.html.erb +++ b/app/views/dmsf/_main.html.erb @@ -60,19 +60,7 @@ <%= render partial: 'path', locals: { folder: @folder, filename: nil, title: nil } %> -<% if @project %> -
- <% if @wiki %> -
- <%= textilizable @folder ? @folder.description : @project.dmsf_description %> -
- <% else %> -
- <%= h @folder ? @folder.description : @project.dmsf_description %> -
- <% end %> -
-<% end %> +<%= render partial: 'description' %> <%= form_tag(@project ? dmsf_folder_path(id: @project, folder_id: @folder) : dmsf_index_path, method: :get, id: 'query_form', class: 'dmsf-query-form') do %> diff --git a/app/views/dmsf_upload/multi_upload.html.erb b/app/views/dmsf_upload/multi_upload.html.erb index e59a75b6..25b1d031 100644 --- a/app/views/dmsf_upload/multi_upload.html.erb +++ b/app/views/dmsf_upload/multi_upload.html.erb @@ -22,6 +22,9 @@ <%= render partial: '/dmsf/path', locals: { folder: @folder, filename: nil, title: l(:label_attachment_new) } %> + +<%= render partial: 'dmsf/description' %> + <%= form_tag({ controller: 'dmsf_upload', action: 'upload_files', id: @project, folder_id: @folder }, { id: 'uploadform', multipart: true }) do %>
diff --git a/app/views/dmsf_upload/upload_files.html.erb b/app/views/dmsf_upload/upload_files.html.erb index 2232bfed..55eac3a8 100644 --- a/app/views/dmsf_upload/upload_files.html.erb +++ b/app/views/dmsf_upload/upload_files.html.erb @@ -33,11 +33,7 @@
<% end %> -<% if (@folder && @folder.description.present?) || @project.dmsf_description.present? %> -
- <%= textilizable(@folder ? @folder.description : @project.dmsf_description) %> -
-<% end %> +<%= render partial: 'dmsf/description' %> <% unless @uploads.empty? %> <%= form_tag({ action: 'commit_files', id: @project, folder_id: @folder }, method: :post) do %>