This commit is contained in:
1redmine 2025-06-19 09:43:25 +02:00
parent ee35b99877
commit 14f649c112
5 changed files with 40 additions and 19 deletions

View File

@ -30,7 +30,7 @@ module DmsfQueriesHelper
case item.type case item.type
when 'file' when 'file'
file = DmsfFile.find_by(id: item.id) file = DmsfFile.find_by(id: item.id)
if file&.locked? if !item.deleted && file&.locked?
return content_tag(:span, val) + return content_tag(:span, val) +
link_to(sprite_icon('unlock', nil, icon_only: true, size: '12'), link_to(sprite_icon('unlock', nil, icon_only: true, size: '12'),
unlock_dmsf_files_path(id: file, unlock_dmsf_files_path(id: file,
@ -40,7 +40,7 @@ module DmsfQueriesHelper
end end
when 'folder' when 'folder'
folder = DmsfFolder.find_by(id: item.id) folder = DmsfFolder.find_by(id: item.id)
if folder&.locked? if !item.deleted && folder&.locked?
return content_tag(:span, val) + return content_tag(:span, val) +
link_to(sprite_icon('unlock', nil, icon_only: true, size: '12'), link_to(sprite_icon('unlock', nil, icon_only: true, size: '12'),
unlock_dmsf_path(id: folder.project, unlock_dmsf_path(id: folder.project,
@ -110,7 +110,8 @@ module DmsfQueriesHelper
when 'project' when 'project'
tag = h("[#{value}]") tag = h("[#{value}]")
tag = if item.project.module_enabled?(:dmsf) tag = if item.project.module_enabled?(:dmsf)
link_to(sprite_icon('folder', nil, icon_only: true), dmsf_folder_path(id: item.project)) + link_to(sprite_icon('folder', nil, icon_only: true), dmsf_folder_path(id: item.project),
class: 'icon icon-folder') +
link_to(tag, dmsf_folder_path(id: item.project), class: 'dmsf-label') link_to(tag, dmsf_folder_path(id: item.project), class: 'dmsf-label')
else else
sprite_icon 'folder', tag sprite_icon 'folder', tag
@ -130,7 +131,7 @@ module DmsfQueriesHelper
) + tag ) + tag
tag = content_tag('div', tag, class: 'row-control dmsf-row-control') tag = content_tag('div', tag, class: 'row-control dmsf-row-control')
end end
tag += content_tag('div', item.filename, class: 'dmsf-filename', title: l(:title_filename_for_download)) tag += content_tag('div', item.filename, class: 'dmsf-filename')
if item.project.watched_by?(User.current) if item.project.watched_by?(User.current)
tag += link_to(sprite_icon('fav', nil, icon_only: true, size: '12'), tag += link_to(sprite_icon('fav', nil, icon_only: true, size: '12'),
watch_path(object_type: 'project', object_id: item.project.id), watch_path(object_type: 'project', object_id: item.project.id),
@ -141,12 +142,12 @@ module DmsfQueriesHelper
tag tag
when 'folder' when 'folder'
if item&.deleted? if item&.deleted?
tag = sprite_icon('folder', h(value)) tag = content_tag(:span, sprite_icon('folder', h(value)), class: 'icon icon-folder')
else else
tag = link_to(sprite_icon('folder', nil, tag = link_to(sprite_icon('folder', nil,
icon_only: true, icon_only: true,
css_class: item.system ? 'dmsf-system' : ''), css_class: item.system ? 'dmsf-system' : ''),
dmsf_folder_path(id: item.project, folder_id: item.id)) dmsf_folder_path(id: item.project, folder_id: item.id), class: 'icon icon-folder')
tag += link_to(h(value), dmsf_folder_path(id: item.project, folder_id: item.id), class: 'dmsf-label') tag += link_to(h(value), dmsf_folder_path(id: item.project, folder_id: item.id), class: 'dmsf-label')
unless filter_any? unless filter_any?
path = expand_folder_dmsf_path path = expand_folder_dmsf_path
@ -175,19 +176,20 @@ module DmsfQueriesHelper
tag tag
when 'folder-link' when 'folder-link'
if item&.deleted? if item&.deleted?
tag = sprite_icon('folder', h(value)) tag = content_tag(:span, sprite_icon('folder', h(value)), class: 'icon icon-folder')
else else
# For links, we use revision_id containing dmsf_folder.id in fact # For links, we use revision_id containing dmsf_folder.id in fact
tag = link_to(sprite_icon('folder', nil, icon_only: true, css_class: 'dmsf-gray'), tag = link_to(sprite_icon('folder', nil, icon_only: true, css_class: 'dmsf-gray'),
dmsf_folder_path(id: item.project, folder_id: item.revision_id)) dmsf_folder_path(id: item.project, folder_id: item.revision_id), class: 'icon icon-folder')
tag += link_to(h(value), dmsf_folder_path(id: item.project, folder_id: item.revision_id), class: 'dmsf-label') tag += link_to(h(value), dmsf_folder_path(id: item.project, folder_id: item.revision_id), class: 'dmsf-label')
tag = content_tag('span', '', class: 'dmsf-expander') + tag unless filter_any? tag = content_tag('span', '', class: 'dmsf-expander') + tag unless filter_any?
end end
tag + content_tag('div', item.filename, class: 'dmsf-filename', title: l(:label_target_folder)) tag + content_tag('div', item.filename, class: 'dmsf-filename', title: l(:label_target_folder))
when 'file', 'file-link' when 'file', 'file-link'
icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(item.filename)) icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(item.filename))
icon_class = icon_class_for_mime_type(item.filename)
if item&.deleted? if item&.deleted?
tag = sprite_icon(icon_name, h(value)) tag = content_tag(:span, sprite_icon(icon_name, h(value)), class: "icon #{icon_class}")
else else
# For links, we use revision_id containing dmsf_file.id in fact # For links, we use revision_id containing dmsf_file.id in fact
file_view_url = url_for( file_view_url = url_for(
@ -195,7 +197,8 @@ module DmsfQueriesHelper
) )
content_type = Redmine::MimeType.of(item.filename) content_type = Redmine::MimeType.of(item.filename)
content_type = 'application/octet-stream' if content_type.blank? content_type = 'application/octet-stream' if content_type.blank?
options = { class: 'dmsf-label', 'data-downloadurl': "#{content_type}:#{h(value)}:#{file_view_url}" } options = { class: "dmsf-label icon #{icon_class}",
'data-downloadurl': "#{content_type}:#{h(value)}:#{file_view_url}" }
unless previewable?(item.filename, content_type) unless previewable?(item.filename, content_type)
options[:target] = '_blank' options[:target] = '_blank'
options[:rel] = 'noopener' options[:rel] = 'noopener'
@ -206,6 +209,7 @@ module DmsfQueriesHelper
css_class: item.type == 'file-link' ? 'dmsf-gray' : ''), css_class: item.type == 'file-link' ? 'dmsf-gray' : ''),
file_view_url, file_view_url,
options) options)
options[:class] = 'dmsf-label'
tag += link_to(h(value), file_view_url, options) tag += link_to(h(value), file_view_url, options)
tag = content_tag('span', '', class: 'dmsf-expander') + tag unless filter_any? tag = content_tag('span', '', class: 'dmsf-expander') + tag unless filter_any?
end end
@ -223,12 +227,13 @@ module DmsfQueriesHelper
tag tag
when 'url-link' when 'url-link'
if item&.deleted? if item&.deleted?
tag = sprite_icon('link', h(value)) tag = content_tag(:span, sprite_icon('link', h(value)), class: 'icon icon-link')
else else
tag = link_to(sprite_icon('link', nil, icon_only: true, css_class: 'dmsf-gray'), tag = link_to(sprite_icon('link', nil, icon_only: true, css_class: 'dmsf-gray'),
item.filename, item.filename,
target: '_blank', target: '_blank',
rel: 'noopener') rel: 'noopener',
class: 'icon icon-link')
tag += link_to(h(value), item.filename, target: '_blank', rel: 'noopener') tag += link_to(h(value), item.filename, target: '_blank', rel: 'noopener')
tag = content_tag('span', '', class: 'dmsf-expander') + tag unless filter_any? tag = content_tag('span', '', class: 'dmsf-expander') + tag unless filter_any?
end end
@ -307,4 +312,15 @@ module DmsfQueriesHelper
Redmine::MimeType.is_type?('text', filename) || Redmine::SyntaxHighlighting.filename_supported?(filename) Redmine::MimeType.is_type?('text', filename) || Redmine::SyntaxHighlighting.filename_supported?(filename)
end end
end end
def icon_class_for_mime_type(mime)
case Redmine::MimeType.of(mime)
when 'application/pdf'
'icon-pdf'
when 'text/plain'
'icon-txt'
else
'icon-file'
end
end
end end

View File

@ -26,7 +26,6 @@
file_view_url, file_view_url,
target: '_blank', target: '_blank',
rel: 'noopener', rel: 'noopener',
class: 'icon icon-file',
title: h(dmsf_file.last_revision.try(:tooltip)), title: h(dmsf_file.last_revision.try(:tooltip)),
'data-downloadurl' => "#{dmsf_file.last_revision.detect_content_type}:#{h(dmsf_file.name)}:#{file_view_url}" %> 'data-downloadurl' => "#{dmsf_file.last_revision.detect_content_type}:#{h(dmsf_file.name)}:#{file_view_url}" %>
</td> </td>
@ -92,7 +91,7 @@
else else
dmsf_file_path(id: dmsf_file, commit: 'yes', back_url: issue_path(@issue)) dmsf_file_path(id: dmsf_file, commit: 'yes', back_url: issue_path(@issue))
end %> end %>
<%= delete_link url %> <%= delete_link url, {}, '' %>
<% end %> <% end %>
<% # Approval workflow %> <% # Approval workflow %>
<% wf = DmsfWorkflow.find_by(id: dmsf_file.last_revision.dmsf_workflow_id) if dmsf_file.last_revision.dmsf_workflow_id %> <% wf = DmsfWorkflow.find_by(id: dmsf_file.last_revision.dmsf_workflow_id) if dmsf_file.last_revision.dmsf_workflow_id %>

View File

@ -209,10 +209,12 @@ svg.dmsf-system {
.dmsf-hidden { display: none; } .dmsf-hidden { display: none; }
.dmsf-tree:not(.dmsf-child) span.dmsf-expander { cursor: pointer; } .dmsf-tree:not(.dmsf-child) span.dmsf-expander { cursor: pointer; }
.dmsf-tree.dmsf-expanded span.dmsf-expander { .dmsf-tree.dmsf-expanded span.dmsf-expander {
background: url("../../../images/arrow_down.png") no-repeat 0 50%;
padding-left: 16px; padding-left: 16px;
} }
.dmsf-tree.dmsf-child span.dmsf-expander { padding-left: 16px; } .dmsf-tree.dmsf-child span.dmsf-expander { padding-left: 16px; }
.dmsf-tree.dmsf-collapsed span.dmsf-expander { .dmsf-tree.dmsf-collapsed span.dmsf-expander {
background: url("../../../images/arrow_right.png") no-repeat 0 50%;
padding-left: 16px; padding-left: 16px;
} }
.dmsf-tree.idnt-1 td.dmsf-title { padding-left: 1.5em; } .dmsf-tree.idnt-1 td.dmsf-title { padding-left: 1.5em; }

View File

@ -22,6 +22,8 @@ module RedmineDmsf
module Views module Views
# Issue view hooks # Issue view hooks
class IssueViewHooks < Redmine::Hook::ViewListener class IssueViewHooks < Redmine::Hook::ViewListener
include DmsfQueriesHelper
def view_issues_form_details_bottom(context = {}) def view_issues_form_details_bottom(context = {})
return if defined?(EasyExtensions) return if defined?(EasyExtensions)
@ -216,14 +218,15 @@ module RedmineDmsf
html << '<td>' html << '<td>'
data = "#{dmsf_file.last_revision.detect_content_type}:#{h(dmsf_file.name)}:#{file_view_url}" data = "#{dmsf_file.last_revision.detect_content_type}:#{h(dmsf_file.name)}:#{file_view_url}"
icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(dmsf_file.name)) icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(dmsf_file.name))
icon_class = icon_class_for_mime_type(dmsf_file.name)
html << link_to(sprite_icon(icon_name, h(dmsf_file.title)), html << link_to(sprite_icon(icon_name, h(dmsf_file.title)),
file_view_url, file_view_url,
target: '_blank', target: '_blank',
rel: 'noopener', rel: 'noopener',
class: 'icon icon-file', class: "icon #{icon_class}",
title: h(dmsf_file.last_revision.try(:tooltip)), title: h(dmsf_file.last_revision.try(:tooltip)),
'data-downloadurl' => data) 'data-downloadurl' => data)
html << "<span class=\"size\">(#{number_to_human_size(dmsf_file.last_revision.size)})</span>" html << "<span class=\"size dmsf-size\">(#{number_to_human_size(dmsf_file.last_revision.size)})</span>"
html << " - #{h(dmsf_file.description)}" if dmsf_file.description.present? html << " - #{h(dmsf_file.description)}" if dmsf_file.description.present?
html << '</td>' html << '</td>'
# Author, updated at # Author, updated at
@ -287,7 +290,7 @@ module RedmineDmsf
else else
dmsf_file_path id: dmsf_file, commit: 'yes', back_url: back_url dmsf_file_path id: dmsf_file, commit: 'yes', back_url: back_url
end end
html << delete_link(url) html << delete_link(url, icon_only: true)
end end
end end
# Approval workflow # Approval workflow

View File

@ -106,8 +106,9 @@ module RedmineDmsf
parent.save parent.save
end end
if parent if parent
folder = DmsfFolder.issystem.where(["project_id = ? AND dmsf_folder_id = ? AND title LIKE '? - %'", folder = DmsfFolder.issystem.where(
project_id, parent.id, id]).first ['project_id = ? AND dmsf_folder_id = ? AND title LIKE ?', project_id, parent.id, "#{id} - %"]
).first
if create && !folder if create && !folder
folder = DmsfFolder.new folder = DmsfFolder.new
folder.dmsf_folder_id = parent.id folder.dmsf_folder_id = parent.id