#557 Disabling legacy notifications

This commit is contained in:
Karel.Picman 2022-01-28 10:14:39 +01:00
parent 218bf47fdf
commit aa0574de37
11 changed files with 69 additions and 53 deletions

View File

@ -57,6 +57,7 @@ class DmsfContextMenusController < ApplicationController
User.current.allowed_to?(:folder_manipulation, @project)
@email_allowed = User.current.allowed_to?(:email_documents, @project)
end
@notifications = Setting.notified_events.include?('dmsf_legacy_notifications')
@back_url = dmsf_folder_path(id: @project, folder_id: @folder)
render layout: false
rescue ActiveRecord::RecordNotFound

View File

@ -80,6 +80,7 @@ class DmsfController < ApplicationController
@folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project)
@file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project)
@trash_enabled = @folder_manipulation_allowed && @file_manipulation_allowed
@notifications = Setting.notified_events.include?('dmsf_legacy_notifications')
@query.dmsf_folder_id = @folder ? @folder.id : nil
@query.deleted = false
@query.sub_projects |= Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders'].present?

View File

@ -85,6 +85,7 @@ class DmsfFilesController < ApplicationController
@file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project)
@revision_count = @file.dmsf_file_revisions.visible.all.size
@revision_pages = Paginator.new @revision_count, params['per_page'] ? params['per_page'].to_i : 25, params['page']
@notifications = Setting.notified_events.include?('dmsf_legacy_notifications')
respond_to do |format|
format.html {

View File

@ -42,7 +42,8 @@
project: @project,
locked_for_user: @locked_for_user,
file_manipulation_allowed: @file_manipulation_allowed,
trash_enabled: @trash_enabled } %>
trash_enabled: @trash_enabled,
notifications: @notifications } %>
<% else %>
<%= actions_dropdown do %>
<%= render partial: 'dmsf_context_menus/main', locals: {
@ -52,7 +53,8 @@
project: @project,
locked_for_user: @locked_for_user,
file_manipulation_allowed: @file_manipulation_allowed,
trash_enabled: @trash_enabled } %>
trash_enabled: @trash_enabled,
notifications: @notifications} %>
<% end %>
<% end %>
</div>

View File

@ -46,15 +46,17 @@
class: 'icon icon-lock', disabled: !allowed %>
<% end %>
</li>
<li>
<% if dmsf_file.notification %>
<%= context_menu_link l(:label_notifications_off), notify_deactivate_dmsf_files_path(id: dmsf_file,
back_url: back_url), class: 'icon icon-email', disabled: !allowed || locked %>
<% else %>
<%= context_menu_link l(:label_notifications_on), notify_activate_dmsf_files_path(id: dmsf_file,
back_url: back_url), class: 'icon icon-email-add', disabled: !allowed || locked %>
<% end %>
</li>
<% if notifications %>
<li>
<% if dmsf_file.notification %>
<%= context_menu_link l(:label_notifications_off), notify_deactivate_dmsf_files_path(id: dmsf_file,
back_url: back_url), class: 'icon icon-email', disabled: !allowed || locked %>
<% else %>
<%= context_menu_link l(:label_notifications_on), notify_activate_dmsf_files_path(id: dmsf_file,
back_url: back_url), class: 'icon icon-email-add', disabled: !allowed || locked %>
<% end %>
</li>
<% end %>
<li>
<%= render partial: 'approval_workflow', locals: { dmsf_file: dmsf_file, project: project, locked: locked,
back_url: back_url } %>

View File

@ -49,17 +49,19 @@
<% end %>
</li>
<% end %>
<li>
<% if dmsf_folder.notification %>
<%= context_menu_link l(:label_notifications_off), notify_deactivate_dmsf_path(id: dmsf_folder.project,
folder_id: dmsf_folder, back_url: back_url), class: 'icon icon-email',
disabled: !allowed || locked || !dmsf_folder.notification? %>
<% else %>
<%= context_menu_link l(:label_notifications_on), notify_activate_dmsf_path(id: dmsf_folder.project,
folder_id: dmsf_folder, back_url: back_url), class: 'icon icon-email-add',
disabled: !allowed || locked || dmsf_folder.notification? %>
<% end %>
</li>
<% if notifications %>
<li>
<% if dmsf_folder.notification %>
<%= context_menu_link l(:label_notifications_off), notify_deactivate_dmsf_path(id: dmsf_folder.project,
folder_id: dmsf_folder, back_url: back_url), class: 'icon icon-email',
disabled: !allowed || locked || !dmsf_folder.notification? %>
<% else %>
<%= context_menu_link l(:label_notifications_on), notify_activate_dmsf_path(id: dmsf_folder.project,
folder_id: dmsf_folder, back_url: back_url), class: 'icon icon-email-add',
disabled: !allowed || locked || dmsf_folder.notification? %>
<% end %>
</li>
<% end %>
<% unless edit %>
<li>
<%= context_menu_link l(:button_download), entries_operations_dmsf_path(id: project, folder_id: folder,

View File

@ -42,16 +42,18 @@
title: l(:title_lock_folder), class: 'icon icon-lock') %>
<% end %>
<% end %>
<% if !locked_for_user && ((folder && folder.notification) || (!folder && project.dmsf_notification)) %>
<%= link_to l(:label_notifications_off),
notify_deactivate_dmsf_path(id: project, folder_id: folder),
title: l(:title_notifications_active_deactivate),
class: 'icon icon-email' %>
<% else %>
<%= link_to l(:label_notifications_on),
notify_activate_dmsf_path(id: project, folder_id: folder),
title: l(:title_notifications_not_active_activate),
class: 'icon icon-email-add' %>
<% if notifications %>
<% if !locked_for_user && ((folder && folder.notification) || (!folder && project.dmsf_notification)) %>
<%= link_to l(:label_notifications_off),
notify_deactivate_dmsf_path(id: project, folder_id: folder),
title: l(:title_notifications_active_deactivate),
class: 'icon icon-email' %>
<% else %>
<%= link_to l(:label_notifications_on),
notify_activate_dmsf_path(id: project, folder_id: folder),
title: l(:title_notifications_not_active_activate),
class: 'icon icon-email-add' %>
<% end %>
<% end %>
<% if file_manipulation_allowed && !locked_for_user %>
<%= link_to l(:label_link_from),

View File

@ -20,16 +20,18 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%>
<% if file.notification %>
<%= link_to l(:label_notifications_off),
notify_deactivate_dmsf_files_path(id: file, back_url: back_url),
title: l(:title_notifications_active_deactivate),
class: 'icon icon-email' %>
<% else %>
<%= link_to l(:label_notifications_on),
notify_activate_dmsf_files_path(id: file, back_url: back_url),
title: l(:title_notifications_not_active_activate),
class: 'icon icon-email-add' %>
<% if notifications %>
<% if file.notification %>
<%= link_to l(:label_notifications_off),
notify_deactivate_dmsf_files_path(id: file, back_url: back_url),
title: l(:title_notifications_active_deactivate),
class: 'icon icon-email' %>
<% else %>
<%= link_to l(:label_notifications_on),
notify_activate_dmsf_files_path(id: file, back_url: back_url),
title: l(:title_notifications_not_active_activate),
class: 'icon icon-email-add' %>
<% end %>
<% end %>
<%= link_to l(:label_link_to),
new_dmsf_link_path(project_id: project.id, dmsf_folder_id: file.dmsf_folder ? file.dmsf_folder.id : nil,

View File

@ -24,12 +24,13 @@
<% if @dmsf_file %>
<%= render partial: 'file', locals: { project: @project, folder: @folder, dmsf_file: @dmsf_file,
dmsf_link: @dmsf_link, locked: @locked, unlockable: @unlockable,
allowed: @allowed, email_allowed: @email_allowed, back_url: @back_url } %>
allowed: @allowed, email_allowed: @email_allowed,
notifications: @notifications, back_url: @back_url } %>
<% elsif @dmsf_folder %>
<%= render partial: 'folder', locals: { project: @project, folder: @folder, dmsf_folder: @dmsf_folder,
dmsf_link: @dmsf_link, locked: @locked, unlockable: @unlockable,
allowed: @allowed, email_allowed: @email_allowed, edit: false,
back_url: @back_url } %>
notifications: @notifications, back_url: @back_url } %>
<% elsif @dmsf_link %>
<%= render partial: 'url', locals: { dmsf_link: @dmsf_link, allowed: @allowed, back_url: @back_url } %>
<% else %>

View File

@ -44,12 +44,12 @@
<% if defined?(EasyExtensions) %>
<%= render partial: 'dmsf_context_menus/revisions',
locals: { project: @project, file: @file, file_delete_allowed: @file_delete_allowed,
back_url: dmsf_file_path(id: @file)} %>
notifications: @notifications, back_url: dmsf_file_path(id: @file)} %>
<% else %>
<%= actions_dropdown do %>
<%= render partial: 'dmsf_context_menus/revisions',
locals: { project: @project, file: @file, file_delete_allowed: @file_delete_allowed,
back_url: dmsf_file_path(id: @file) } %>
notifications: @notifications, back_url: dmsf_file_path(id: @file) } %>
<% end %>
<% end %>
<% end %>

View File

@ -23,13 +23,15 @@
<% if member %>
<fieldset class="box tabular">
<legend><%= l(:link_user_preferences) %></legend>
<p>
<%= content_tag :label, l(:label_notifications) %>
<%= select_tag 'email_notify',
options_for_select([[l(:select_option_default), nil],
[l(:select_option_activated), true], [l(:select_option_deactivated), false]],
selected: member.dmsf_mail_notification) %>
</p>
<% if Setting.notified_events.include?('dmsf_legacy_notifications') %>
<p>
<%= content_tag :label, l(:label_notifications) %>
<%= select_tag 'email_notify',
options_for_select([[l(:select_option_default), nil],
[l(:select_option_activated), true], [l(:select_option_deactivated), false]],
selected: member.dmsf_mail_notification) %>
</p>
<% end %>
<p>
<%= content_tag :label, l(:label_title_format) %>
<%= text_field_tag 'title_format', member.dmsf_title_format, size: 10 %>