#557 UI for watching documents

This commit is contained in:
Karel.Picman 2022-01-19 12:27:50 +01:00
parent 4faef673b0
commit e028d1f83c
9 changed files with 58 additions and 20 deletions

View File

@ -92,6 +92,9 @@ def dmsf_init
pmap.permission :display_system_folders,
read: true
# Watchers
pmap.permission :view_dmsf_file_watchers, {}, read: true
pmap.permission :add_dmsf_file_watchers, { watchers: [:new, :create, :append, :autocomplete_for_user]}
pmap.permission :delete_dmsf_file_watchers, { watchers: :destroy}
pmap.permission :view_dmsf_folder_watchers, {}, read: true
pmap.permission :add_dmsf_folder_watchers, { watchers: [:new, :create, :append, :autocomplete_for_user]}
pmap.permission :delete_dmsf_folder_watchers, { watchers: :destroy}

View File

@ -36,6 +36,8 @@ class DmsfFilesController < ApplicationController
helper :dmsf_workflows
helper :dmsf
helper :queries
helper :watchers
helper :context_menus
include QueriesHelper

View File

@ -82,6 +82,9 @@
(Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] != 'WEBDAV_READ_WRITE') %>
</li>
<% end %>
<li>
<%= render partial: 'dmsf_context_menus/watch', locals: { object: dmsf_file } %>
</li>
<li>
<%= context_menu_link l(:button_delete),
dmsf_link ? dmsf_link_path(id: dmsf_link, folder_id: folder, back_url: back_url) : dmsf_file_path(id: dmsf_file,

View File

@ -72,14 +72,9 @@
disabled: !email_allowed %>
</li>
<% end %>
<% watched = Watcher.any_watched?([dmsf_folder], User.current) %>
<% css = [watcher_css([dmsf_folder]), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') %>
<% text = watched ? l(:button_unwatch) : l(:button_watch) %>
<% url = watch_path(object_type: dmsf_folder.class.to_s.underscore, object_id: dmsf_folder, back_url: back_url) %>
<% method = watched ? 'delete' : 'post' %>
<%= context_menu_link text, url, method: method, class: css, disabled: !User.current.logged? %>
<li>
<%= render partial: 'dmsf_context_menus/watch', locals: { object: dmsf_folder } %>
</li>
<li>
<%= context_menu_link l(:button_delete),
dmsf_link ? dmsf_link_path(id: dmsf_link, folder_id: folder, back_url: back_url) :

View File

@ -60,15 +60,7 @@
class: 'icon dmsf-icon-link' %>
<% end %>
<% end %>
<% object = folder ? folder : project %>
<% watched = Watcher.any_watched?([object], User.current) %>
<% css = [watcher_css([object]), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') %>
<% text = watched ? l(:button_unwatch) : l(:button_watch) %>
<% url = watch_path(object_type: object.class.to_s.underscore, object_id: object.id) %>
<% method = watched ? 'delete' : 'post' %>
<%= context_menu_link text, url, method: method, class: css, disabled: !User.current.logged? %>
<%= render partial: 'dmsf_context_menus/watch', locals: { object: folder ? folder : project } %>
<% if trash_enabled %>
<%= link_to l(:link_trash_bin), trash_dmsf_path(project), title: l(:link_trash_bin), class: 'icon icon-del' %>
<% else %>

View File

@ -39,5 +39,6 @@
<%= link_to "#{l(:button_copy)}/#{l(:button_move)}", copy_file_path(id: file, back_url: back_url),
title: l(:title_copy), class: 'icon icon-copy' %>
<%= link_to l(:button_download), view_dmsf_file_path(file, disposition: 'attachment'), class: 'icon icon-download' %>
<%= render partial: 'dmsf_context_menus/watch', locals: { object: file } %>
<%= delete_link(dmsf_file_path(id: file, details: true),
back_url: dmsf_folder_path(id: file.project, folder_id: file.dmsf_folder)) if file_delete_allowed %>

View File

@ -0,0 +1,30 @@
<%
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
#
# 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.
#
# Watch/unwatch menu's item
%>
<% watched = Watcher.any_watched?([object], User.current) %>
<% css = [watcher_css([object]), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') %>
<% text = watched ? l(:button_unwatch) : l(:button_watch) %>
<% url = watch_path(object_type: object.class.to_s.underscore, object_id: object.id) %>
<% method = watched ? 'delete' : 'post' %>
<%= context_menu_link text, url, method: method, class: css, disabled: !User.current.logged? %>

View File

@ -171,6 +171,14 @@
<% end %>
<span class="pagination"><%= pagination_links_full @revision_pages, @revision_count %></span>
<% if @file.watchers.present? %>
<% content_for :sidebar do %>
<div id="watchers">
<%= render partial: 'watchers/watchers', locals: { watched: @file } %>
</div>
<% end %>
<% end %>
<%= late_javascript_tag do %>
$('a.delete-revision').click(function(event) {
if(!window.confirm('<%= l(:text_are_you_sure) %>')) {

View File

@ -427,9 +427,13 @@ en:
label_project_watchers: Watchers
label_dmsf_folder_watchers: Watchers
permission_view_dmsf_folder_watchers: View watchers
permission_add_dmsf_folder_watchers: Add watchers
permission_delete_dmsf_folder_watchers: Delete watchers
label_dmsf_file_watchers: Watchers
permission_view_dmsf_folder_watchers: View folder's watchers
permission_add_dmsf_folder_watchers: Add folder's watchers
permission_delete_dmsf_folder_watchers: Delete folder's watchers
permission_view_dmsf_file_watchers: View document's watchers
permission_add_dmsf_file_watchers: Add document's watchers
permission_delete_dmsf_file_watchers: Delete document's watchers
permission_view_project_watchers: View project's watchers
permission_add_project_watchers: Add project's watchers
permission_delete_project_watchers: Delete project's watchers