diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb
index e3174bb5..cd4b3b35 100644
--- a/app/models/dmsf_folder.rb
+++ b/app/models/dmsf_folder.rb
@@ -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)
diff --git a/app/views/dmsf/edit.html.erb b/app/views/dmsf/edit.html.erb
index b31c580a..1bc49ec1 100644
--- a/app/views/dmsf/edit.html.erb
+++ b/app/views/dmsf/edit.html.erb
@@ -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 %>
diff --git a/app/views/dmsf_context_menus/_file.html.erb b/app/views/dmsf_context_menus/_file.html.erb
index 794f63b1..adfbbb47 100644
--- a/app/views/dmsf_context_menus/_file.html.erb
+++ b/app/views/dmsf_context_menus/_file.html.erb
@@ -82,5 +82,5 @@
<%= context_menu_link l(:button_delete),
dmsf_link ? dmsf_link_path(id: dmsf_link, folder_id: folder) : dmsf_file_path(id: dmsf_file, folder_id: folder),
method: :delete, class: 'icon icon-del', data: { confirm: l(:text_are_you_sure) }, id: 'dmsf-cm-delete',
- disabled: !allowed || locked %>
+ disabled: !allowed || (locked && !dmsf_link) %>
diff --git a/app/views/dmsf_context_menus/_folder.html.erb b/app/views/dmsf_context_menus/_folder.html.erb
index 4ba89c60..62804c71 100644
--- a/app/views/dmsf_context_menus/_folder.html.erb
+++ b/app/views/dmsf_context_menus/_folder.html.erb
@@ -66,7 +66,8 @@
<%= 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_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) %>
diff --git a/config/locales/cs.yml b/config/locales/cs.yml
index 7a69314a..002f1e4b 100644
--- a/config/locales/cs.yml
+++ b/config/locales/cs.yml
@@ -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
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 232addcd..4b2e4e6c 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -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
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 71d0cbc6..cbea3481 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -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
diff --git a/config/locales/es.yml b/config/locales/es.yml
index c9dd5bd8..71e20c96 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -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
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index c82f0fa5..ee653d12 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -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
diff --git a/config/locales/hu.yml b/config/locales/hu.yml
index afd4cb96..4ca411e5 100644
--- a/config/locales/hu.yml
+++ b/config/locales/hu.yml
@@ -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
diff --git a/config/locales/it.yml b/config/locales/it.yml
index 449b7e8a..4dd11ac0 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -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
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index 0261953b..8e22ac90 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -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: 自分がロック中の文書
diff --git a/config/locales/ko.yml b/config/locales/ko.yml
index 112dd2e7..e3f752fe 100644
--- a/config/locales/ko.yml
+++ b/config/locales/ko.yml
@@ -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: 내 잠긴 파일
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index 4d8f996b..2e103ce6 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -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
diff --git a/config/locales/pl.yml b/config/locales/pl.yml
index 3469dda7..e439be44 100644
--- a/config/locales/pl.yml
+++ b/config/locales/pl.yml
@@ -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
diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml
index d7e81ab1..e5cb6727 100644
--- a/config/locales/pt-BR.yml
+++ b/config/locales/pt-BR.yml
@@ -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
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
index 4f2e9420..9de9e9af 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -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: Мои заблокированные документы
diff --git a/config/locales/sl.yml b/config/locales/sl.yml
index 027fde33..4c0cd975 100644
--- a/config/locales/sl.yml
+++ b/config/locales/sl.yml
@@ -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
diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml
index 5a88d3b8..6566c546 100644
--- a/config/locales/zh-TW.yml
+++ b/config/locales/zh-TW.yml
@@ -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
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 72cecd80..488d2315 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -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
diff --git a/test/functional/dmsf_context_menus_controller_test.rb b/test/functional/dmsf_context_menus_controller_test.rb
index 6a84a323..6b92fe7e 100644
--- a/test/functional/dmsf_context_menus_controller_test.rb
+++ b/test/functional/dmsf_context_menus_controller_test.rb
@@ -160,7 +160,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
assert_select 'a.icon-unlock', text: l(:button_unlock)
assert_select 'a.icon-lock', text: l(:button_lock), count: 0
assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on)
- assert_select 'a.icon-del.disabled', text: l(:button_delete)
+ assert_select 'a.icon-del', text: l(:button_delete)
end
def test_dmsf_url_link
diff --git a/test/unit/dmsf_folder_test.rb b/test/unit/dmsf_folder_test.rb
index c7eaa62b..45415b53 100644
--- a/test/unit/dmsf_folder_test.rb
+++ b/test/unit/dmsf_folder_test.rb
@@ -253,4 +253,9 @@ class DmsfFolderTest < RedmineDmsf::Test::UnitTest
assert !@folder1.save
end
+ def test_empty
+ assert !@folder1.empty?
+ assert @folder6.empty?
+ end
+
end
\ No newline at end of file