Redmine 6.1's watch icon

This commit is contained in:
Karel Pičman 2025-10-02 16:52:34 +02:00
parent fb5fecb90f
commit 862097dccf
2 changed files with 6 additions and 5 deletions

View File

@ -133,7 +133,7 @@ module DmsfQueriesHelper
end end
tag += content_tag('div', item.filename, class: 'dmsf-filename') 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('unwatch', 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),
title: l(:button_unwatch), title: l(:button_unwatch),
method: 'delete', method: 'delete',
@ -167,7 +167,7 @@ module DmsfQueriesHelper
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', title: l(:title_filename_for_download))
if !item&.deleted? && item.watched_by?(User.current) if !item&.deleted? && item.watched_by?(User.current)
tag += link_to(sprite_icon('fav', nil, icon_only: true, size: '12'), tag += link_to(sprite_icon('unwatch', nil, icon_only: true, size: '12'),
watch_path(object_type: 'dmsf_folder', object_id: item.id), watch_path(object_type: 'dmsf_folder', object_id: item.id),
title: l(:button_unwatch), title: l(:button_unwatch),
method: 'delete', method: 'delete',
@ -218,7 +218,7 @@ module DmsfQueriesHelper
filename = revision ? revision.formatted_name(member) : item.filename filename = revision ? revision.formatted_name(member) : item.filename
tag += content_tag('div', filename, class: 'dmsf-filename', title: l(:title_filename_for_download)) 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) if (item.type == 'file') && !item&.deleted? && revision.dmsf_file&.watched_by?(User.current)
tag += link_to(sprite_icon('fav', nil, icon_only: true, size: '12'), tag += link_to(sprite_icon('unwatch', nil, icon_only: true, size: '12'),
watch_path(object_type: 'dmsf_file', object_id: item.id), watch_path(object_type: 'dmsf_file', object_id: item.id),
title: l(:button_unwatch), title: l(:button_unwatch),
method: 'delete', method: 'delete',

View File

@ -19,7 +19,8 @@
<% watched = object.watched_by?(User.current) %> <% watched = object.watched_by?(User.current) %>
<% css = [watcher_css([object]), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') %> <% css = [watcher_css([object]), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') %>
<% text = sprite_icon('fav', watched ? l(:button_unwatch) : l(:button_watch)) %> <% icon = watched ? 'unwatch' : 'watch' %>
<% text = watched ? l(:button_unwatch) : l(:button_watch) %>
<% url = watch_path(object_type: object.class.to_s.underscore, object_id: object.id) %> <% url = watch_path(object_type: object.class.to_s.underscore, object_id: object.id) %>
<% method = watched ? 'delete' : 'post' %> <% method = watched ? 'delete' : 'post' %>
<%= context_menu_link text, url, method: method, class: css, disabled: !User.current.logged? %> <%= context_menu_link sprite_icon(icon, text), url, method: method, class: css, disabled: !User.current.logged? %>