From 59cf43312e14f31c40aa64c6f44257667063312e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Thu, 30 Jan 2025 10:18:07 +0100 Subject: [PATCH] Editing of locked folder #1557 --- app/controllers/dmsf_controller.rb | 2 +- app/models/dmsf_folder.rb | 4 ++-- app/views/dmsf/_main.html.erb | 6 +++--- app/views/dmsf/_path.html.erb | 4 ++++ app/views/dmsf_context_menus/_main.html.erb | 10 +++++----- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 73b648a92..e65e6cc00 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -78,7 +78,7 @@ def index def show @system_folder = @folder&.system - @locked_for_user = @folder&.locked_for_user? + @locked = @folder&.locked? @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 diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index f9ae94940..8ab4f41c3 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -567,7 +567,7 @@ def self.visible_folders(folders, project) def css_classes(trash) classes = [] if trash - if title.match?(/^\./) + if system classes << 'dmsf-system' else classes << 'hascontextmenu' @@ -581,7 +581,7 @@ def css_classes(trash) else classes << 'dmsf-child' end - if title.match?(/^\./) + if system classes << 'dmsf-system' else classes << 'hascontextmenu' diff --git a/app/views/dmsf/_main.html.erb b/app/views/dmsf/_main.html.erb index fe2742d00..066c3e0ff 100644 --- a/app/views/dmsf/_main.html.erb +++ b/app/views/dmsf/_main.html.erb @@ -21,7 +21,7 @@ <% html_title l(:dmsf) %> <% if @project %>
- <% unless @locked_for_user || @system_folder %> + <% unless @locked || @system_folder %> <% if @file_manipulation_allowed %> <%= link_to sprite_icon('add', l(:label_document_new)), multi_dmsf_upload_path(id: @project, folder_id: @folder), class: 'icon icon-add', @@ -38,7 +38,7 @@ system_folder: @system_folder, folder: @folder, project: @project, - locked_for_user: @locked_for_user, + locked: @locked, file_manipulation_allowed: @file_manipulation_allowed, trash_enabled: @trash_enabled, notifications: @notifications } %> @@ -49,7 +49,7 @@ system_folder: @system_folder, folder: @folder, project: @project, - locked_for_user: @locked_for_user, + locked: @locked, file_manipulation_allowed: @file_manipulation_allowed, trash_enabled: @trash_enabled, notifications: @notifications} %> diff --git a/app/views/dmsf/_path.html.erb b/app/views/dmsf/_path.html.erb index 82416d449..73e4b0a28 100644 --- a/app/views/dmsf/_path.html.erb +++ b/app/views/dmsf/_path.html.erb @@ -29,6 +29,10 @@ <%= link_to h(path_element.title), dmsf_folder_path(id: @project, folder_id: path_element) %> <% end %> <% end %> + <% if folder.locked? && !(filename || title) %> + <%= content_tag('span', sprite_icon('unlock', nil, icon_only: true, size: '12'), + title: l(:title_locked_by_user, user: folder.locked_by)) %> + <% end %> <% else %> <% if @project %> <%= link_to l(:link_documents), dmsf_folder_path(id: @project) %> diff --git a/app/views/dmsf_context_menus/_main.html.erb b/app/views/dmsf_context_menus/_main.html.erb index 6c149f047..32e5019d7 100644 --- a/app/views/dmsf_context_menus/_main.html.erb +++ b/app/views/dmsf_context_menus/_main.html.erb @@ -25,14 +25,14 @@ title: l(:link_edit, title: l(:link_documents)), class: 'icon icon-edit', data: { cy: 'button__edit--dmsf' } %> - <% elsif !locked_for_user %> + <% elsif !locked %> <%= link_to sprite_icon('edit', l(:button_edit)), edit_dmsf_path(id: project, folder_id: folder, redirect_to_folder_id: folder.id), title: l(:link_edit, title: h(folder.title)), class: 'icon icon-edit', data: { cy: 'button__edit--dmsf' } %> <% end %> - <% if folder && (!locked_for_user || User.current.allowed_to?(:force_file_unlock, project)) %> + <% if folder && (!locked || User.current.allowed_to?(:force_file_unlock, project)) %> <% if folder.locked? %> <%= link_to_if folder.unlockable?, sprite_icon('unlock', l(:button_unlock)), @@ -47,8 +47,8 @@ data: { cy: 'button__lock--dmsf' } %> <% end %> <% end %> - <% if notifications %> - <% if !locked_for_user && ((folder && folder.notification) || (!folder && project.dmsf_notification)) %> + <% if notifications && !locked %> + <% if ((folder && folder.notification) || (!folder && project.dmsf_notification)) %> <%= link_to sprite_icon('email', l(:label_notifications_off)), notify_deactivate_dmsf_path(id: project, folder_id: folder), title: l(:title_notifications_active_deactivate), @@ -62,7 +62,7 @@ data: { cy: 'button__notifications-on--dmsf' } %> <% end %> <% end %> - <% if file_manipulation_allowed && !locked_for_user %> + <% if file_manipulation_allowed && !locked %> <%= link_to sprite_icon('link', l(:label_link_from)), new_dmsf_link_path(project_id: project.id, dmsf_folder_id: folder ? folder.id : folder, type: 'link_from'),