diff --git a/app/controllers/dmsf_workflows_controller.rb b/app/controllers/dmsf_workflows_controller.rb index 3b68db7a..e360e9d7 100644 --- a/app/controllers/dmsf_workflows_controller.rb +++ b/app/controllers/dmsf_workflows_controller.rb @@ -270,6 +270,15 @@ class DmsfWorkflowsController < ApplicationController render :layout => false end + def new_step + @steps = @dmsf_workflow.dmsf_workflow_steps.collect{|s| s.step}.uniq + + respond_to do |format| + format.html + format.js + end + end + def add_step if request.post? if params[:step] == '0' diff --git a/app/views/dmsf_workflows/_new_step_form.html.erb b/app/views/dmsf_workflows/_new_step_form.html.erb new file mode 100644 index 00000000..5157e57f --- /dev/null +++ b/app/views/dmsf_workflows/_new_step_form.html.erb @@ -0,0 +1,36 @@ +<% +# encoding: utf-8 +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011-15 Karel Pičman +# +# 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. +%> + +
+ <%=l(:label_dmsf_workflow_add_approver)%> +

<%= label_tag 'user_search', l(:label_user_search) %><%= text_field_tag 'user_search', nil %>

+ <%= javascript_tag "observeSearchfield('user_search', 'users', '#{ escape_javascript autocomplete_for_user_dmsf_workflow_path(@dmsf_workflow, :dmsf_workflow_step_assignment_id => nil, :dmsf_file_revision_id => nil, :project_id => @project ? @project.id : nil) }')" %> + +
+ <%= render_principals_for_new_dmsf_workflow_users(@dmsf_workflow, nil, nil) %> +
+
+ +
+ <%= l(:label_dmsf_workflow_step) %> + <%= select_tag 'step', dmsf_workflow_steps_options_for_select(@steps), + :id => 'selected_step', :style => "width:100px" %> +
\ No newline at end of file diff --git a/app/views/dmsf_workflows/_new_step_modal.html.erb b/app/views/dmsf_workflows/_new_step_modal.html.erb new file mode 100644 index 00000000..61ed2c36 --- /dev/null +++ b/app/views/dmsf_workflows/_new_step_modal.html.erb @@ -0,0 +1,31 @@ +<% +# encoding: utf-8 +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011-15 Karel Pičman +# +# 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. +%> + +

<%= l(:dmsf_new_step) %>

+ +<%= form_for(:dmsf_workflow, {:url => edit_dmsf_workflow_path(@dmsf_workflow), :method => :post}) do |f| %> + <%= render :partial => 'new_step_form' %> +

+ <%= submit_tag l(:dmsf_and), :id => 'add-step-and' %> + <%= submit_tag l(:dmsf_or), :id => 'add-step-or' %> + <%= submit_tag l(:button_cancel), :name => nil, :onclick => 'hideModal(this);', :type => 'button' %> +

+<% end %> \ No newline at end of file diff --git a/app/views/dmsf_workflows/_steps.html.erb b/app/views/dmsf_workflows/_steps.html.erb index db08246f..6d282c99 100644 --- a/app/views/dmsf_workflows/_steps.html.erb +++ b/app/views/dmsf_workflows/_steps.html.erb @@ -1,6 +1,8 @@ -<%# Redmine plugin for Document Management System "Features" +<% +# encoding: utf-8 +# Redmine plugin for Document Management System "Features" # -# Copyright (C) 2013 Karel Pičman +# Copyright (C) 2011-15 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -14,7 +16,8 @@ # # 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.%> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +%> <% if @dmsf_workflow.project %>

<%= link_to l(:label_dmsf_workflow_plural), settings_project_path(@project, :tab => 'dmsf_workflow') %> » <%=h @dmsf_workflow %>

@@ -29,67 +32,42 @@ <% end %> -
- -
-<% steps = @dmsf_workflow.dmsf_workflow_steps.collect{|s| s.step}.uniq %> -<% if steps.any? %> - - - - - - - - <% steps.each do |i|%> - - - - - - - <% end; reset_cycle %> - -
<%= l(:label_dmsf_workflow_step) %><%= l(:label_dmsf_workflow_approval_plural) %><%= l(:button_sort)%> -
<%= i %> - <% @dmsf_workflow.dmsf_workflow_steps.collect{|s| (s.step == i) ? s : nil}.compact.each_with_index do |step, j| %> - <% if j != 0 %> - <%= step.soperator %>  - <% end %> - <%= link_to_user step.user %> - <% end %> - - <%= reorder_links('workflow_step', {:action => 'edit', :id => @dmsf_workflow, :step => i}, :put) %> - - <%= delete_link edit_dmsf_workflow_path(@dmsf_workflow, :step => i) %> -
-<% else %> -

<%= l(:label_no_data) %>

-<% end %> -
- -
- <%= form_for(@dmsf_workflow, :url => edit_dmsf_workflow_path(@dmsf_workflow), - :html => {:method => :post}) do |f| %> -
<%=l(:label_user_new)%> - -

<%= label_tag 'user_search', l(:label_user_search) %><%= text_field_tag 'user_search', nil %>

- <%= javascript_tag "observeSearchfield('user_search', 'users', '#{ escape_javascript autocomplete_for_user_dmsf_workflow_path(@dmsf_workflow, :dmsf_workflow_step_assignment_id => nil, :dmsf_file_revision_id => nil, :project_id => @project ? @project.id : nil) }')" %> - -
- <%= render_principals_for_new_dmsf_workflow_users(@dmsf_workflow, nil, nil) %> -
- -

- <%= l(:label_dmsf_workflow_step) %> - <%= select_tag 'step', - dmsf_workflow_steps_options_for_select(steps), - :id => 'selected_step', :style => "width:100px" %> -

-

<%= l(:label_dmsf_workflow_add_approver) %>

-

<%= submit_tag l(:dmsf_and) %> <%= l(:label_or) %> <%= submit_tag l(:dmsf_or) %>

-
+
+

+ <%= link_to l(:dmsf_new_step), new_step_dmsf_workflow_path(@dmsf_workflow), :remote => true, :class => 'icon icon-add' %> +

+ <% steps = @dmsf_workflow.dmsf_workflow_steps.collect{|s| s.step}.uniq %> + <% if steps.any? %> + + + + + + + + <% steps.each do |i|%> + + + + + + + <% end; reset_cycle %> + +
<%= l(:label_dmsf_workflow_step) %><%= l(:label_dmsf_workflow_approval_plural) %><%= l(:button_sort)%> +
<%= i %> + <% @dmsf_workflow.dmsf_workflow_steps.collect{|s| (s.step == i) ? s : nil}.compact.each_with_index do |step, j| %> + <% if j != 0 %> + <%= step.soperator %>  + <% end %> + <%= link_to_user step.user %> + <% end %> + + <%= reorder_links('workflow_step', {:action => 'edit', :id => @dmsf_workflow, :step => i}, :put) %> + + <%= delete_link edit_dmsf_workflow_path(@dmsf_workflow, :step => i) %> +
+ <% else %> +

<%= l(:label_no_data) %>

<% end %> -
-
\ No newline at end of file diff --git a/app/views/dmsf_workflows/new_step.html.erb b/app/views/dmsf_workflows/new_step.html.erb new file mode 100644 index 00000000..8baa7cf3 --- /dev/null +++ b/app/views/dmsf_workflows/new_step.html.erb @@ -0,0 +1,19 @@ +<% +# encoding: utf-8 +# +# Redmine plugin for Kontron customisation +# Copyright (c) 2011-15 Kontron +# Karel Pičman +# +# Repository folders +%> + +

<%= l(:label_repository_folders) %>

+ +<%= form_for(:repository_folder, {:url => edit_dmsf_workflow_path(@dmsf_workflow), :method => :post}) do |f| %> + <%= render :partial => 'new_step_form' %> +

+ <%= submit_tag l(:dmsf_and), :id => 'add-step-and' %> + <%= submit_tag l(:dmsf_or), :id => 'add-step-or' %> +

+<% end %> \ No newline at end of file diff --git a/app/views/dmsf_workflows/new_step.js.erb b/app/views/dmsf_workflows/new_step.js.erb new file mode 100644 index 00000000..691a431f --- /dev/null +++ b/app/views/dmsf_workflows/new_step.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'new_step_modal') %>'); +showModal('ajax-modal', '700px'); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 1b827724..ab597dfe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -126,9 +126,10 @@ RedmineApp::Application.routes.draw do post 'new_action' get 'start' post 'assignment' + get 'new_step' end end - + match 'dmsf_workflows/:id/edit', :controller => 'dmsf_workflows', :action => 'add_step', :id => /\d+/, :via => :post match 'dmsf_workflows/:id/edit', :controller => 'dmsf_workflows', :action => 'remove_step', :id => /\d+/, :via => :delete match 'dmsf_workflows/:id/edit', :controller => 'dmsf_workflows', :action => 'reorder_steps', :id => /\d+/, :via => :put diff --git a/init.rb b/init.rb index 7d6cd202..e40154da 100644 --- a/init.rb +++ b/init.rb @@ -84,7 +84,7 @@ Redmine::Plugin.register :redmine_dmsf do permission :file_approval, {:dmsf_workflows => [:action, :new_action, :autocomplete_for_user, :start, :assign, :assignment]} permission :manage_workflows, - {:dmsf_workflows => [:index, :new, :create, :destroy, :show, :add_step, :remove_step, :reorder_steps, :update]} + {:dmsf_workflows => [:index, :new, :create, :destroy, :show, :new_step, :add_step, :remove_step, :reorder_steps, :update]} end # Administration menu extension