#1207 merge
This commit is contained in:
commit
3e5659cd76
2
Gemfile
2
Gemfile
@ -32,7 +32,7 @@ source 'https://rubygems.org' do
|
||||
gem 'redmine_extensions', '~> 0.3.9'
|
||||
gem 'rubyzip', '>= 1.1.3'
|
||||
|
||||
group :test do
|
||||
group :test do
|
||||
gem 'rails-controller-testing'
|
||||
end
|
||||
end
|
||||
|
||||
@ -33,7 +33,7 @@ class DmsfController < ApplicationController
|
||||
# Also try to lookup folder by title if this is an API call
|
||||
before_action :find_folder_by_title, only: [:show]
|
||||
before_action :get_query, only: [:expand_folder, :show, :trash, :empty_trash]
|
||||
before_action :get_project_roles, only: [:new, :edit, :create]
|
||||
before_action :get_project_roles, only: [:new, :edit, :create, :save]
|
||||
|
||||
accept_api_auth :show, :create, :save, :delete
|
||||
|
||||
@ -51,7 +51,10 @@ class DmsfController < ApplicationController
|
||||
|
||||
def expand_folder
|
||||
@idnt = params[:idnt].present? ? params[:idnt].to_i + 1 : 0
|
||||
@query.dmsf_folder_id = @folder.id
|
||||
if params[:project_id].present?
|
||||
@query.project = Project.find_by(id: params[:project_id])
|
||||
end
|
||||
@query.dmsf_folder_id = @folder&.id
|
||||
@query.deleted = false
|
||||
respond_to do |format|
|
||||
format.js { render action: 'query_rows' }
|
||||
@ -263,8 +266,10 @@ class DmsfController < ApplicationController
|
||||
format.html {
|
||||
if saved
|
||||
flash[:notice] = l(:notice_folder_details_were_saved)
|
||||
redirect_to_folder_id = params[:dmsf_folder][:redirect_to_folder_id]
|
||||
redirect_to_folder_id = @folder.dmsf_folder.id if(@folder.dmsf_folder && redirect_to_folder_id.blank?)
|
||||
if @folder.project == @project
|
||||
redirect_to_folder_id = params[:dmsf_folder][:redirect_to_folder_id]
|
||||
redirect_to_folder_id = @folder.dmsf_folder.id if(@folder.dmsf_folder && redirect_to_folder_id.blank?)
|
||||
end
|
||||
redirect_to dmsf_folder_path(id: @project, folder_id: redirect_to_folder_id)
|
||||
else
|
||||
render action: 'edit'
|
||||
@ -399,7 +404,7 @@ class DmsfController < ApplicationController
|
||||
if params[:dmsf_folder][:drag_id] =~ /(.+)-(\d+)/
|
||||
type = $1
|
||||
id = $2
|
||||
if params[:dmsf_folder][:drop_id] =~ /^folder.*-(\d+)/
|
||||
if params[:dmsf_folder][:drop_id] =~ /^(\d+)(p|f)span$/
|
||||
case type
|
||||
when 'file'
|
||||
object = DmsfFile.find_by(id: id)
|
||||
@ -408,14 +413,25 @@ class DmsfController < ApplicationController
|
||||
when 'file-link', 'folder-link', 'url-link'
|
||||
object = DmsfLink.find_by(id: id)
|
||||
end
|
||||
dmsf_folder = DmsfFolder.find_by(id: $1)
|
||||
if object && dmsf_folder
|
||||
if dmsf_folder == object.dmsf_folder
|
||||
object.errors[:base] << l(:error_target_folder_same)
|
||||
elsif object.dmsf_folder&.locked_for_user?
|
||||
object.errors[:base] << l(:error_folder_is_locked)
|
||||
else
|
||||
result = object.move_to(dmsf_folder.project, dmsf_folder)
|
||||
if object
|
||||
case $2
|
||||
when 'p'
|
||||
project = Project.find_by(id: $1)
|
||||
if project && User.current.allowed_to?(:file_manipulation, project) &&
|
||||
User.current.allowed_to?(:folder_manipulation, project)
|
||||
result = object.move_to(project, nil)
|
||||
end
|
||||
when 'f'
|
||||
dmsf_folder = DmsfFolder.find_by(id: $1)
|
||||
if dmsf_folder
|
||||
if dmsf_folder == object.dmsf_folder
|
||||
object.errors[:base] << l(:error_target_folder_same)
|
||||
elsif object.dmsf_folder&.locked_for_user?
|
||||
object.errors[:base] << l(:error_folder_is_locked)
|
||||
else
|
||||
result = object.move_to(dmsf_folder.project, dmsf_folder)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -85,13 +85,19 @@ module DmsfQueriesHelper
|
||||
end
|
||||
when :title
|
||||
case item.type
|
||||
when 'project'
|
||||
tag = link_to(h("[#{value}]"), dmsf_folder_path(id: item.project), class: 'icon icon-folder')
|
||||
unless filter_any?
|
||||
tag = "<span class=\"dmsf_expander\" onclick=\"dmsfToggle(this, '#{item.id}', null,'#{escape_javascript(expand_folder_dmsf_path)}')\"></span>".html_safe + tag
|
||||
end
|
||||
tag + content_tag('div', item.filename, class: 'dmsf-filename', title: l(:title_filename_for_download))
|
||||
when 'folder'
|
||||
if item&.deleted > 0
|
||||
tag = content_tag('span', value, class: 'icon icon-folder')
|
||||
else
|
||||
tag = link_to(h(value), dmsf_folder_path(id: item.project, folder_id: item.id), class: 'icon icon-folder')
|
||||
unless filter_any?
|
||||
tag = "<span class=\"dmsf_expander\" onclick=\"dmsfToggle(this, '#{item.id}','#{escape_javascript(expand_folder_dmsf_path)}')\"></span>".html_safe + tag
|
||||
tag = "<span class=\"dmsf_expander\" onclick=\"dmsfToggle(this, null, '#{item.id}','#{escape_javascript(expand_folder_dmsf_path)}')\"></span>".html_safe + tag
|
||||
end
|
||||
end
|
||||
tag + content_tag('div', item.filename, class: 'dmsf-filename', title: l(:title_filename_for_download))
|
||||
|
||||
@ -565,7 +565,7 @@ class DmsfFolder < ActiveRecord::Base
|
||||
end
|
||||
else
|
||||
classes << 'dmsf-tree'
|
||||
if type == 'folder'
|
||||
if %(folder project).include?(type)
|
||||
classes << 'dmsf-collapsed'
|
||||
classes << 'dmsf-not-loaded'
|
||||
else
|
||||
@ -574,9 +574,11 @@ class DmsfFolder < ActiveRecord::Base
|
||||
if title =~ /^\./
|
||||
classes << 'dmsf-system'
|
||||
else
|
||||
classes << 'hascontextmenu'
|
||||
classes << 'dmsf-draggable'
|
||||
if type =~ /^folder/
|
||||
if (type != 'project')
|
||||
classes << 'hascontextmenu'
|
||||
classes << 'dmsf-draggable'
|
||||
end
|
||||
if %(project folder).include?(type)
|
||||
classes << 'dmsf-droppable'
|
||||
end
|
||||
if type =~ /link$/
|
||||
|
||||
@ -82,8 +82,8 @@ class DmsfQuery < Query
|
||||
|
||||
def base_scope
|
||||
unless @scope
|
||||
@scope = [dmsf_folders_scope, dmsf_folder_links_scope, dmsf_files_scope, dmsf_file_links_scope, dmsf_url_links_scope].
|
||||
inject(:union_all)
|
||||
@scope = [dmsf_folders_scope, dmsf_folder_links_scope, dmsf_projects_scope, dmsf_files_scope, dmsf_file_links_scope, dmsf_url_links_scope].
|
||||
compact.inject(:union_all)
|
||||
end
|
||||
@scope
|
||||
end
|
||||
@ -171,11 +171,15 @@ class DmsfQuery < Query
|
||||
limit(options[:limit]).
|
||||
offset(options[:offset]).to_a
|
||||
items.each do |item|
|
||||
if item.type == 'folder'
|
||||
case item.type
|
||||
when 'folder'
|
||||
dmsf_folder = DmsfFolder.find_by(id: item.id)
|
||||
if dmsf_folder && (!DmsfFolder.permissions?(dmsf_folder, false))
|
||||
items.delete item
|
||||
end
|
||||
when 'project'
|
||||
p = Project.find_by(id: item.id)
|
||||
items.delete(item) unless p&.dmsf_available?
|
||||
end
|
||||
end
|
||||
items
|
||||
@ -187,6 +191,41 @@ class DmsfQuery < Query
|
||||
|
||||
private
|
||||
|
||||
def dmsf_projects_scope
|
||||
return nil unless Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders']
|
||||
cf_columns = +''
|
||||
if statement.present?
|
||||
DmsfFileRevisionCustomField.visible.order(:position).pluck(:id).each do |id|
|
||||
cf_columns << ",NULL AS cf_#{id}"
|
||||
end
|
||||
end
|
||||
scope = Project.
|
||||
select(%{
|
||||
projects.id AS id,
|
||||
projects.id AS project_id,
|
||||
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS revision_id,
|
||||
projects.name AS title,
|
||||
projects.identifier AS filename,
|
||||
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS size,
|
||||
projects.updated_on AS updated,
|
||||
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS major_version,
|
||||
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS minor_version,
|
||||
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow,
|
||||
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS workflow_id,
|
||||
'' AS firstname,
|
||||
'' AS lastname,
|
||||
CAST(NULL AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS author,
|
||||
'project' AS type,
|
||||
CAST(0 AS #{ActiveRecord::Base.connection.type_to_sql(:decimal)}) AS deleted,
|
||||
0 AS sort #{cf_columns}}).visible
|
||||
if dmsf_folder_id || deleted
|
||||
scope.where '1=0'
|
||||
else
|
||||
scope = scope.non_templates if scope.respond_to?(:non_templates)
|
||||
scope.where projects: { parent_id: project.id }
|
||||
end
|
||||
end
|
||||
|
||||
def dmsf_folders_scope
|
||||
cf_columns = +''
|
||||
if statement.present?
|
||||
@ -212,7 +251,7 @@ class DmsfQuery < Query
|
||||
users.id AS author,
|
||||
'folder' AS type,
|
||||
dmsf_folders.deleted AS deleted,
|
||||
0 AS sort #{cf_columns}}).
|
||||
1 AS sort #{cf_columns}}).
|
||||
joins('LEFT JOIN users ON dmsf_folders.user_id = users.id')
|
||||
if deleted
|
||||
scope = scope.deleted
|
||||
@ -255,7 +294,7 @@ class DmsfQuery < Query
|
||||
users.id AS author,
|
||||
'folder-link' AS type,
|
||||
dmsf_links.deleted AS deleted,
|
||||
0 AS sort #{cf_columns}}).
|
||||
1 AS sort #{cf_columns}}).
|
||||
joins('LEFT JOIN dmsf_folders ON dmsf_links.target_id = dmsf_folders.id').
|
||||
joins('LEFT JOIN users ON users.id = COALESCE(dmsf_folders.user_id, dmsf_links.user_id)')
|
||||
if dmsf_folder_id
|
||||
@ -294,7 +333,7 @@ class DmsfQuery < Query
|
||||
users.id AS author,
|
||||
'file' AS type,
|
||||
dmsf_files.deleted AS deleted,
|
||||
1 AS sort #{cf_columns}}).
|
||||
2 AS sort #{cf_columns}}).
|
||||
joins(:dmsf_file_revisions).
|
||||
joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id ').
|
||||
where(sub_query)
|
||||
@ -334,7 +373,7 @@ class DmsfQuery < Query
|
||||
users.id AS author,
|
||||
'file-link' AS type,
|
||||
dmsf_links.deleted AS deleted,
|
||||
1 AS sort #{cf_columns}}).
|
||||
2 AS sort #{cf_columns}}).
|
||||
joins('JOIN dmsf_files ON dmsf_files.id = dmsf_links.target_id').
|
||||
joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id').
|
||||
joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id ').
|
||||
@ -376,7 +415,7 @@ class DmsfQuery < Query
|
||||
users.id AS author,
|
||||
'url-link' AS type,
|
||||
dmsf_links.deleted AS deleted,
|
||||
1 AS sort #{cf_columns}}).
|
||||
2 AS sort #{cf_columns}}).
|
||||
joins('LEFT JOIN users ON dmsf_links.user_id = users.id ')
|
||||
if dmsf_folder_id
|
||||
scope.where dmsf_links: { target_type: 'DmsfUrl', dmsf_folder_id: dmsf_folder_id, deleted: deleted }
|
||||
|
||||
@ -27,17 +27,24 @@
|
||||
<% end %>
|
||||
<% query.dmsf_nodes(options).each do |node| %>
|
||||
<% system = node.title =~ /^\./ %>
|
||||
<% id = (node.type == 'folder') ? "#{node.id}span" : "#{node.id}item" %>
|
||||
<% case node.type %>
|
||||
<% when 'project'%>
|
||||
<% id = "#{node.id}pspan" %>
|
||||
<% when 'folder' %>
|
||||
<% id = "#{node.id}fspan" %>
|
||||
<% else %>
|
||||
<% id = "#{node.id}item" %>
|
||||
<% end %>
|
||||
<% @idnt ||= 0 %>
|
||||
<tr id="<%= id %>" class="<%= cycle('odd', 'even') %> <%= node.css_classes(query.deleted) %> <%= params[:classes] %> <%= @idnt > 0 ? "idnt idnt-#{@idnt}" : nil %>">
|
||||
<td class="checkbox hide-when-print">
|
||||
<%= check_box_tag('ids[]', "#{node.type}-#{node.id}", false, id: nil) unless system %>
|
||||
<%= check_box_tag('ids[]', "#{node.type}-#{node.id}", false, id: nil) unless (system || (node.type == 'project')) %>
|
||||
</td>
|
||||
<% query.inline_columns.each do |column| %>
|
||||
<%= content_tag 'td', column_content(column, node), class: column.css_classes %>
|
||||
<% end %>
|
||||
<td class="buttons">
|
||||
<% unless system %>
|
||||
<% unless (system || (node.type == 'project')) %>
|
||||
<% if defined?(EasyExtensions) %>
|
||||
<%= link_to '', '#', title: l(:button_actions), class: 'icon-only icon-actions js-contextmenu icon-more-horiz' %>
|
||||
<% else %>
|
||||
@ -68,10 +75,10 @@
|
||||
});
|
||||
$(".dmsf-droppable" ).droppable({
|
||||
drop: function(event, ui) {
|
||||
var handle = $(this);
|
||||
var dragObjectId = ui.draggable.find("td").find("input").val()
|
||||
var dropObjectId = handle.find("td").find("input").val();
|
||||
var data = {};
|
||||
let handle = $(this);
|
||||
let dragObjectId = ui.draggable.find("td").find("input").val()
|
||||
let dropObjectId = handle.attr('id');
|
||||
let data = {};
|
||||
handle.addClass("ui-state-highlight ajax-loading")
|
||||
data['dmsf_folder'] = { drag_id: dragObjectId, drop_id: dropObjectId};
|
||||
$.ajax({
|
||||
|
||||
@ -150,6 +150,15 @@
|
||||
</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag :label, l(:label_dmsf_projects_as_subfolders) %>
|
||||
<%= check_box_tag 'settings[dmsf_projects_as_subfolders]', true, @settings['dmsf_projects_as_subfolders'] %>
|
||||
<em class="info">
|
||||
<%= l(:note_dmsf_projects_as_subfolders) %><br/>
|
||||
<%= l(:label_default) %>: <%= l(:general_text_Yes) %>
|
||||
</em>
|
||||
</p>
|
||||
|
||||
<hr/>
|
||||
<em class="info">
|
||||
<%= l(:menu_dmsf) %> <%= l(:field_column_names) %>
|
||||
|
||||
@ -269,7 +269,12 @@ function dmsfSetupFileDrop() {
|
||||
|
||||
if (window.File && window.FileList && window.ProgressEvent && window.FormData) {
|
||||
|
||||
$.event.addProp('dataTransfer');
|
||||
if($().jquery < '3.0.0') {
|
||||
$.event.fixHooks.drop = {props: ['dataTransfer']};
|
||||
}
|
||||
else{
|
||||
$.event.addProp('dataTransfer');
|
||||
}
|
||||
|
||||
$('form span.dmsf-uploader:not(.dmsffiledroplistner)').has('input:file').each(function () {
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/* Function to allow the projects to show up as a tree */
|
||||
function dmsfToggle(el, id, url)
|
||||
function dmsfToggle(el, project_id, folder_id, url)
|
||||
{
|
||||
// Expand not yet loaded selected row
|
||||
let selectedRow = $(el).parents('tr').first();
|
||||
@ -33,15 +33,13 @@ function dmsfToggle(el, id, url)
|
||||
|
||||
if(selectedRow.hasClass('dmsf-not-loaded')){
|
||||
|
||||
dmsfExpandRows(id, selectedRow, url);
|
||||
dmsfExpandRows(project_id, folder_id, selectedRow, url);
|
||||
}
|
||||
|
||||
if(expand) {
|
||||
|
||||
$(selectedRow).switchClass('dmsf-collapsed', 'dmsf-expanded');
|
||||
}
|
||||
else {
|
||||
|
||||
$(selectedRow).switchClass('dmsf-expanded', 'dmsf-collapsed');
|
||||
}
|
||||
|
||||
@ -51,12 +49,11 @@ function dmsfToggle(el, id, url)
|
||||
$("tr.dmsf-tree").each(function(i, tr){
|
||||
|
||||
// Visiblity
|
||||
if($(tr).hasClass(id)) {
|
||||
|
||||
if($(tr).hasClass(folder_id ? (folder_id + 'f') : (project_id + 'p'))) {
|
||||
if (expand) {
|
||||
|
||||
// Display only children with expanded parent
|
||||
m = $(tr).attr('class').match(/(\d+) idnt/);
|
||||
m = $(tr).attr('class').match(/(\d+(p|f)) idnt/);
|
||||
|
||||
if(m){
|
||||
|
||||
@ -69,7 +66,6 @@ function dmsfToggle(el, id, url)
|
||||
} else {
|
||||
|
||||
if(!$(tr).hasClass('dmsf-hidden')) {
|
||||
|
||||
$(tr).addClass('dmsf-hidden');
|
||||
}
|
||||
}
|
||||
@ -93,7 +89,7 @@ function dmsfToggle(el, id, url)
|
||||
}
|
||||
|
||||
/* Add child rows */
|
||||
function dmsfExpandRows(id, parentRow, url) {
|
||||
function dmsfExpandRows(project_id, folder_id, parentRow, url) {
|
||||
|
||||
$(parentRow).removeClass('dmsf-not-loaded');
|
||||
|
||||
@ -105,13 +101,13 @@ function dmsfExpandRows(id, parentRow, url) {
|
||||
idnt = m[1];
|
||||
}
|
||||
|
||||
m = $(parentRow).attr('class').match(/((\d|\s)+) idnt/);
|
||||
m = $(parentRow).attr('class').match(/((\d|p|f|\s)+) idnt/);
|
||||
|
||||
if(m){
|
||||
classes = m[1]
|
||||
}
|
||||
|
||||
m = $(parentRow).attr('id').match(/^(\d+)/);
|
||||
m = $(parentRow).attr('id').match(/^(\d+(p|f))/);
|
||||
|
||||
if(m){
|
||||
classes = classes + ' ' + m[1]
|
||||
@ -122,7 +118,8 @@ function dmsfExpandRows(id, parentRow, url) {
|
||||
type: 'post',
|
||||
dataType: 'html',
|
||||
data: {
|
||||
folder_id: id,
|
||||
project_id: project_id,
|
||||
folder_id: folder_id,
|
||||
row_id: $(parentRow).attr('id'),
|
||||
idnt: idnt,
|
||||
classes: classes
|
||||
@ -144,7 +141,7 @@ function dmsfExpandRows(id, parentRow, url) {
|
||||
}
|
||||
})
|
||||
.fail(function() {
|
||||
alert('An error in rows expanding');
|
||||
console.log('An error in rows expanding');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -418,6 +418,8 @@ cs:
|
||||
|
||||
dmsf_copy: "Kopie (%{n})"
|
||||
label_empty_trash_bin: Vysypat koš
|
||||
label_dmsf_projects_as_subfolders: Podprojekty jako podaresáře
|
||||
note_dmsf_projects_as_subfolders: Přidá podprojekty jako podadresáře do pohledu DMS
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -413,6 +413,8 @@ de:
|
||||
|
||||
dmsf_copy: "Kopie (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ en:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ es:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ fr:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -417,6 +417,8 @@ hu:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ it: # Italian strings thx 2 Matteo Arceci!
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ ja:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -417,6 +417,8 @@ ko:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ nl:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ pl:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ pt-BR:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ ru:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ sl:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -417,6 +417,8 @@ zh-TW:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
@ -418,6 +418,8 @@ zh:
|
||||
|
||||
dmsf_copy: "Copy (%{n})"
|
||||
label_empty_trash_bin: Empty Trash
|
||||
label_dmsf_projects_as_subfolders: Sub-projects as sub-folders
|
||||
note_dmsf_projects_as_subfolders: Add sub-projects as sub-folders into DMS view
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
|
||||
3
init.rb
3
init.rb
@ -59,7 +59,8 @@ Redmine::Plugin.register :redmine_dmsf do
|
||||
'dmsf_documents_email_links_only' => nil,
|
||||
'dmsf_enable_cjk_ngrams' => nil,
|
||||
'dmsf_webdav_use_project_names' => Redmine::Plugin.installed?(:easy_extensions) ? '1' : nil,
|
||||
'dmsf_webdav_ignore_1b_file_for_authentication' => '1'
|
||||
'dmsf_webdav_ignore_1b_file_for_authentication' => '1',
|
||||
'dmsf_projects_as_subfolders' => Redmine::Plugin.installed?(:easy_extensions) ? '1' : nil,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@ -117,6 +117,15 @@ module RedmineDmsf
|
||||
end
|
||||
end
|
||||
|
||||
# Go recursively through the project tree until a dmsf enabled project is found
|
||||
def dmsf_available?
|
||||
return true if(visible? && module_enabled?(:dmsf))
|
||||
children.each do |child|
|
||||
return true if child.dmsf_available?
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -181,7 +181,7 @@ module RedmineDmsf
|
||||
scope = project_scope.visible
|
||||
scope = scope.non_templates if scope.respond_to?(:non_templates)
|
||||
scope.find_each do |p|
|
||||
if dmsf_available?(p)
|
||||
if p.dmsf_available?
|
||||
@children << child_project(p)
|
||||
end
|
||||
end
|
||||
@ -271,15 +271,6 @@ module RedmineDmsf
|
||||
end
|
||||
end
|
||||
|
||||
# Go recursively through the project tree until a dmsf enabled project is found
|
||||
def dmsf_available?(p)
|
||||
return true if(p.visible? && p.module_enabled?(:dmsf))
|
||||
p.children.each do |child|
|
||||
return true if dmsf_available?(child)
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,7 +30,7 @@ module RedmineDmsf
|
||||
@children = []
|
||||
if project
|
||||
# Sub-projects
|
||||
load_projects project.children
|
||||
load_projects(project.children) if Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders']
|
||||
if project.module_enabled?(:dmsf)
|
||||
# Folders
|
||||
if User.current.allowed_to?(:view_dmsf_folders, project)
|
||||
|
||||
@ -346,4 +346,20 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
||||
assert_redirected_to dmsf_folder_path(id: @project1, folder_id: @folder1)
|
||||
end
|
||||
|
||||
def test_show_with_sub_projects
|
||||
Setting.clear_cache
|
||||
Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders'] = '1'
|
||||
get :show, params: { id: @project1.id }
|
||||
assert_response :success
|
||||
# @project3 is as a sub-folder
|
||||
assert_select "tr##{@project3.id}pspan", count: 1
|
||||
end
|
||||
|
||||
def test_show_without_sub_projects
|
||||
get :show, params: { id: @project1.id }
|
||||
assert_response :success
|
||||
# @project3 is not as a sub-folder
|
||||
assert_select "tr##{@project3.id}pspan", count: 0
|
||||
end
|
||||
|
||||
end
|
||||
@ -50,10 +50,12 @@ module RedmineDmsf
|
||||
@someone = User.find_by(login: 'someone')
|
||||
@project1 = Project.find 1
|
||||
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] = '1'
|
||||
Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders'] = nil
|
||||
@project1_name = RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1)
|
||||
@project1_uri = Addressable::URI.escape(@project1_name)
|
||||
@project2 = Project.find 2
|
||||
@project3 = Project.find 3
|
||||
@project4 = Project.find 4
|
||||
[@project1, @project2, @project3].each do |project|
|
||||
project.enable_module! :dmsf
|
||||
project.enable_module! :issue_tracking
|
||||
@ -88,6 +90,7 @@ module RedmineDmsf
|
||||
Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] = 'WEBDAV_READ_WRITE'
|
||||
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] = nil
|
||||
Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.join(%w(files dmsf))
|
||||
Setting.plugin_redmine_dmsf['dmsf_projects_as_subfolders'] = nil
|
||||
Setting.text_formatting = 'Textile'
|
||||
FileUtils.cp_r File.join(File.expand_path('../fixtures/files', __FILE__), '.'), DmsfFile.storage_path
|
||||
User.current = nil
|
||||
|
||||
@ -90,4 +90,16 @@ class ProjectPatchTest < RedmineDmsf::Test::UnitTest
|
||||
assert_equal 0, @project3.url_links.visible.all.size
|
||||
end
|
||||
|
||||
def test_dmsf_avaliable
|
||||
# @project1
|
||||
# L @project3
|
||||
assert @project1.dmsf_available?
|
||||
assert @project3.dmsf_available?
|
||||
@project1.disable_module! :dmsf
|
||||
assert @project3.dmsf_available?
|
||||
@project3.disable_module! :dmsf
|
||||
@project3.reload
|
||||
assert !@project3.dmsf_available?
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user