A warning by deleting non-empty folders

This commit is contained in:
karel.picman@lbcfree.net 2020-12-10 10:41:40 +01:00
parent 0d5ebf2f1e
commit b5fc8ece60
20 changed files with 46 additions and 4 deletions

View File

@ -587,6 +587,10 @@ class DmsfFolder < ActiveRecord::Base
classes.join ' '
end
def empty?
!(dmsf_folders.visible.exists? || dmsf_files.visible.exists? || dmsf_links.visible.exists?)
end
private
def self.directory_subtree(tree, folder, level, current_folder)

View File

@ -49,7 +49,7 @@
<% end %>
<% unless @folder.locked? %>
<%= link_to l(:button_delete), delete_dmsf_path(id: @project, folder_id: @folder),
data: { confirm: l(:text_are_you_sure) },
data: { confirm: "#{l(:text_are_you_sure)}\n#{l(:text_not_empty) unless @folder.empty?}" },
title: l(:button_delete), class: 'icon icon-del', method: :delete %>
<% end %>
<% end %>

View File

@ -66,7 +66,8 @@
</li>
<li>
<%= context_menu_link l(:button_delete),
dmsf_link ? dmsf_link_path(id: dmsf_link, folder_id: folder) : delete_dmsf_path(id: project, folder_id: dmsf_folder, parent_id: folder),
data: { confirm: l(:text_are_you_sure) }, method: :delete, class: 'icon icon-del', id: 'dmsf-cm-delete',
disabled: !allowed || (locked && !dmsf_link) %>
dmsf_link ? dmsf_link_path(id: dmsf_link, folder_id: folder) :
delete_dmsf_path(id: project, folder_id: dmsf_folder, parent_id: folder),
data: { confirm: "#{l(:text_are_you_sure)}\n#{l(:text_not_empty) unless dmsf_folder.empty?}" }, method: :delete,
class: 'icon icon-del', id: 'dmsf-cm-delete', disabled: !allowed || (locked && !dmsf_link) %>
</li>

View File

@ -412,6 +412,8 @@ cs:
dmsf_webdav_ignore_1b_file_for_authentication: Ignorovat 1b soubor poslaný kvůli autentizaci
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: Adresář není prázdný.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ de:
dmsf_webdav_ignore_1b_file_for_authentication: Ignoriern 1b Datai geschickt wegen der Autorization
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: Der Ordner ist nich leer.
easy_pages:
modules:
dmsf_locked_documents: Von mir gesperrte Dokumente

View File

@ -412,6 +412,8 @@ en:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -412,6 +412,8 @@ es:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -412,6 +412,8 @@ fr:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ hu:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -412,6 +412,8 @@ it: # Italian strings thx 2 Matteo Arceci!
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -412,6 +412,8 @@ ja:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: 自分がロック中の文書

View File

@ -411,6 +411,8 @@ ko:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: 내 잠긴 파일

View File

@ -412,6 +412,8 @@ nl:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -412,6 +412,8 @@ pl:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -412,6 +412,8 @@ pt-BR:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -412,6 +412,8 @@ ru:
dmsf_webdav_ignore_1b_file_for_authentication: Игнорировать однобайтовый файл, отправляемый для аутентификации
dmsf_webdav_ignore_1b_file_for_authentication_info: Плагин WebDAV программы Total Commander
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: Мои заблокированные документы

View File

@ -412,6 +412,8 @@ sl:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ zh-TW:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -412,6 +412,8 @@ zh:
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
text_not_empty: The folder is not empty.
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -253,4 +253,9 @@ class DmsfFolderTest < RedmineDmsf::Test::UnitTest
assert !@folder1.save
end
def test_empty
assert !@folder1.empty?
assert @folder6.empty?
end
end