This commit is contained in:
Karel Picman 2018-02-13 13:17:09 +01:00
parent 714079ad6f
commit d07b83102e
8 changed files with 140 additions and 26 deletions

View File

@ -37,7 +37,8 @@ def init
{:dmsf => [:new, :create, :delete, :edit, :save, :edit_root, :save_root, :lock, :unlock,
:notify_activate, :notify_deactivate, :restore],
:dmsf_folder_permissions => [:new, :append, :autocomplete_for_user],
:dmsf_folders_copy => [:new, :copy, :move]}
:dmsf_folders_copy => [:new, :copy, :move],
:dmsf_context_menus => [:dmsf]}
pmap.permission :file_manipulation,
{:dmsf_files => [:create_revision, :lock, :unlock, :delete_revision, :notify_activate,
:notify_deactivate, :restore],
@ -46,7 +47,7 @@ def init
:dmsf_links => [:new, :create, :destroy, :restore, :autocomplete_for_project,
:autocomplete_for_folder],
:dmsf_files_copy => [:new, :copy, :move],
}
:dmsf_context_menus => [:dmsf]}
pmap.permission :file_delete,
{ :dmsf => [:trash, :delete_entries],
:dmsf_files => [:delete]}

View File

@ -0,0 +1,42 @@
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 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.
class DmsfContextMenusController < ApplicationController
helper :context_menus
def dmsf
selected_files = params[:files] || []
selected_file_links = params[:file_links] || []
if selected_file_links.present?
selected_file_links.each do |id|
link = DmsfLink.find_by_id id
selected_files << link.target_id if link && !selected_files.include?(link.target_id.to_s)
end
end
if selected_files.size == 1
@file = DmsfFile.find selected_files[0]
end
render :layout => false
rescue ActiveRecord::RecordNotFound
render_404
end
end

View File

@ -1,6 +1,28 @@
<%
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 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.
%>
<% parent = @folder ? @folder : @project %>
<% DmsfHelper.all_children_sorted(parent, @pos, @idnt).each do |obj, position| %>
<% classes = "dmsf_tree idnt-#{@idnt}" %>
<% classes = "dmsf_tree idnt-#{@idnt} hascontextmenu" %>
<% if obj.is_a?(DmsfFolder) && ((obj.dmsf_folders.visible.count > 0) || (obj.dmsf_files.visible.count > 0) || (obj.dmsf_links.visible.count > 0)) %>
<% classes += ' idnt dmsf_collapsed dmsf-not-loaded' %>
<% id = "id='#{obj.id}span'".html_safe %>

View File

@ -64,8 +64,9 @@
</tr>
</thead>
<tbody>
<% classes = 'dir hascontextmenu' %>
<% @subfolders.each do |subfolder| %>
<tr class="dir <%= 'dmsf_system' if subfolder.system %> <%= 'dmsf_system_closed' if subfolder.issue && subfolder.issue.closed? %>">
<tr class="<%= classes %> <%= 'dmsf_system' if subfolder.system %> <%= 'dmsf_system_closed' if subfolder.issue && subfolder.issue.closed? %>">
<%= render(:partial => 'dir',
:locals => {
:project => @project,
@ -77,12 +78,13 @@
:position => 0 }) %>
</tr>
<% end %>
<% classes = 'dmsf_gray hascontextmenu' %>
<% @dir_links.each do |link| %>
<% unless link.target_project %>
<% Rails.logger.error "Error: dmsf_link id #{link.id} has no target!" %>
<% next %>
<% end %>
<tr class="dmsf_gray">
<tr class="<%= classes %>">
<%= render(:partial => 'dir',
:locals => {
:project => link.target_project,
@ -94,12 +96,13 @@
:position => 0}) %>
</tr>
<% end %>
<% classes = 'file hascontextmenu' %>
<% @files.each do |file| %>
<% unless file.last_revision %>
<% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %>
<% next %>
<% end %>
<tr class="file">
<tr class="<%= classes %>">
<%= render(:partial => 'file', :locals => {
:project => @project,
:file => file,
@ -110,24 +113,25 @@
:position => 1 }) %>
</tr>
<% end %>
<% classes = 'dmsf_gray hascontextmenu' %>
<% @file_links.each do |link| %>
<% unless link.target_file.last_revision %>
<% Rails.logger.error "Error: dmsf_file id #{link.target_id} has no revision!" %>
<% next %>
<% end %>
<tr class="dmsf_gray">
<%= render(:partial => 'file', :locals => {
:project => link.target_project,
:file => link.target_file,
:link => link,
:id => link.id,
:name => 'file_links[]',
:title => link.name,
:position => 1}) %>
</tr>
<% end %>
<tr class="<%= classes %>">
<%= render(:partial => 'file', :locals => {
:project => link.target_project,
:file => link.target_file,
:link => link,
:id => link.id,
:name => 'file_links[]',
:title => link.name,
:position => 1}) %>
</tr>
<% end %>
<% @url_links.each do |link| %>
<tr class="dmsf_gray">
<tr class="<%= classes %>">
<%= render(:partial => 'url', :locals => {
:project => link.target_project,
:file => link.target_file,

View File

@ -84,7 +84,7 @@
<%= error_messages_for('dmsf_workflow') %>
<%= 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', :data => {:cm_url => dmsf_context_menu_path}) do %>
<%= hidden_field_tag('action') %>
<div id="dmsf_buttons" class="dmsf_controls" style="float: left">
<%= submit_tag(l(:button_download), :title => l(:title_download_checked), :name => 'download_entries') if @file_view_allowed %>
@ -119,6 +119,8 @@
</div>
<% end %>
<%= context_menu %>
<%= late_javascript_tag do %>
$('#entries_delete_button').click(function () {
if (window.confirm("<%= l(:text_are_you_sure) %>")) {

View File

@ -32,8 +32,8 @@
<%= error_messages_for('dmsf_workflow') %>
<%= form_tag({:action => :entries_operation, :id => @project, :folder_id => @folder}, :method => :post,
:class => 'dmsf_entries', :id => 'entries_form') do %>
<%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post,
:class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_context_menu_path}) do %>
<%= hidden_field_tag('action') %>
<div class="dmsf_controls" style="float: left">
<% if @file_manipulation_allowed && @folder_manipulation_allowed %>
@ -88,8 +88,9 @@
</tr>
</thead>
<tbody>
<% classes = 'dir hascontextmenu' %>
<% @subfolders.each do |subfolder| %>
<tr class="dir">
<tr class="<%= classes %>">
<%= render(:partial => 'dir_trash',
:locals => {
:project => @project,
@ -100,8 +101,9 @@
:title => subfolder.title }) %>
</tr>
<% end %>
<% classes = 'dmsf_gray hascontextmenu' %>
<% @dir_links.each do |link| %>
<tr class="dmsf_gray">
<tr class="<%= classes %>">
<%= render(:partial => 'dir_trash',
:locals => {
:project => link.target_project,
@ -112,12 +114,13 @@
:title => link.name }) %>
</tr>
<% end %>
<% classes = 'file hascontextmenu' %>
<% @files.each do |file| %>
<% unless file.last_revision %>
<% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %>
<% next %>
<% end %>
<tr class="file">
<tr class="<%= classes %>">
<%= render(:partial => 'file_trash', :locals => {
:project => @project,
:file => file,
@ -127,6 +130,7 @@
:title => file.title }) %>
</tr>
<% end %>
<% classes = 'dmsf_gray hascontextmenu' %>
<% @file_links.each do |link| %>
<% unless link.target_file %>
<% Rails.logger.error "Error: dmsf_link id #{link.id} has no target file!" %>
@ -136,7 +140,7 @@
<% Rails.logger.error "Error: dmsf_file id #{link.target_id} has no revision!" %>
<% next %>
<% end %>
<tr class="dmsf_gray">
<tr class="<%= classes %>">
<%= render(:partial => 'file_trash', :locals => {
:project => link.target_project,
:file => link.target_file,
@ -147,7 +151,7 @@
</tr>
<% end %>
<% @url_links.each do |link| %>
<tr class="dmsf_gray">
<tr class="<%= classes %>">
<%= render(:partial => 'url_trash', :locals => {
:project => link.target_project,
:file => link.target_file,
@ -162,6 +166,8 @@
</div>
<% end %>
<%= context_menu %>
<%= late_javascript_tag do %>
$('#entries_delete_button').click(function() {
if(window.confirm("<%= l(:text_are_you_sure) %>")) {

View File

@ -0,0 +1,34 @@
<%
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 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.
%>
<ul>
<li>
<% if @file && @file.last_revision %>
<% url = "ms-word:ofe|u|#{Setting.protocol.strip}://#{Setting.host_name.strip}/#{Addressable::URI.escape(@file.project.identifier)}/" %>
<% if @file.dmsf_folder %>
<% url << @file.dmsf_folder.dmsf_path_str %>
<% end %>
<% url << @file.name %>
<% end %>
<%= context_menu_link l(:button_edit), url, :class => 'icon-edit', :disabled => url.blank? %>
</li>
</ul>

View File

@ -53,6 +53,9 @@ if Redmine::Plugin.installed? :redmine_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'
# dmsf_context_menu_controller
match '/projects/:id/dmsf/context_menu', :to => 'dmsf_context_menus#dmsf', :as => 'dmsf_context_menu', :via => [:get, :post]
#
# dmsf_state controller
# /projects/<project>/dmsf/state