Does the redmine_dmsf support to choose the members of current project when email ? #492

This commit is contained in:
Karel Picman 2018-01-25 09:22:05 +01:00
parent 078c227b6d
commit 038198ede7
13 changed files with 254 additions and 6 deletions

View File

@ -26,7 +26,8 @@ def init
pmap.permission :user_preferences, pmap.permission :user_preferences,
{:dmsf_state => [:user_pref_save]} {:dmsf_state => [:user_pref_save]}
pmap.permission :view_dmsf_files, pmap.permission :view_dmsf_files,
{:dmsf => [:entries_operation, :entries_email, :download_email_entries, :tag_changed], {:dmsf => [:entries_operation, :entries_email, :download_email_entries, :tag_changed, :add_email,
:append_email, :autocomplete_for_user],
:dmsf_files => [:show, :view, :thumbnail], :dmsf_files => [:show, :view, :thumbnail],
:dmsf_workflows => [:log]}, :dmsf_workflows => [:log]},
:read => true :read => true

View File

@ -24,7 +24,8 @@ class DmsfController < ApplicationController
before_action :find_project before_action :find_project
before_action :authorize, :except => [:expand_folder] before_action :authorize, :except => [:expand_folder]
before_action :find_folder, :except => [:new, :create, :edit_root, :save_root] 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] before_action :find_parent, :only => [:new, :create]
before_action :tree_view, :only => [:delete, :show] before_action :tree_view, :only => [:delete, :show]
before_action :permissions before_action :permissions
@ -335,8 +336,31 @@ class DmsfController < ApplicationController
redirect_to :back redirect_to :back
end end
def add_email
@principals = users_for_new_users
# respond_to do |format|
# format.js
# end
end
def append_email
@principals = Principal.where(:id => params[:user_ids]).to_a
head 200 if @principals.blank?
end
def autocomplete_for_user
@principals = users_for_new_users
respond_to do |format|
format.js
end
end
private private
def users_for_new_users
Principal.active.visible.member_of(@project).like(params[:q]).order(:type, :lastname).to_a
end
def email_entries(selected_folders, selected_files) def email_entries(selected_folders, selected_files)
begin begin
zip = DmsfZip.new zip = DmsfZip.new
@ -564,8 +588,6 @@ class DmsfController < ApplicationController
copy copy
end end
private
def get_display_params def get_display_params
@system_folder = @folder && @folder.system @system_folder = @folder && @folder.system
@folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project) @folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project)
@ -667,4 +689,3 @@ class DmsfController < ApplicationController
end end
end end

View File

@ -182,4 +182,8 @@ module DmsfHelper
end end
end end
def render_principals_for_new_email(users)
principals_check_box_tags 'user_ids[]', users
end
end end

View File

@ -0,0 +1,43 @@
<%
# 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.
%>
<h3 class="title"><%= l(:label_email_address_add) %></h3>
<%= form_tag(append_email_dmsf_path,
:remote => true,
:method => :post,
:id => 'new-user-form') do %>
<%= hidden_field_tag :project_id, @project.id %>
<p><%= label_tag 'user_search', l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p>
<%= late_javascript_tag "observeSearchfield('user_search', 'users_for_users', '#{ escape_javascript url_for(
:controller => 'dmsf', :action => 'autocomplete_for_user', :project_id => @project) }')" %>
<div id="users_for_watcher">
<%= render_principals_for_new_email(@principals) %>
</div>
<p class="buttons">
<%= submit_tag l(:button_add), :name => nil, :onclick => "hideModal(this);" %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
</p>
<% end %>

View File

@ -0,0 +1,25 @@
<%
# 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.
%>
$('#ajax-modal').html("<%= escape_javascript(render :partial => 'dmsf/add_email', :locals => { :emails => 'xxx'}) %>");
showModal('ajax-modal', '400px');
$('#ajax-modal').addClass('new-user');

View File

@ -0,0 +1,33 @@
<%
# 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.
%>
var to = $('#email_to');
var text = to.val();
<% @principals.each do |p| %>
if(text.indexOf("<%= p.mail %>") < 0){
if(text.length > 0){
text += ', '
}
text += "<%= p.mail %>"
}
<% end %>
to.val(text);

View File

@ -0,0 +1,23 @@
<%
# 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.
%>
$('#users_for_watcher').html('<%= escape_javascript(render_principals_for_new_email(@principals)) %>');

View File

@ -41,7 +41,11 @@
</p> </p>
<p> <p>
<%= label_tag('email[to]', l(:label_email_to)) %> <%= label_tag('email[to]', l(:label_email_to)) %>
<%= text_field_tag('email[to]', @email_params[:to], :style => 'width: 90%;', :required => true) %> <span>
<%= text_field_tag('email[to]', @email_params[:to], :style => 'width: 90%;', :required => true) %>
<%= link_to l(:button_add), add_email_dmsf_path(:project_id => @project),
:title => l(:label_email_address_add), :class => 'icon icon-add', :remote => true %>
</span>
</p> </p>
<p> <p>
<%= label_tag('email[cc]', l(:label_email_cc)) %> <%= label_tag('email[cc]', l(:label_email_cc)) %>

View File

@ -1,3 +1,25 @@
<%
# 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.
%>
<h3 class="title"><%= l(:label_user_search) %></h3> <h3 class="title"><%= l(:label_user_search) %></h3>
<%= form_tag(append_dmsf_folder_permissions_path, <%= form_tag(append_dmsf_folder_permissions_path,

View File

@ -1,3 +1,26 @@
<%
# 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.
%>
$('#users_for_watcher').html('<%= escape_javascript(render_principals_for_new_email(@principals)) %>');
<% @principals.each do |principal| %> <% @principals.each do |principal| %>
$("#user_permission_ids_<%= principal.id %>").remove(); $("#user_permission_ids_<%= principal.id %>").remove();
<% end %> <% end %>

View File

@ -1,2 +1,25 @@
<%
# 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.
%>
$('#users_for_watcher').html('<%= escape_javascript(render_principals_for_new_email(@principals)) %>');
$('#users_for_watcher').html('<%= escape_javascript( $('#users_for_watcher').html('<%= escape_javascript(
render_principals_for_new_folder_permissions(@principals)) %>'); render_principals_for_new_folder_permissions(@principals)) %>');

View File

@ -1,3 +1,26 @@
<%
# 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.
%>
$('#users_for_watcher').html('<%= escape_javascript(render_principals_for_new_email(@principals)) %>');
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'dmsf_folder_permissions/new') %>'); $('#ajax-modal').html('<%= escape_javascript(render :partial => 'dmsf_folder_permissions/new') %>');
showModal('ajax-modal', '400px'); showModal('ajax-modal', '400px');
$('#ajax-modal').addClass('new-user'); $('#ajax-modal').addClass('new-user');

View File

@ -49,6 +49,9 @@ if Redmine::Plugin.installed? :redmine_dmsf
get '/projects/:id/dmsf/trash', :controller => 'dmsf', :action => 'trash', :as => 'trash_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' 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/expand_folder', :controller => 'dmsf', :action => 'expand_folder', :as => 'expand_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'
# #
# dmsf_state controller # dmsf_state controller