diff --git a/app/controllers/dmsf_files_copy_controller.rb b/app/controllers/dmsf_files_copy_controller.rb index 1cf44adf..7c4e67c5 100644 --- a/app/controllers/dmsf_files_copy_controller.rb +++ b/app/controllers/dmsf_files_copy_controller.rb @@ -32,8 +32,12 @@ class DmsfFilesCopyController < ApplicationController accept_api_auth :copy, :move def new - @projects = DmsfFile.allowed_target_projects_on_copy - @folders = DmsfFolder.directory_tree(@target_project, @folder) + member = Member.find_by(project_id: @project.id, user_id: User.current.id) + @fast_links = member && member.dmsf_fast_links + unless @fast_links + @projects = DmsfFile.allowed_target_projects_on_copy + @folders = DmsfFolder.directory_tree(@target_project, @folder) + end @back_url = params[:back_url] render layout: !request.xhr? end @@ -105,6 +109,8 @@ private target_project_id = params[:target_project_id] elsif params[:dmsf_file_or_folder] && params[:dmsf_file_or_folder][:target_project_id].present? target_project_id = params[:dmsf_file_or_folder][:target_project_id] + else + target_project_id = @target_folder&.project_id end @target_project = target_project_id ? Project.visible.find(target_project_id) : @project rescue ActiveRecord::RecordNotFound diff --git a/app/controllers/dmsf_folders_copy_controller.rb b/app/controllers/dmsf_folders_copy_controller.rb index d7bbcf9f..92139acb 100644 --- a/app/controllers/dmsf_folders_copy_controller.rb +++ b/app/controllers/dmsf_folders_copy_controller.rb @@ -32,9 +32,13 @@ class DmsfFoldersCopyController < ApplicationController accept_api_auth :copy, :move def new - @projects = DmsfFolder.allowed_target_projects_on_copy - @folders = DmsfFolder.directory_tree(@target_project, @folder) - @target_folder = DmsfFolder.visible.find(params[:target_folder_id]) unless params[:target_folder_id].blank? + member = Member.find_by(project_id: @project.id, user_id: User.current.id) + @fast_links = member && member.dmsf_fast_links + unless @fast_links + @projects = DmsfFolder.allowed_target_projects_on_copy + @folders = DmsfFolder.directory_tree(@target_project, @folder) + @target_folder = DmsfFolder.visible.find(params[:target_folder_id]) unless params[:target_folder_id].blank? + end @back_url = params[:back_url] render layout: !request.xhr? end @@ -105,6 +109,7 @@ class DmsfFoldersCopyController < ApplicationController target_folder_id = params[:dmsf_file_or_folder][:target_folder_id] @target_folder = DmsfFolder.find(target_folder_id) raise ActiveRecord::RecordNotFound unless DmsfFolder.visible.where(id: target_folder_id).exists? + @target_project = @target_folder&.project end rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/views/dmsf_files_copy/new.html.erb b/app/views/dmsf_files_copy/new.html.erb index 0aa44324..5af4c0ee 100644 --- a/app/views/dmsf_files_copy/new.html.erb +++ b/app/views/dmsf_files_copy/new.html.erb @@ -33,4 +33,5 @@ file_or_folder: @file, target_folder: @target_folder, permission: :file_manipulation, + fast_links: @fast_links, back_url: @back_url } %> diff --git a/app/views/dmsf_folders_copy/_form.html.erb b/app/views/dmsf_folders_copy/_form.html.erb index 9ff70259..15d8a0ce 100644 --- a/app/views/dmsf_folders_copy/_form.html.erb +++ b/app/views/dmsf_folders_copy/_form.html.erb @@ -20,19 +20,25 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. %> -<% if projects.present? %> +<% if projects.present? || fast_links %> <%= form_tag({ action: 'copy', id: file_or_folder}, id: 'copyForm') do %> <%= hidden_field_tag 'back_url', back_url %>
+ <%= label_tag 'dmsf_file_or_folder[target_project_id]', l(:field_target_project) %> + <%= select_tag 'dmsf_file_or_folder[target_project_id]', + project_tree_options_for_select(projects, selected: target_project) %> +
+ <% end %>- <%= label_tag 'dmsf_file_or_folder[target_project_id]', l(:field_target_project) %> - <%= select_tag 'dmsf_file_or_folder[target_project_id]', - project_tree_options_for_select(projects, selected: target_project) %> -
-- <%= label_tag 'dmsf_file_or_folder[target_folder_id]', l(:field_target_folder) %> - <%= select_tag 'dmsf_file_or_folder[target_folder_id]', - options_for_select(folders, selected: (target_folder.id if target_folder)) %> + <%= label_tag 'dmsf_file_or_folder[target_folder_id]', l(:field_target_folder) %><%= ' #' if fast_links %> + <% if fast_links %> + <%= text_field_tag 'dmsf_file_or_folder[target_folder_id]', '', required: true, max_length: 255 %> + <% else %> + <%= select_tag 'dmsf_file_or_folder[target_folder_id]', + options_for_select(folders, selected: (target_folder.id if target_folder)) %> + <% end %>
@@ -49,9 +55,11 @@ $('#copyForm').attr('action', "<%= url_for(action: 'move', id: file_or_folder) %>"); $('#copyForm').submit(); }); - $('#target_project_id').change(function () { - $('#content').load("<%= url_for(action: 'new') %>", $('#copyForm').serialize()); - }); - $('#target_project_id').select2(); - $('#target_folder_id').select2(); + <% unless fast_links %> + $('#target_project_id').change(function () { + $('#content').load("<%= url_for(action: 'new') %>", $('#copyForm').serialize()); + }); + $('#target_project_id').select2(); + $('#target_folder_id').select2(); + <% end %> <% end %> diff --git a/app/views/dmsf_folders_copy/new.html.erb b/app/views/dmsf_folders_copy/new.html.erb index 3db90880..e5c5fb04 100644 --- a/app/views/dmsf_folders_copy/new.html.erb +++ b/app/views/dmsf_folders_copy/new.html.erb @@ -32,4 +32,5 @@ file_or_folder: @folder, target_folder: @target_folder, permission: :folder_manipulation, + fast_links: @fast_links, back_url: @back_url} %> diff --git a/config/locales/cs.yml b/config/locales/cs.yml index fe601144..0abea358 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -393,7 +393,7 @@ cs: label_dmsf_fast_links: Rychlé odkazy text_dmsf_fast_links_info: Při vytváření odkazů budete moci zadat přímo ID cílového adresáře za účelem zrychlení - procesu vytváření odkazů. + procesu vytváření odkazů nebo kopírování dokumentů a adresářů. label_dmsf_permissions: Povolený přístup pro label_inherited_permissions: Zděděný přístup pro diff --git a/config/locales/de.yml b/config/locales/de.yml index e56cd346..58a910e1 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -388,7 +388,8 @@ de: z.B. XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Schnelle Verknüpfung - text_dmsf_fast_links_info: Ermöglicht durch Eingabe der Ordner-ID auf einfache Art und Weise eine Verknüpfung auf den Zielordner zu erstellen. + text_dmsf_fast_links_info: Ermöglicht durch Eingabe der Ordner-ID auf einfache Art und Weise eine Verknüpfung + auf den Zielordner zu erstellen. label_dmsf_permissions: Zugriff erlaubt für label_inherited_permissions: Zugriff vererbt für diff --git a/config/locales/en.yml b/config/locales/en.yml index 03990e8f..ae85d74f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -392,8 +392,8 @@ en: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/es.yml b/config/locales/es.yml index 1e37548b..3bc59bf7 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -392,8 +392,8 @@ es: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 7e76dfc2..39bdf8ac 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -392,8 +392,8 @@ fr: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/hu.yml b/config/locales/hu.yml index aba03e02..163f3d1d 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -391,8 +391,8 @@ hu: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/it.yml b/config/locales/it.yml index 135dee2f..416e2521 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -392,8 +392,8 @@ it: # Italian strings thx 2 Matteo Arceci! e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/ja.yml b/config/locales/ja.yml index e613e927..0e9fcf13 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -392,7 +392,8 @@ ja: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: 高速リンク - text_dmsf_fast_links_info: ターゲットフォルダのIDを手動で入力することで、リンク作成時のプロセスを高速化することができます。 + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 0141bbe6..a04a17c0 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -392,7 +392,8 @@ ko: label_dmsf_fast_links: 빠른 링크 - text_dmsf_fast_links_info: 링크 생성을 더 빨리할 수 있도록 링크 생성 시에 대상 폴더의 식별자를 직접 입력할 수 있게 됩니다. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 90a37799..d08d18d3 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -392,8 +392,8 @@ nl: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/pl.yml b/config/locales/pl.yml index f028310d..d168def0 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -392,8 +392,8 @@ pl: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index bf35b1a0..33e6e9ec 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -392,8 +392,8 @@ pt-BR: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 74c37a9d..8c178241 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -392,8 +392,8 @@ ru: Пример: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Быстрые ссылки - text_dmsf_fast_links_info: Вы сможете вручную ввести ID целевого каталога при создании ссылок, чтобы ускорить - процесс создания ссылок. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Разрешить доступ только для label_inherited_permissions: Унаследованный доступ для diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 7202c054..d479e44a 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -392,8 +392,8 @@ sl: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index a82175b0..b3cacf94 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -391,8 +391,8 @@ zh-TW: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/config/locales/zh.yml b/config/locales/zh.yml index deb1f586..ed6d7c25 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -392,8 +392,8 @@ zh: e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" label_dmsf_fast_links: Fast links - text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed - up the process of creating links. + text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files + or folders in order to speed up the process of creating links. label_dmsf_permissions: Allow access only to label_inherited_permissions: Inherited Access for diff --git a/test/functional/dmsf_files_copy_controller_test.rb b/test/functional/dmsf_files_copy_controller_test.rb index 3f329a1f..1cb3d4ce 100644 --- a/test/functional/dmsf_files_copy_controller_test.rb +++ b/test/functional/dmsf_files_copy_controller_test.rb @@ -163,5 +163,22 @@ class DmsfFilesCopyControllerTest < RedmineDmsf::Test::TestCase post :move, params: { id: @file9.id, dmsf_file_or_folder: { target_project_id: @project2.id } } assert_response :forbidden end + + def test_new_fast_links_enabled + member = Member.find_by(user_id: @jsmith.id, project_id: @project1.id) + assert member + member.update_attribute :dmsf_fast_links, true + get :new, params: { id: @file1.id } + assert_response :success + assert_select 'label', { count: 0, text: l(:label_target_project) } + assert_select 'label', { count: 0, text: "#{l(:label_target_folder)}#" } + end + + def test_move_fast_links_enabled + # Target project is not given + post :move, params: { id: @file1.id, dmsf_file_or_folder: { target_folder_id: @folder1.id } } + assert_response :redirect + assert_nil flash[:error] + end end \ No newline at end of file diff --git a/test/functional/dmsf_folders_copy_controller_test.rb b/test/functional/dmsf_folders_copy_controller_test.rb index ccd0666e..202d6470 100644 --- a/test/functional/dmsf_folders_copy_controller_test.rb +++ b/test/functional/dmsf_folders_copy_controller_test.rb @@ -180,4 +180,21 @@ class DmsfFoldersCopyControllerTest < RedmineDmsf::Test::TestCase assert_response :not_found end + def test_new_fast_links_enabled + member = Member.find_by(user_id: @jsmith.id, project_id: @project1.id) + assert member + member.update_attribute :dmsf_fast_links, true + get :new, params: { id: @folder1.id } + assert_response :success + assert_select 'label', { count: 0, text: l(:label_target_project) } + assert_select 'label', { count: 0, text: "#{l(:label_target_folder)}#" } + end + + def test_move_fast_links_enabled + # Target project is not given + post :move, params: { id: @folder6.id, dmsf_file_or_folder: { target_folder_id: @folder1.id } } + assert_response :redirect + assert_nil flash[:error] + end + end \ No newline at end of file