diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb
index 36d9eeba..d8fc682f 100644
--- a/app/controllers/dmsf_controller.rb
+++ b/app/controllers/dmsf_controller.rb
@@ -25,7 +25,7 @@ class DmsfController < ApplicationController
include RedmineDmsf::DmsfZip
before_action :find_project
- before_action :authorize, :except => [:expand_folder]
+ before_action :authorize, :except => [:expand_folder, :exp_folder]
before_action :find_folder, :except => [:new, :create, :edit_root, :save_root, :add_email, :append_email,
:autocomplete_for_user]
before_action :find_parent, :only => [:new, :create]
@@ -57,6 +57,16 @@ class DmsfController < ApplicationController
end
end
+ def exp_folder
+ @idnt = params[:idnt].present? ? params[:idnt].to_i + 1 : 0
+ @query = retrieve_query(DmsfQuery, true)
+ @query.dmsf_folder_id = @folder.id
+ @query.deleted = false
+ respond_to do |format|
+ format.js { render action: 'query_rows' }
+ end
+ end
+
def switch_rlf
rlf = params[:rlf] == 'true'
cookie_options = {
diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb
index 2aebcf84..25f586e7 100644
--- a/app/models/dmsf_folder.rb
+++ b/app/models/dmsf_folder.rb
@@ -577,16 +577,20 @@ class DmsfFolder < ActiveRecord::Base
end
def css_classes
- classes = []
+ classes = %w(dmsf_tree)
+ if type == 'folder'
+ classes << 'dmsf_collapsed'
+ classes << 'dmsf-not-loaded'
+ else
+ classes << 'dmsf_child'
+ end
if title =~ /^\./
classes << 'dmsf_system'
else
classes << 'hascontextmenu'
+ classes << 'dmsf-draggable'
if type =~ /^folder/
classes << 'dmsf-droppable'
- classes << 'dmsf-draggable'
- else
- classes << 'dmsf-draggable'
end
if type =~ /link$/
classes << 'dmsf_gray'
diff --git a/app/views/dmsf/_query_list.html.erb b/app/views/dmsf/_query_list.html.erb
index 2cb88a0f..33424444 100644
--- a/app/views/dmsf/_query_list.html.erb
+++ b/app/views/dmsf/_query_list.html.erb
@@ -41,59 +41,8 @@
- <% level = 0 %>
- <% query.dmsf_nodes.each do |node| %>
- <% system = node.title =~ /^\./ %>
- ">
- |
- <%= check_box_tag('ids[]', "#{node.type}-#{node.id}", false, id: nil) unless system %>
- |
- <% query.inline_columns.each do |column| %>
- <%= content_tag 'td', column_content(column, node), class: column.css_classes %>
- <% end %>
-
- <%= link_to_context_menu %>
- |
-
- <% end %>
+ <%= render partial: 'query_rows', locals: { query: query } %>
<% end %>
-
-<% unless query.deleted %>
- <%= late_javascript_tag do %>
- $(function() {
- $(".dmsf-draggable").draggable({
- axis: "y",
- revert: "invalid"
- });
- $(".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 = {};
- handle.addClass("ui-state-highlight ajax-loading")
- data['dmsf_folder'] = { drag_id: dragObjectId, drop_id: dropObjectId};
- $.ajax({
- url: '<%= dmsf_folder_url(query.project) %>',
- type: 'put',
- dataType: 'script',
- data: data,
- error: function(jqXHR, textStatus, errorThrown){
- alert(textStatus + " " + jqXHR.status);
- ui.draggable.animate(ui.draggable.data("ui-draggable").originalPosition, "slow");
- },
- complete: function(jqXHR, textStatus, errorThrown){
- handle.removeClass("ui-state-highlight ajax-loading")
- if(textStatus == 'success'){
- ui.draggable.remove();
- }
- }
- });
- }
- });
- });
- <% end %>
-<% end %>
diff --git a/app/views/dmsf/_query_rows.erb b/app/views/dmsf/_query_rows.erb
new file mode 100644
index 00000000..c51ab1e0
--- /dev/null
+++ b/app/views/dmsf/_query_rows.erb
@@ -0,0 +1,74 @@
+<%
+ # encoding: utf-8
+ #
+ # Redmine plugin for Document Management System "Features"
+ #
+ # Copyright © 2011-20 Karel Pičman
+ #
+ # This program is free software; you can redistribute it and/or
+ # modify it under the terms of the GNU General Public License
+ # as published by the Free Software Foundation; either version 2
+ # of the License, or (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+%>
+
+<% query.dmsf_nodes.each do |node| %>
+ <% system = node.title =~ /^\./ %>
+ <% @idnt ||= 0 %>
+ ">
+ |
+ <%= check_box_tag('ids[]', "#{node.type}-#{node.id}", false, id: nil) unless system %>
+ |
+ <% query.inline_columns.each do |column| %>
+ <%= content_tag 'td', column_content(column, node), class: column.css_classes %>
+ <% end %>
+
+ <%= link_to_context_menu %>
+ |
+
+<% end %>
+
+<% unless query.deleted %>
+ <%= late_javascript_tag do %>
+ $(function() {
+ $(".dmsf-draggable").draggable({
+ axis: "y",
+ revert: "invalid"
+ });
+ $(".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 = {};
+ handle.addClass("ui-state-highlight ajax-loading")
+ data['dmsf_folder'] = { drag_id: dragObjectId, drop_id: dropObjectId};
+ $.ajax({
+ url: '<%= dmsf_folder_url(query.project) %>',
+ type: 'put',
+ dataType: 'script',
+ data: data,
+ error: function(jqXHR, textStatus, errorThrown){
+ alert(textStatus + " " + jqXHR.status);
+ ui.draggable.animate(ui.draggable.data("ui-draggable").originalPosition, "slow");
+ },
+ complete: function(jqXHR, textStatus, errorThrown){
+ handle.removeClass("ui-state-highlight ajax-loading")
+ if(textStatus == 'success'){
+ ui.draggable.remove( );
+ }
+ }
+ });
+ }
+ });
+ });
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/dmsf/query_rows.js.erb b/app/views/dmsf/query_rows.js.erb
new file mode 100644
index 00000000..c06b21e8
--- /dev/null
+++ b/app/views/dmsf/query_rows.js.erb
@@ -0,0 +1,2 @@
+// Add rows
+$('#<%= params[:row_id] %>').after('<%= escape_javascript(render(partial: 'dmsf/query_rows', locals: { query: @query })) %>');
diff --git a/assets/javascripts/redmine_dmsf.js b/assets/javascripts/redmine_dmsf.js
index d3362c07..133c19d2 100644
--- a/assets/javascripts/redmine_dmsf.js
+++ b/assets/javascripts/redmine_dmsf.js
@@ -50,7 +50,10 @@ function dmsfToggle(EL, PM, url)
spanid = els[i].id;
classid = spanid;
- classid = classid.match(/(\w+)span/)[1];
+ m = classid.match(/(\w+)span/);
+ if(m) {
+ classid = m[1];
+ }
classid = new RegExp(classid);
if(tmpclassid.test(els[i].className) && (tmpspanid.toString() !== PM.toString()))
@@ -130,13 +133,25 @@ function dmsfExpandRows(EL, parentRow, url) {
parentRow.className = parentRow.className.replace(/dmsf-not-loaded/, '');
var idnt = 0;
- var result = parentRow.className.match(/idnt-(\d+)/);
+ var pos = $(parentRow).find('.dmsf_position').text();
+ var classes = '';
+ var m = parentRow.className.match(/idnt-(\d+)/);
- if(result){
- idnt = result[1];
+ if(m){
+ idnt = m[1];
}
- var pos = $(parentRow).find('.dmsf_position').text();
+ m = parentRow.className.match(/((\d|\s)+) idnt/);
+
+ if(m){
+ classes = m[1]
+ }
+
+ m = parentRow.id.match(/^(\d+)/);
+
+ if(m){
+ classes = classes + ' ' + m[1]
+ }
$.ajax({
url: url,
@@ -146,7 +161,9 @@ function dmsfExpandRows(EL, parentRow, url) {
folder_id: EL,
row_id: parentRow.id,
idnt: idnt,
- pos: pos}
+ pos: pos,
+ classes: classes
+ }
}).done(function(data) {
eval(data);
})
diff --git a/config/routes.rb b/config/routes.rb
index d8ef35f5..71be8235 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -51,6 +51,7 @@ if Redmine::Plugin.installed? :redmine_dmsf
get '/projects/:id/dmsf/trash', :controller => 'dmsf', :action => 'trash', :as => 'trash_dmsf'
get '/projects/:id/dmsf/restore', :controller => 'dmsf', :action => 'restore', :as => 'restore_dmsf'
post '/projects/:id/dmsf/expand_folder', :controller => 'dmsf', :action => 'expand_folder', :as => 'expand_folder_dmsf'
+ post '/projects/:id/dmsf/exp_folder', controller: 'dmsf', action: 'exp_folder', as: 'exp_folder_dmsf'
get '/projects/:id/dmsf/add_email', :controller => 'dmsf', :action => 'add_email', :as => 'add_email_dmsf'
post '/projects/:id/dmsf/append_email', :controller => 'dmsf', :action => 'append_email', :as => 'append_email_dmsf'
get '/projects/:id/dmsf/autocomplete_for_user', :controller => 'dmsf', :action => 'autocomplete_for_user'
diff --git a/lib/redmine_dmsf/patches/queries_helper_patch.rb b/lib/redmine_dmsf/patches/queries_helper_patch.rb
index 6e7b8aec..2ae2ffb3 100644
--- a/lib/redmine_dmsf/patches/queries_helper_patch.rb
+++ b/lib/redmine_dmsf/patches/queries_helper_patch.rb
@@ -50,24 +50,34 @@ module RedmineDmsf
link_to "#{item.firstname} #{item.lastname}", user_path(id: value)
when :title
case item.type
- when 'folder', 'folder-link'
+ when 'folder'
+ "".html_safe +
link_to(h(value),
dmsf_folder_path(id: item.project_id, folder_id: item.id),
class: 'icon icon-folder',
title: h(value)) +
- content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download))
+ content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download))
+ when 'folder-link'
+ "".html_safe +
+ link_to(h(value),
+ dmsf_folder_path(id: item.project_id, folder_id: item.id),
+ class: 'icon icon-folder',
+ title: h(value)) +
+ content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download))
when 'file', 'file-link'
file_view_url = url_for({ controller: :dmsf_files, action: 'view', id: item.id })
content_type = Redmine::MimeType.of(value)
content_type = 'application/octet-stream' if content_type.blank?
+ "".html_safe +
link_to(h(value),
file_view_url,
target: '_blank',
class: "icon icon-file #{DmsfHelper.filetype_css(item.filename)}",
title: h(value),
'data-downloadurl': "#{content_type}:#{h(value)}:#{file_view_url}") +
- content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download))
+ content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download))
when 'url-link'
+ "".html_safe +
link_to(h(value), item.filename, target: '_blank', class: 'icon icon-link') +
content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download))
else