Fast links for Copy/Move #1323
This commit is contained in:
parent
dbd6a4238d
commit
a3a68edb98
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -33,4 +33,5 @@
|
||||
file_or_folder: @file,
|
||||
target_folder: @target_folder,
|
||||
permission: :file_manipulation,
|
||||
fast_links: @fast_links,
|
||||
back_url: @back_url } %>
|
||||
|
||||
@ -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 %>
|
||||
<div class="box tabular">
|
||||
<% unless fast_links %>
|
||||
<p>
|
||||
<%= 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) %>
|
||||
</p>
|
||||
<% end %>
|
||||
<p>
|
||||
<%= 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) %>
|
||||
</p>
|
||||
<p>
|
||||
<%= 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 %>
|
||||
</p>
|
||||
</div>
|
||||
<p>
|
||||
@ -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 %>
|
||||
|
||||
@ -32,4 +32,5 @@
|
||||
file_or_folder: @folder,
|
||||
target_folder: @target_folder,
|
||||
permission: :folder_manipulation,
|
||||
fast_links: @fast_links,
|
||||
back_url: @back_url} %>
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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: Унаследованный доступ для
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -164,4 +164,21 @@ class DmsfFilesCopyControllerTest < RedmineDmsf::Test::TestCase
|
||||
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
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user