The main document view seeded up 3x
This commit is contained in:
parent
dc06d7d3ae
commit
343866a015
@ -39,6 +39,7 @@ class DmsfController < ApplicationController
|
||||
else
|
||||
@subfolders = @folder.subfolders.visible
|
||||
@files = @folder.files.visible
|
||||
@locked_for_user = @folder.locked_for_user?
|
||||
end
|
||||
|
||||
@files.sort! do |a,b|
|
||||
|
||||
@ -94,8 +94,10 @@ class DmsfFile < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def last_revision
|
||||
return self.revisions.visible.first unless deleted
|
||||
self.revisions.first
|
||||
unless @last_revision
|
||||
@last_revision = deleted ? self.revisions.first : self.revisions.visible.first
|
||||
end
|
||||
@last_revision
|
||||
end
|
||||
|
||||
def delete
|
||||
|
||||
@ -136,32 +136,13 @@ class DmsfFolder < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def deep_file_count
|
||||
file_count = self.files.visible.length
|
||||
file_count = self.files.visible.count
|
||||
self.subfolders.visible.each {|subfolder| file_count += subfolder.deep_file_count}
|
||||
file_count
|
||||
end
|
||||
|
||||
def deep_folder_count
|
||||
folder_count = self.subfolders.length
|
||||
self.subfolders.each {|subfolder| folder_count += subfolder.deep_folder_count}
|
||||
folder_count
|
||||
end
|
||||
|
||||
def self.project_deep_folder_count(project)
|
||||
subfolders = self.project_root_folders(project)
|
||||
folder_count = subfolders.length
|
||||
subfolders.each{|subfolder| folder_count += subfolder.deep_folder_count}
|
||||
folder_count
|
||||
end
|
||||
|
||||
def self.project_deep_file_count(project)
|
||||
file_count = DmsfFile.project_root_files(project).length
|
||||
self.project_root_folders(project).each{|subfolder| file_count += subfolder.deep_file_count}
|
||||
file_count
|
||||
end
|
||||
|
||||
def deep_folder_count
|
||||
folder_count = self.subfolders.length
|
||||
folder_count = self.subfolders.visible.count
|
||||
self.subfolders.visible.each {|subfolder| folder_count += subfolder.deep_folder_count}
|
||||
folder_count
|
||||
end
|
||||
|
||||
@ -21,19 +21,18 @@
|
||||
%>
|
||||
|
||||
<% html_title(l(:dmsf)) %>
|
||||
|
||||
<div class="contextual">
|
||||
<% if User.current.allowed_to?(:folder_manipulation, @project) %>
|
||||
<% if @folder.nil? %>
|
||||
|
||||
<%= link_to('', {:action => 'edit_root', :id => @project},
|
||||
:title => l(:link_edit, :title => l(:link_documents)), :class => 'icon icon-edit') %>
|
||||
<% elsif (@folder && !@folder.locked_for_user? ) %>
|
||||
<% elsif @locked_for_user %>
|
||||
|
||||
<%= link_to('', {:action => 'edit', :id => @project, :folder_id => @folder },
|
||||
:title => l(:link_edit, :title => h(@folder.title)), :class => 'icon icon-edit') %>
|
||||
<% end %>
|
||||
<% if @folder && (!@folder.locked_for_user? || User.current.allowed_to?(:force_file_unlock, @project)) %>
|
||||
<% if @folder && (!@locked_for_user || User.current.allowed_to?(:force_file_unlock, @project)) %>
|
||||
<% if @folder.locked? %>
|
||||
<% unless @folder.unlockable? %>
|
||||
<%= image_tag('locked.png', :plugin => :redmine_dmsf, :title => l(:title_folder_parent_locked, :name => @folder.folder.lock.reverse[0].folder.title)) unless @folder.nil?%>
|
||||
@ -62,7 +61,7 @@
|
||||
<% end %>
|
||||
|
||||
<%= link_to('', {:action => 'new', :id => @project, :parent_id => @folder },
|
||||
:title => l(:link_create_folder), :class => 'icon icon-add') unless (@folder && @folder.locked_for_user?) %>
|
||||
:title => l(:link_create_folder), :class => 'icon icon-add') unless @locked_for_user %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@ -89,7 +88,7 @@
|
||||
<div class="controls" style="float: left">
|
||||
<%= submit_tag(l(:submit_download), :title => l(:title_download_checked), :name => 'download_entries') %>
|
||||
<%= submit_tag(l(:submit_email), :title => l(:title_send_checked_by_email), :name => 'email_entries') %>
|
||||
<% if User.current.allowed_to?(:file_manipulation, @project) && (@folder && !@folder.locked_for_user?) %>
|
||||
<% if User.current.allowed_to?(:file_manipulation, @project) && @folder && !@locked_for_user %>
|
||||
<button type="button" id="entries_delete_button" title="<%= l(:title_delete_checked) %>"><%= l(:button_delete) %></button>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -112,20 +111,22 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @subfolders.each do |subfolder| %>
|
||||
<% locked_for_user = subfolder.locked_for_user? %>
|
||||
<% locked = subfolder.locked? %>
|
||||
<tr class="dir">
|
||||
<td class="check"><%= check_box_tag('subfolders[]', subfolder.id, false, :title => l(:title_check_for_zip_download_or_email)) %></td>
|
||||
<td class="title">
|
||||
<%= link_to(h(subfolder.title),
|
||||
{:action => 'show', :id => @project, :folder_id => subfolder}, :class => 'icon icon-folder') %>
|
||||
<div class="filename" title="<%= l(:title_number_of_files_in_directory)%>">[<%= subfolder.deep_file_count %>]</div>
|
||||
<div class="filename" title="<%= l(:title_number_of_files_in_directory)%>">[<%= subfolder.files.visible.count %>]</div>
|
||||
</td>
|
||||
<td class="size" title="<%= l(:title_total_size_of_all_files)%>"><%= number_to_human_size(subfolder.deep_size) %></td>
|
||||
<td class="size"></td>
|
||||
<td class="modified"><%= format_time(subfolder.updated_at) %>
|
||||
<% if subfolder.locked_for_user? %>
|
||||
<% if locked_for_user %>
|
||||
<%= link_to(image_tag('locked.png', :plugin => :redmine_dmsf),
|
||||
{:controller => 'users', :action => 'show', :id => subfolder.lock.reverse[0].user },
|
||||
:title => l(:title_locked_by_user, :user => subfolder.lock.reverse[0].user.to_s)) %>
|
||||
<% elsif subfolder.locked? %>
|
||||
<% elsif locked %>
|
||||
<%= image_tag('lockedbycurrent.png', :title => l(:title_locked_by_you), :plugin => :redmine_dmsf) %>
|
||||
<% end %>
|
||||
</td>
|
||||
@ -151,12 +152,12 @@
|
||||
<div style="float: left">
|
||||
<%= link_to(image_tag('edit.png', :class =>'detail_icon'),
|
||||
{:action => 'edit', :id => @project, :folder_id => subfolder },
|
||||
:title => l(:link_edit, :title => h(subfolder.title))) unless subfolder.locked_for_user? %>
|
||||
:title => l(:link_edit, :title => h(subfolder.title))) unless locked_for_user %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div style="float: right; width: 44px;">
|
||||
<% unless subfolder.locked_for_user? && !User.current.allowed_to?(:force_file_unlock, @project)%>
|
||||
<% if subfolder.locked? %>
|
||||
<% unless locked_for_user && !User.current.allowed_to?(:force_file_unlock, @project)%>
|
||||
<% if locked %>
|
||||
<% if subfolder.unlockable? %>
|
||||
<%= link_to_function(image_tag('unlock.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:controller => 'dmsf', :action => 'unlock',
|
||||
@ -174,15 +175,16 @@
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
<% jetzt = Time.now %>
|
||||
<%= link_to_function(image_tag('delete.png', :plugin => :redmine_dmsf),
|
||||
"confirmation_link('#{url_for(:action => 'delete', :id => @project, :folder_id => @folder, :delete_folder_id => subfolder)}', '#{l(:question_do_you_really_want_to_delete_this_entry)}')",
|
||||
:title => l(:title_delete)) unless subfolder.locked_for_user? %>
|
||||
:title => l(:title_delete)) unless locked_for_user %>
|
||||
</div>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
</td>
|
||||
<td class="hidden">0</td>
|
||||
<td class="hidden"><%= subfolder.deep_size %></td>
|
||||
<td class="hidden">0</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% workflows_available = DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', @project.id]).count > 0 %>
|
||||
@ -191,6 +193,8 @@
|
||||
<% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %>
|
||||
<% next %>
|
||||
<% end %>
|
||||
<% locked_for_user = file.locked_for_user? %>
|
||||
<% locked = file.locked? %>
|
||||
<% wf = DmsfWorkflow.find_by_id(file.last_revision.dmsf_workflow_id) %>
|
||||
<tr class="file">
|
||||
<td class="check"><%= check_box_tag('files[]', file.id, false, :title => l(:title_check_for_zip_download_or_email)) %></td>
|
||||
@ -206,11 +210,11 @@
|
||||
<td class="size"><%= number_to_human_size(file.last_revision.size) %></td>
|
||||
<td class="modified">
|
||||
<%= format_time(file.last_revision.updated_at) %>
|
||||
<% if file.locked_for_user? %>
|
||||
<% if locked_for_user %>
|
||||
<%= link_to(image_tag('locked.png', :plugin => :redmine_dmsf),
|
||||
{:controller => 'users', :action => 'show', :id => file.lock.reverse[0].user },
|
||||
:title => l(:title_locked_by_user, :user => file.lock.reverse[0].user.to_s)) %>
|
||||
<% elsif file.locked? %>
|
||||
<% elsif locked %>
|
||||
<%= image_tag('lockedbycurrent.png', :title => l(:title_locked_by_you), :plugin => :redmine_dmsf) %>
|
||||
<% end %>
|
||||
</td>
|
||||
@ -293,12 +297,12 @@
|
||||
<div class="right_icon_box" style="width: 70px">
|
||||
<div style="float: left">
|
||||
<%= link_to(image_tag('filedetails.png', :plugin => :redmine_dmsf, :class =>'detail_icon'),
|
||||
{:controller => "dmsf_files", :action => :show, :id => file },
|
||||
{:controller => 'dmsf_files', :action => :show, :id => file },
|
||||
:title => l(:link_details, :title =>h(file.last_revision.title))) %>
|
||||
</div>
|
||||
<div style="float: right; width: 44px;">
|
||||
<% unless file.locked_for_user? && !User.current.allowed_to?(:force_file_unlock, @project)%>
|
||||
<% if file.locked? %>
|
||||
<% unless locked_for_user && !User.current.allowed_to?(:force_file_unlock, @project)%>
|
||||
<% if locked %>
|
||||
<% if file.unlockable? %>
|
||||
<%= link_to_function(image_tag('unlock.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'unlock', :id => file)}')",
|
||||
@ -314,7 +318,7 @@
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
<% if User.current.allowed_to?(:file_manipulation, @project) && !file.locked_for_user? %>
|
||||
<% if User.current.allowed_to?(:file_manipulation, @project) && !locked_for_user %>
|
||||
<%= link_to_function(image_tag('delete.png', :plugin => :redmine_dmsf),
|
||||
"confirmation_link('#{url_for(:controller => 'dmsf_files', :action => 'delete', :id => file)}', '#{l(:question_do_you_really_want_to_delete_this_entry)}')",
|
||||
:title => l(:title_delete)) %>
|
||||
@ -407,6 +411,5 @@ sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && !
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<%= render(:partial => 'multi_upload') if (User.current.allowed_to?(:file_manipulation, @project) &&
|
||||
(@folder.nil? || (@folder && !@folder.locked_for_user?))) %>
|
||||
<%= render(:partial => 'multi_upload') if (User.current.allowed_to?(:file_manipulation, @project) && !@locked_for_user) %>
|
||||
<br/>
|
||||
|
||||
27
db/migrate/20131113141401_add_index_to_dmsf_file_revision.rb
Normal file
27
db/migrate/20131113141401_add_index_to_dmsf_file_revision.rb
Normal file
@ -0,0 +1,27 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2013 Karel Picman <karel.picman@kontron.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
class AddIndexToDmsfFileRevision < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_index :dmsf_file_revisions, :dmsf_file_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :dmsf_file_revisions, :dmsf_file_id
|
||||
end
|
||||
end
|
||||
27
db/migrate/20131113141402_add_index_to_dmsf_lock.rb
Normal file
27
db/migrate/20131113141402_add_index_to_dmsf_lock.rb
Normal file
@ -0,0 +1,27 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2013 Karel Picman <karel.picman@kontron.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
class AddIndexToDmsfLock < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_index :dmsf_locks, :entity_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :dmsf_locks, :entity_id
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user