#48 Link's buttons

This commit is contained in:
Karel Picman 2017-05-26 14:12:49 +02:00
parent 64e2c78e4a
commit 1342033692
6 changed files with 139 additions and 99 deletions

View File

@ -83,7 +83,7 @@
<%= error_messages_for('dmsf_workflow') %> <%= error_messages_for('dmsf_workflow') %>
<%= form_tag({:action => :entries_operation, :id => @project, :folder_id => @folder}, :method => :post, <%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post,
:class => 'dmsf_entries', :id => 'entries_form') do %> :class => 'dmsf_entries', :id => 'entries_form') do %>
<%= hidden_field_tag('action') %> <%= hidden_field_tag('action') %>
<div id="dmsf_buttons" class="dmsf_controls" style="float: left"> <div id="dmsf_buttons" class="dmsf_controls" style="float: left">

View File

@ -0,0 +1,101 @@
<%
# 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.
%>
<% if link %>
<p class="dmsf_gray">
<% else %>
<p>
<% end %>
<% file_view_url = url_for({:controller => :dmsf_files, :action => 'view', :id => dmsf_file}) %>
<%= link_to(h(dmsf_file.title),
file_view_url,
:target => '_blank',
:class => "icon icon-file #{DmsfHelper.filetype_css(dmsf_file.name)}",
:title => h(dmsf_file.last_revision.try(:tooltip)),
'data-downloadurl' => "#{dmsf_file.last_revision.detect_content_type}:#{h(dmsf_file.name)}:#{file_view_url}") %>
<% if dmsf_file.text? || dmsf_file.image? %>
<%= link_to l(:button_view),
file_view_url,
:class => 'icon-only icon-magnifier',
:title => l(:button_view) %>
<% end %>
<%= " - #{dmsf_file.description}" unless dmsf_file.description.blank? %>
<span class="size">(<%= number_to_human_size dmsf_file.last_revision.size %>)</span>
<span class="author"><%= dmsf_file.last_revision.user %>, <%= format_time(dmsf_file.last_revision.updated_at) %></span>
<% # Command icons %>
<span class="dmsf_upload_select">
<% # Details %>
<% if User.current.allowed_to? :file_manipulation, dmsf_file.project %>
<%= link_to('', dmsf_file_path(:id => dmsf_file),
:title => l(:link_details, :title => h(dmsf_file.last_revision.title)),
:class => 'icon icon-edit') %>
<% else %>
<span class="icon"></span>
<% end %>
<% # Email %>
<%= link_to('', entries_operations_dmsf_path(:id => dmsf_file.project, :email_entries => 'email', :files => [dmsf_file.id]), :method => :post,
:title => l(:heading_send_documents_by_email),
:class => 'icon icon-email-disabled') %>
<% # Lock %>
<% if !dmsf_file.locked? %>
<%= link_to('', lock_dmsf_files_path(:id => dmsf_file),
:title => l(:title_lock_file),
:class => 'icon icon-lock') %>
<% elsif dmsf_file.unlockable? && (!dmsf_file.locked_for_user? || User.current.allowed_to?(:force_file_unlock, dmsf_file.project)) %>
<%= link_to('', unlock_dmsf_files_path(:id => dmsf_file),
:title => dmsf_file.get_locked_title,
:class => 'icon icon-unlock') %>
<% else %>
<span class="icon icon-unlock" title="<%= dmsf_file.get_locked_title %>"></span>
<% end %>
<% unless dmsf_file.locked? %>
<% # Notifications %>
<% if dmsf_file.notification %>
<%= link_to('', notify_deactivate_dmsf_files_path(:id => dmsf_file),
:title => l(:title_notifications_active_deactivate),
:class => 'icon icon-email') %>
<% else %>
<%= link_to('', notify_activate_dmsf_files_path(:id => dmsf_file),
:title => l(:title_notifications_not_active_activate),
:class => 'icon icon-email-add') %>
<% end %>
<% # Delete %>
<% if @issue.attributes_editable? && User.current.allowed_to?(:file_delete, dmsf_file.project) %>
<%= link_to('',
link ? dmsf_link_path(link, :commit => 'yes') : dmsf_file_path(:id => dmsf_file, :commit => 'yes'),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:title => l(:title_delete),
:class => 'icon icon-del') %>
<% end %>
<% else %>
<span class="icon"></span>
<span class="icon"></span>
<% end %>
<% # Approval workflow %>
<% wf = DmsfWorkflow.find_by_id(dmsf_file.last_revision.dmsf_workflow_id) if dmsf_file.last_revision.dmsf_workflow_id %>
<%= render(:partial => 'dmsf_files/approval_workflow_button',
:locals => {:file => dmsf_file,
:file_approval_allowed => User.current.allowed_to?(:file_approval, dmsf_file.project),
:workflows_available => DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', dmsf_file.project.id]).exists?,
:project => dmsf_file.project, :wf => wf }) %>
</span>
</p>

View File

@ -20,114 +20,28 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%> %>
<% if dmsf_files.present? || dmsf_links.present? %> <% if links.present? %>
<hr/> <hr/>
<strong><%= l(:menu_dmsf) %></strong>
<div class="attachments dmsf_parent_container"> <div class="attachments dmsf_parent_container">
<% for dmsf_file in dmsf_files %> <% # DMS documents & links %>
<% if dmsf_file.last_revision %> <% links.each do |dmsf_file, link, create_at| %>
<p> <%= render :partial => 'dmsf_files/link', :locals => { :dmsf_file => dmsf_file, :link => link } %>
<% file_view_url = url_for({:controller => :dmsf_files, :action => 'view', :id => dmsf_file}) %>
<%= link_to(h(dmsf_file.title),
file_view_url,
:target => '_blank',
:class => "icon icon-file #{DmsfHelper.filetype_css(dmsf_file.name)}",
:title => h(dmsf_file.last_revision.try(:tooltip)),
'data-downloadurl' => "#{dmsf_file.last_revision.detect_content_type}:#{h(dmsf_file.name)}:#{file_view_url}") %>
<% if dmsf_file.text? || dmsf_file.image? %>
<%= link_to l(:button_view),
file_view_url,
:class => 'icon-only icon-magnifier',
:title => l(:button_view) %>
<% end %>
<%= " - #{dmsf_file.description}" unless dmsf_file.description.blank? %>
<span class="size">(<%= number_to_human_size dmsf_file.last_revision.size %>)</span>
<% if @issue.attributes_editable? && User.current.allowed_to?(:file_delete, dmsf_file.project) %>
<%= link_to('',
dmsf_file_path(:id => dmsf_file, :commit => 'yes'),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:title => l(:title_delete),
:class => 'icon icon-del') %>
<% end %>
<span class="author"><%= dmsf_file.last_revision.user %>, <%= format_time(dmsf_file.last_revision.updated_at) %></span>
<span class="dmsf_upload_select">
<% wf = DmsfWorkflow.find_by_id(dmsf_file.last_revision.dmsf_workflow_id) if dmsf_file.last_revision.dmsf_workflow_id %>
<%= render(:partial => 'dmsf_files/approval_workflow_button',
:locals => {:file => dmsf_file,
:file_approval_allowed => User.current.allowed_to?(:file_approval, dmsf_file.project),
:workflows_available => DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', dmsf_file.project.id]).exists?,
:project => dmsf_file.project, :wf => wf }) %>
</span>
</p>
<% end %>
<% end %> <% end %>
<% # Thumbnails %>
<% if defined?(thumbnails) && thumbnails %> <% if defined?(thumbnails) && thumbnails %>
<% images = dmsf_files.select(&:image?) %> <% 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 => dmsf_file.title %>
</div>
<% end %>
</div>
<% end %>
<% end %>
</div>
<% for dmsf_link in dmsf_links %>
<% dmsf_file = dmsf_link.target_file %>
<% if dmsf_file.last_revision %>
<p class = "dmsf_gray">
<% file_view_url = url_for({:controller => :dmsf_files, :action => 'view', :id => dmsf_file}) %>
<%= link_to(h(dmsf_link.title),
file_view_url,
:target => '_blank',
:class => "icon icon-file #{DmsfHelper.filetype_css(dmsf_file.name)}",
:title => h(dmsf_file.last_revision.try(:tooltip)),
'data-downloadurl' => "#{dmsf_file.last_revision.detect_content_type}:#{h(dmsf_file.name)}:#{file_view_url}") %>
<% if dmsf_file.text? || dmsf_file.image? %>
<%= link_to l(:button_view),
file_view_url,
:class => 'icon-only icon-magnifier',
:title => l(:button_view) %>
<% end %>
<%= " - #{dmsf_file.description}" unless dmsf_file.description.blank? %>
<span class="size">(<%= number_to_human_size dmsf_file.last_revision.size %>)</span>
<% if @issue.attributes_editable? && User.current.allowed_to?(:file_delete, dmsf_file.project) %>
<%= link_to('',
dmsf_link_path(dmsf_link, :commit => 'yes'),
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:title => l(:title_delete),
:class => 'icon icon-del') %>
<% end %>
<span class="author"><%= dmsf_file.last_revision.user %>, <%= format_time(dmsf_file.last_revision.updated_at) %></span>
<span class="dmsf_upload_select">
<% wf = DmsfWorkflow.find_by_id(dmsf_file.last_revision.dmsf_workflow_id) if dmsf_file.last_revision.dmsf_workflow_id %>
<%= render(:partial => 'dmsf_files/approval_workflow_button',
:locals => {:file => dmsf_file,
:file_approval_allowed => User.current.allowed_to?(:file_approval, dmsf_file.project),
:workflows_available => DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', dmsf_file.project.id]).exists?,
:project => dmsf_file.project, :wf => wf }) %>
</span>
</p>
<% end %>
<% end %>
<% if defined?(thumbnails) && thumbnails %>
<% images = dmsf_links.map{ |link| link.target_file }.select(&:image?) %>
<% if images.any? %> <% if images.any? %>
<div class="thumbnails"> <div class="thumbnails">
<% images.each do |file| %> <% images.each do |file| %>
<div> <div>
<%= link_to image_tag(dmsf_thumbnail_path(file)), <%= link_to image_tag(dmsf_thumbnail_path(file)),
url_for({:controller => :dmsf_files, :action => 'view', :id => file}), url_for({:controller => :dmsf_files, :action => 'view', :id => file}),
:alt => dmsf_file.title %> :alt => file.title %>
</div> </div>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>

View File

@ -35,7 +35,7 @@ if Redmine::Plugin.installed? :redmine_dmsf
delete '/projects/:id/dmsf/delete', :controller => 'dmsf', :action => 'delete', :as => 'delete_dmsf' delete '/projects/:id/dmsf/delete', :controller => 'dmsf', :action => 'delete', :as => 'delete_dmsf'
post '/projects/:id/dmsf/save', :controller => 'dmsf', :action => 'save' post '/projects/:id/dmsf/save', :controller => 'dmsf', :action => 'save'
post '/projects/:id/dmsf/save/root', :controller => 'dmsf', :action => 'save_root' post '/projects/:id/dmsf/save/root', :controller => 'dmsf', :action => 'save_root'
post '/projects/:id/dmsf/entries', :controller => 'dmsf', :action => 'entries_operation' post '/projects/:id/dmsf/entries', :controller => 'dmsf', :action => 'entries_operation', :as => 'entries_operations_dmsf'
post '/projects/:id/dmsf/tag_changed', :controller => 'dmsf', :action => 'tag_changed', :as => 'tag_changed' post '/projects/:id/dmsf/tag_changed', :controller => 'dmsf', :action => 'tag_changed', :as => 'tag_changed'
post '/projects/:id/dmsf/entries/delete', :controller => 'dmsf', :action => 'delete_entries', :as => 'delete_entries' post '/projects/:id/dmsf/entries/delete', :controller => 'dmsf', :action => 'delete_entries', :as => 'delete_entries'
post '/projects/:id/dmsf/entries/email', :to => 'dmsf#entries_email', :as => 'email_entries' post '/projects/:id/dmsf/entries/email', :to => 'dmsf#entries_email', :as => 'email_entries'

View File

@ -25,6 +25,7 @@ module RedmineDmsf
class DmsfViewListener < Redmine::Hook::ViewListener class DmsfViewListener < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context={}) def view_layouts_base_html_head(context={})
return if defined?(EasyExtensions)
"\n".html_safe + stylesheet_link_tag('redmine_dmsf.css', :plugin => :redmine_dmsf) + "\n".html_safe + stylesheet_link_tag('redmine_dmsf.css', :plugin => :redmine_dmsf) +
"\n".html_safe + stylesheet_link_tag('select2.min.css', :plugin => :redmine_dmsf) + "\n".html_safe + stylesheet_link_tag('select2.min.css', :plugin => :redmine_dmsf) +
"\n".html_safe + javascript_include_tag('select2.min.js', :plugin => :redmine_dmsf) + "\n".html_safe + javascript_include_tag('select2.min.js', :plugin => :redmine_dmsf) +
@ -32,6 +33,17 @@ module RedmineDmsf
"\n".html_safe + javascript_include_tag('attachments_dmsf.js', :plugin => :redmine_dmsf) "\n".html_safe + javascript_include_tag('attachments_dmsf.js', :plugin => :redmine_dmsf)
end end
def easy_extensions_javascripts_hook(context={})
context[:template].require_asset('select2.min.js')
context[:template].require_asset('redmine_dmsf.js')
context[:template].require_asset('attachments_dmsf.js')
end
def easy_extensions_stylesheets_hook(context={})
context[:template].require_asset('redmine_dmsf.css')
context[:template].require_asset('select2.min.css')
end
end end
end end
end end

View File

@ -48,9 +48,22 @@ module RedmineDmsf
issue = context[:issue] issue = context[:issue]
if User.current.allowed_to?(:view_dmsf_files, issue.project) && if User.current.allowed_to?(:view_dmsf_files, issue.project) &&
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] Setting.plugin_redmine_dmsf['dmsf_act_as_attachable']
links = []
for dmsf_file in issue.dmsf_files
if dmsf_file.last_revision
links << [dmsf_file, nil, dmsf_file.created_at]
end
end
for dmsf_link in issue.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] }
context[:controller].send(:render_to_string, {:partial => 'dmsf_files/links', context[:controller].send(:render_to_string, {:partial => 'dmsf_files/links',
:locals => { :dmsf_files => issue.dmsf_files, :dmsf_links => issue.dmsf_links, :locals => { :links => links, :thumbnails => Setting.thumbnails_enabled? }})
:thumbnails => Setting.thumbnails_enabled? }})
end end
end end
end end