#48 Thumbnails
This commit is contained in:
parent
478bac0f69
commit
bf47687615
@ -28,20 +28,6 @@
|
||||
<% links.each do |dmsf_file, link, create_at| %>
|
||||
<%= render :partial => 'dmsf_files/link', :locals => { :dmsf_file => dmsf_file, :link => link } %>
|
||||
<% end %>
|
||||
<% # Thumbnails %>
|
||||
<% if defined?(thumbnails) && thumbnails %>
|
||||
<% images = links.map{ |x| x[0] }.select(&:image?) %>
|
||||
<% if images.any? %>
|
||||
<div class="thumbnails">
|
||||
<% images.each do |file| %>
|
||||
<div>
|
||||
<%= link_to image_tag(dmsf_thumbnail_path(file)),
|
||||
url_for({:controller => :dmsf_files, :action => 'view', :id => file}),
|
||||
:alt => file.title %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render :partial => 'dmsf_files/thumbnails', :locals => { :links => links, :thumbnails => thumbnails } %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
37
app/views/dmsf_files/_thumbnails.html.erb
Normal file
37
app/views/dmsf_files/_thumbnails.html.erb
Normal file
@ -0,0 +1,37 @@
|
||||
<%
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011-17 Karel Pičman <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.
|
||||
%>
|
||||
|
||||
<% # Thumbnails %>
|
||||
<% if defined?(thumbnails) && thumbnails %>
|
||||
<% images = links.map{ |x| x[0] }.select(&:image?) %>
|
||||
<% if images.any? %>
|
||||
<div class="thumbnails">
|
||||
<% images.each do |file| %>
|
||||
<div>
|
||||
<%= link_to image_tag(dmsf_thumbnail_path(file)),
|
||||
url_for({:controller => :dmsf_files, :action => 'view', :id => file}),
|
||||
:alt => file.title %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@ -37,6 +37,7 @@ require 'redmine_dmsf/patches/role_patch'
|
||||
|
||||
if defined?(EasyExtensions)
|
||||
require 'redmine_dmsf/patches/easy_crm_case_patch'
|
||||
require 'redmine_dmsf/patches/attachable_patch'
|
||||
end
|
||||
|
||||
# Load up classes that make up our WebDAV solution ontop of DAV4Rack
|
||||
|
||||
@ -39,11 +39,48 @@ module RedmineDmsf
|
||||
end
|
||||
|
||||
def view_issues_show_attachments_bottom(context={})
|
||||
show_attached_documents(context[:container], context[:controller])
|
||||
unless context[:options][:only_mails].present?
|
||||
show_attached_documents(context[:container], context[:controller])
|
||||
end
|
||||
end
|
||||
|
||||
def view_issues_show_thumbnails(context={})
|
||||
unless context[:options][:only_mails].present?
|
||||
show_thumbnails(context[:container], context[:controller])
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_links(container)
|
||||
if User.current.allowed_to?(:view_dmsf_files, container.project) &&
|
||||
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
||||
(container.project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS)
|
||||
links = []
|
||||
for dmsf_file in container.dmsf_files
|
||||
if dmsf_file.last_revision
|
||||
links << [dmsf_file, nil, dmsf_file.created_at]
|
||||
end
|
||||
end
|
||||
for dmsf_link in container.dmsf_links
|
||||
dmsf_file = dmsf_link.target_file
|
||||
if dmsf_file && dmsf_file.last_revision
|
||||
links << [dmsf_file, dmsf_link, dmsf_link.created_at]
|
||||
end
|
||||
end
|
||||
# Sort by 'create_at'
|
||||
links.sort{ |x, y| x[2] <=> y[2] }
|
||||
end
|
||||
end
|
||||
|
||||
def show_thumbnails(container, controller)
|
||||
links = get_links(container)
|
||||
html = controller.send(:render_to_string,
|
||||
{ :partial => 'dmsf_files/thumbnails',
|
||||
:locals => { :links => links, :thumbnails => Setting.thumbnails_enabled?} })
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
def attach_documents_form(context)
|
||||
if context.is_a?(Hash) && context[:issue]
|
||||
# Add Dmsf upload form
|
||||
@ -65,23 +102,8 @@ module RedmineDmsf
|
||||
|
||||
def show_attached_documents(container, controller)
|
||||
# Add list of attached documents
|
||||
if User.current.allowed_to?(:view_dmsf_files, container.project) &&
|
||||
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
||||
(container.project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS)
|
||||
links = []
|
||||
for dmsf_file in container.dmsf_files
|
||||
if dmsf_file.last_revision
|
||||
links << [dmsf_file, nil, dmsf_file.created_at]
|
||||
end
|
||||
end
|
||||
for dmsf_link in container.dmsf_links
|
||||
dmsf_file = dmsf_link.target_file
|
||||
if dmsf_file && dmsf_file.last_revision
|
||||
links << [dmsf_file, dmsf_link, dmsf_link.created_at]
|
||||
end
|
||||
end
|
||||
# Sort by 'create_at'
|
||||
links.sort!{ |x, y| x[2] <=> y[2] }
|
||||
links = get_links(container)
|
||||
if links.any?
|
||||
unless defined?(EasyExtensions)
|
||||
controller.send(:render_to_string, {:partial => 'dmsf_files/links',
|
||||
:locals => { :links => links, :thumbnails => Setting.thumbnails_enabled? }})
|
||||
@ -91,8 +113,6 @@ module RedmineDmsf
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def attachment_rows(links, issue, controller)
|
||||
html = '<tbody>'
|
||||
links.each do |dmsf_file, link, create_at|
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011-14 Karel Pičman <karel.picman@kontron.com>
|
||||
# Copyright (C) 2011-17 Karel Pičman <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
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright (C) 2013 Karel Pičman <karel.picman@kontron.com>
|
||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright (C) 2011-17 Karel Pičman <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
|
||||
|
||||
47
lib/redmine_dmsf/patches/attachable_patch.rb
Normal file
47
lib/redmine_dmsf/patches/attachable_patch.rb
Normal file
@ -0,0 +1,47 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011-17 Karel Pičman <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.
|
||||
|
||||
module RedmineDmsf
|
||||
module Patches
|
||||
module AttachablePatch
|
||||
|
||||
def self.included(base)
|
||||
base.send(:include, InstanceMethods)
|
||||
base.class_eval do
|
||||
unloadable
|
||||
alias_method_chain :has_attachments?, :has_attachments_dms
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
def has_attachments_with_has_attachments_dms?
|
||||
has_attachments_without_has_attachments_dms? || self.dmsf_files.any?
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Apply the patch
|
||||
Rails.configuration.to_prepare do
|
||||
unless Redmine::Acts::Attachable::InstanceMethods.included_modules.include?(RedmineDmsf::Patches::AttachablePatch)
|
||||
Redmine::Acts::Attachable::InstanceMethods.send(:include, RedmineDmsf::Patches::AttachablePatch)
|
||||
end
|
||||
end
|
||||
@ -1,8 +1,8 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
|
||||
# Copyright (C) 2013 Karel Pičman <karel.picman@kontron.com>
|
||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
|
||||
# Copyright (C) 2011-17 Karel Pičman <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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user