Skip to content

Commit

Permalink
Missing default browser context menu #1574
Browse files Browse the repository at this point in the history
  • Loading branch information
picman committed Jan 9, 2025
1 parent 00a8817 commit 77de451
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
51 changes: 24 additions & 27 deletions app/helpers/dmsf_queries_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ def column_value(column, item, value)
when 'file'
file = DmsfFile.find_by(id: item.id)
if file&.locked?
return content_tag(:span, val) + content_tag('span',
sprite_icon('unlock', ''),
title: l(:title_locked_by_user, user: file.locked_by),
class: 'icon icon-unlock dmsf-icon-unlock')
return content_tag(:span, val) +
content_tag('span', sprite_icon('unlock', nil, icon_only: true, size: '12'),
title: l(:title_locked_by_user, user: file.locked_by))
end
when 'folder'
folder = DmsfFolder.find_by(id: item.id)
if folder&.locked?
return content_tag(:span, val) + content_tag('span',
sprite_icon('unlock', ''),
title: l(:title_locked_by_user, user: folder.locked_by),
class: 'icon icon-unlock dmsf-icon-unlock')
return content_tag(:span, val) +
content_tag('span', sprite_icon('unlock', nil, icon_only: true, size: '12'),
title: l(:title_locked_by_user, user: folder.locked_by))
end
end
content_tag(:span, val) + content_tag(:span, '', class: 'icon icon-none')
Expand Down Expand Up @@ -127,19 +125,19 @@ def column_value(column, item, value)
end
tag += content_tag('div', item.filename, class: 'dmsf-filename', title: l(:title_filename_for_download))
if item.project.watched_by?(User.current)
tag += link_to(sprite_icon('unlock', ''),
tag += link_to(sprite_icon('fav', nil, icon_only: true, size: '12'),
watch_path(object_type: 'project', object_id: item.project.id),
title: l(:button_unwatch),
method: 'delete',
class: 'icon icon-fav')
method: 'delete')
end
tag
when 'folder'
if item&.deleted?
tag = sprite_icon('folder', h(value))
else
tag = link_to(sprite_icon('folder', h(value)),
tag = link_to(sprite_icon('folder', nil, icon_only: true),
dmsf_folder_path(id: item.project, folder_id: item.id))
tag += link_to(h(value), dmsf_folder_path(id: item.project, folder_id: item.id), class: 'dmsf-label')
unless filter_any?
path = expand_folder_dmsf_path
columns = params['c']
Expand All @@ -158,64 +156,63 @@ def column_value(column, item, value)
end
tag += content_tag('div', item.filename, class: 'dmsf-filename', title: l(:title_filename_for_download))
if !item&.deleted? && item.watched_by?(User.current)
tag += link_to(sprite_icon('fav', ''),
tag += link_to(sprite_icon('fav', nil, icon_only: true, size: '12'),
watch_path(object_type: 'dmsf_folder', object_id: item.id),
title: l(:button_unwatch),
method: 'delete',
class: 'icon icon-fav')
method: 'delete')
end
tag
when 'folder-link'
if item&.deleted?
tag = sprite_icon('folder', h(value))
else
# For links, we use revision_id containing dmsf_folder.id in fact
tag = link_to(sprite_icon('folder', h(value)), dmsf_folder_path(id: item.project,
folder_id: item.revision_id))
tag = link_to(sprite_icon('folder', nil, icon_only: true),
dmsf_folder_path(id: item.project, folder_id: item.revision_id))
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?
end
tag + content_tag('div', item.filename, class: 'dmsf-filename', title: l(:label_target_folder))
when 'file', 'file-link'
icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(item.filename))
if item&.deleted?
tag = sprite_icon(icon_name, h(value), css_class: 'icon icon-file')
tag = sprite_icon(icon_name, h(value))
else
# For links, we use revision_id containing dmsf_file.id in fact
file_view_url = url_for(
{ controller: :dmsf_files, action: 'view', id: item.type == 'file' ? item.id : item.revision_id }
)
content_type = Redmine::MimeType.of(item.filename)
content_type = 'application/octet-stream' if content_type.blank?
options = { class: 'icon icon-file', 'data-downloadurl': "#{content_type}:#{h(value)}:#{file_view_url}" }
options = { class: 'dmsf-label', 'data-downloadurl': "#{content_type}:#{h(value)}:#{file_view_url}" }
unless previewable?(item.filename, content_type)
options[:target] = '_blank'
options[:rel] = 'noopener'
end
tag = link_to(sprite_icon(icon_name, h(value)), file_view_url, options)

tag = link_to(sprite_icon(icon_name, nil, icon_only: true), file_view_url, options)
tag += link_to(h(value), file_view_url, options)
tag = content_tag('span', '', class: 'dmsf-expander') + tag unless filter_any?
end
member = Member.find_by(user_id: User.current.id, project_id: item.project_id)
revision = DmsfFileRevision.find_by(id: item.customized_id)
filename = revision ? revision.formatted_name(member) : item.filename
tag += content_tag('div', filename, class: 'dmsf-filename', title: l(:title_filename_for_download))
if (item.type == 'file') && !item&.deleted? && revision.dmsf_file&.watched_by?(User.current)
tag += link_to(sprite_icon('fav', ''),
tag += link_to(sprite_icon('fav', nil, icon_only: true, size: '12'),
watch_path(object_type: 'dmsf_file', object_id: item.id),
title: l(:button_unwatch),
method: 'delete',
class: 'icon icon-fav')
method: 'delete')
end
tag
when 'url-link'
if item&.deleted?
tag = sprite_icon('link', h(value))
else
tag = link_to(sprite_icon('link', h(value)),
tag = link_to(sprite_icon('link', nil, icon_only: true),
item.filename,
target: '_blank',
rel: 'noopener',
class: 'icon dmsf-icon-link')
rel: 'noopener')
tag += link_to(h(value), item.filename, target: '_blank', rel: 'noopener', class: 'dmsf-link')
tag = content_tag('span', '', class: 'dmsf-expander') + tag unless filter_any?
end
tag + content_tag('div', item.filename, class: 'dmsf-filename', title: l(:field_url))
Expand Down
4 changes: 4 additions & 0 deletions assets/stylesheets/redmine_dmsf.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
min-width: 18px;
}

a.dmsf-label {
margin-left: 4px;
}

/* Query form */
.query-columns > span { /* EasyExtension */
display: inline-block;
Expand Down

0 comments on commit 77de451

Please sign in to comment.