Assigning of approval workflows to revisions

This commit is contained in:
Karel Picman 2013-05-24 14:25:36 +02:00
parent cce36da72e
commit 64d8c521df
36 changed files with 309 additions and 192 deletions

View File

@ -255,8 +255,22 @@ class DmsfController < ApplicationController
redirect_to params[:current] ? params[:current] :
{:controller => "dmsf", :action => "show", :id => @project, :folder_id => @folder.folder}
end
def assign
end
def assignment
revision = DmsfFileRevision.find_by_id params[:dmsf_file_revision_id]
if revision
revision.set_workflow(params[:dmsf_workflow_id], params[:action])
revision.assign_workflow(params[:dmsf_workflow_id])
if request.post? && revision.save
flash[:notice] = l(:notice_successful_create)
end
end
redirect_to params[:current] ? params[:current] :
{:controller => "dmsf", :action => "show", :id => @project, :folder_id => @folder.folder}
end
private

View File

@ -20,9 +20,9 @@ class DmsfWorkflowsController < ApplicationController
unloadable
layout :workflows_layout
before_filter :find_workflow, :except => [:create, :new, :index]
before_filter :find_project
before_filter :authorize_global, :except => [:action, :new_action]
before_filter :find_workflow, :except => [:create, :new, :index, :assign, :assignment]
before_filter :find_project, :except => [:start]
before_filter :authorize_global #, :except => [:action, :new_action]
def index
if @project
@ -35,18 +35,40 @@ class DmsfWorkflowsController < ApplicationController
def action
end
def new_action
action = DmsfWorkflowStepAction.new(
:dmsf_workflow_step_assignment_id => params[:dmsf_workflow_step_assignment_id],
:action => params[:step_action],
:note => params[:note])
if request.post? && action.save
@workflow.try_finish params[:dmsf_file_revision_id]
flash[:notice] = l(:notice_successful_create)
end
# TODO: Refresh the page!
def new_action
if params[:commit] == l(:submit_commit)
action = DmsfWorkflowStepAction.new(
:dmsf_workflow_step_assignment_id => params[:dmsf_workflow_step_assignment_id],
:action => params[:step_action],
:note => params[:note])
if request.post?
if action.save
@workflow.try_finish params[:dmsf_file_revision_id], action, params[:user_id]
flash[:notice] = l(:notice_successful_update)
else
flash[:error] = l(:error_empty_note)
end
end
end
redirect_to :back
end
def assign
end
def assignment
if params[:commit] == l(:button_assign)
revision = DmsfFileRevision.find_by_id params[:dmsf_file_revision_id]
if revision
revision.set_workflow(params[:dmsf_workflow_id], params[:action])
revision.assign_workflow(params[:dmsf_workflow_id])
if request.post? && revision.save
flash[:notice] = l(:notice_successful_update)
end
end
end
redirect_to :back
end
def log
end
@ -87,7 +109,8 @@ class DmsfWorkflowsController < ApplicationController
def destroy
begin
@workflow.destroy
@workflow.destroy
flash[:notice] = l(:notice_successful_delete)
rescue
flash[:error] = l(:error_unable_delete_dmsf_workflow)
end
@ -98,10 +121,8 @@ class DmsfWorkflowsController < ApplicationController
end
end
def autocomplete_for_user
respond_to do |format|
format.js
end
def autocomplete_for_user
render :layout => false
end
def add_step
@ -158,6 +179,17 @@ class DmsfWorkflowsController < ApplicationController
end
end
def start
revision = DmsfFileRevision.find_by_id(params[:dmsf_file_revision_id])
if revision
revision.set_workflow(@workflow.id, params[:action])
if request.post? && revision.save
flash[:notice] = l(:notice_successful_update)
end
end
redirect_to :back
end
private
def find_workflow

View File

@ -18,19 +18,24 @@
module DmsfWorkflowsHelper
def render_principals_for_new_dmsf_workflow_users(workflow)
scope = User.active.sorted.like(params[:q])
def render_principals_for_new_dmsf_workflow_users(workflow, dmsf_workflow_step_assignment_id, dmsf_file_revision_id)
scope = workflow.delegates(params[:q], dmsf_workflow_step_assignment_id, dmsf_file_revision_id, nil)
principal_count = scope.count
principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page']
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page']
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals')
if dmsf_workflow_step_assignment_id
s = content_tag('div', principals_radio_button_tags('step_action', principals), :id => 'users_for_delegate')
else
s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'users')
end
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
link_to text, autocomplete_for_user_dmsf_workflow_path(workflow, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
}
s + content_tag('p', links, :class => 'pagination')
s.html_safe
end
def dmsf_workflow_steps_options_for_select(steps)
@ -50,4 +55,12 @@ module DmsfWorkflowsHelper
end
options_for_select(options, :selected => dmsf_workflow_id)
end
def principals_radio_button_tags(name, principals)
s = ''
principals.each do |principal|
s << "<label>#{ radio_button_tag name, principal.id, false, :id => nil } #{h principal}</label>\n"
end
s.html_safe
end
end

View File

@ -156,19 +156,22 @@ class DmsfFileRevision < ActiveRecord::Base
return new_revision
end
def workflow_str
str = ''
if dmsf_workflow_id
def workflow_str(name)
if name && dmsf_workflow_id
wf = DmsfWorkflow.find_by_id(dmsf_workflow_id)
str = "#{wf.name} - " if wf
else
str = ''
end
case workflow
when 1
when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL
str + l(:title_waiting_for_approval)
when 2
when DmsfWorkflow::STATE_APPROVED
str + l(:title_approved)
when 3
when DmsfWorkflow::STATE_DRAFT
str + l(:title_draft)
when DmsfWorkflow::STATE_REJECTED
str + l(:title_rejected)
else
str
end
@ -178,21 +181,21 @@ class DmsfFileRevision < ActiveRecord::Base
if User.current.allowed_to?(:file_approval, self.file.project)
unless dmsf_workflow_id.blank?
self.dmsf_workflow_id = dmsf_workflow_id
if commit == l(:label_dmsf_wokflow_action_start)
self.workflow = 1 # Waiting for approval
if commit == 'start'
self.workflow = DmsfWorkflow::STATE_WAITING_FOR_APPROVAL # Waiting for approval
else
self.workflow = 3 # Draft
end
self.workflow = DmsfWorkflow::STATE_DRAFT # Draft
end
end
end
end
def assign_workflow(dmsf_workflow_id)
if User.current.allowed_to?(:file_approval, self.file.project)
if self.workflow == 1 # Waiting for approval
#if self.workflow == DmsfWorkflow::STATE_DRAFT # Waiting for approval
wf = DmsfWorkflow.find_by_id(dmsf_workflow_id)
wf.assign(self.id) if wf && self.id
end
#end
end
end

View File

@ -42,7 +42,7 @@ class DmsfWorkflow < ActiveRecord::Base
def to_s
name
end
end
def approvals(step)
wa = Array.new
@ -109,9 +109,24 @@ class DmsfWorkflow < ActiveRecord::Base
end
end
end
def delegates
User.all
def delegates(q, dmsf_workflow_step_assignment_id, dmsf_file_revision_id, project_id)
if project_id
sql = ['id IN (SELECT user_id FROM members WHERE project_id = ?', project_id]
elsif dmsf_workflow_step_assignment_id && dmsf_file_revision_id
sql = [
'id NOT IN (SELECT a.user_id FROM dmsf_workflow_step_assignments a WHERE id = ?) AND id IN (SELECT m.user_id FROM members m JOIN dmsf_file_revisions r ON m.project_id = r.project_id WHERE r.id = ?)',
dmsf_workflow_step_assignment_id,
dmsf_file_revision_id]
else
sql = '1=1'
end
unless q.nil? || q.empty?
User.active.sorted.where(sql).like(q)
else
User.active.sorted.where(sql)
end
end
def get_free_assignment(user, dmsf_file_revision_id)
@ -130,17 +145,28 @@ class DmsfWorkflow < ActiveRecord::Base
end
end
def try_finish(dmsf_file_revision_id)
def try_finish(dmsf_file_revision_id, action, user_id)
res = nil
steps = DmsfWorkflowStep.where(:dmsf_workflow_id => self.id).all
steps.each do |step|
res = step.result dmsf_file_revision_id
unless step.finished? dmsf_file_revision_id
return
end
case action.action
when DmsfWorkflowStepAction::ACTION_APPROVE
steps = DmsfWorkflowStep.where(:dmsf_workflow_id => self.id).all
steps.each do |step|
res = step.result dmsf_file_revision_id
unless step.finished? dmsf_file_revision_id
return
end
end
when DmsfWorkflowStepAction::ACTION_REJECT
res = DmsfWorkflow::STATE_REJECTED
when DmsfWorkflowStepAction::ACTION_DELEGATE
assignment = DmsfWorkflowStepAssignment.find_by_id(action.dmsf_workflow_step_assignment_id)
assignment.update_attribute(:user_id, user_id) if assignment
end
if res
revision = DmsfFileRevision.find_by_id dmsf_file_revision_id
revision.update_attribute(:workflow, res) if revision
end
revision = DmsfFileRevision.find_by_id dmsf_file_revision_id
revision.update_attribute(:workflow, res) if revision && res
end
end

View File

@ -77,14 +77,16 @@ class DmsfWorkflowStep < ActiveRecord::Base
:dmsf_workflow_step_id => self.id,
:dmsf_file_revision_id => dmsf_file_revision_id,
:user_id => user.id).first
actions = DmsfWorkflowStepAction.where(
:dmsf_workflow_step_assignment_id => assignment.id).all
actions.each do |action|
if action && action.is_finished?
return
if assignment
actions = DmsfWorkflowStepAction.where(
:dmsf_workflow_step_assignment_id => assignment.id).all
actions.each do |action|
if action && action.is_finished?
return
end
end
return assignment.id
end
return assignment.id
end
end

View File

@ -22,6 +22,7 @@ class DmsfWorkflowStepAction < ActiveRecord::Base
validates :dmsf_workflow_step_assignment_id, :presence => true
validates :action, :presence => true
validates :note, :presence => true, :unless => lambda { self.action == DmsfWorkflowStepAction::ACTION_APPROVE }
ACTION_APPROVE = 1
ACTION_REJECT = 2

View File

@ -65,7 +65,7 @@
<th><%= l(:link_title) %></th>
<th><%= l(:link_size) %></th>
<th><%= l(:link_modified) %></th>
<th><%= l(:link_ver) %></th>
<th><%= l(:link_ver) %></th>
<th><%= l(:link_author) %></th>
<th></th>
<th class="hidden"></th>
@ -93,11 +93,11 @@
<%= image_tag("lockedbycurrent.png", :title => l(:title_locked_by_you), :plugin => :redmine_dmsf) %>
<% end %>
</td>
<td class="version"></td>
<td class="version"></td>
<td class="author"><%= h(subfolder.user) %></td>
<td class="actions">
<% if User.current.allowed_to?(:file_approval, @project) %>
<div class="right_icon_box">
<div class="right_icon_box" style="width:26px;">
<% if subfolder.notification %>
<%= link_to_function(image_tag("notify.png", :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:action => 'notify_deactivate', :id => @project, :folder_id => subfolder)}')",
@ -106,7 +106,7 @@
<%= link_to_function(image_tag("notifynot.png", :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:action => 'notify_activate', :id => @project, :folder_id => subfolder)}')",
:title => l(:title_notifications_not_active_activate)) %>
<% end %>
<% end %>
</div>
<% end %>
<div class="right_icon_box" style="width: 70px;">
@ -147,7 +147,7 @@
<td class="hidden"><%= subfolder.deep_size %></td>
</tr>
<% end %>
<% @files.each do |file| %>
<% @files.each do |file| %>
<tr class="file">
<td class="check"><%= check_box_tag("files[]", file.id, false, :title => l(:title_check_for_zip_download_or_email)) %></td>
<td class="title">
@ -172,38 +172,12 @@
<% end %>
</td>
<td class="version">
<%= file.last_revision.version %>
<% case file.last_revision.workflow %>
<% when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL %>
<% wf = DmsfWorkflow.find_by_id(file.last_revision.dmsf_workflow_id) %>
<% if wf %>
<% dmsf_workflow_step_assignment_id = wf.get_free_assignment(User.current, file.last_revision.id) %>
<% if dmsf_workflow_step_assignment_id %>
<%= link_to(
image_tag('waitingforapproval.png', :plugin => :redmine_dmsf),
action_dmsf_workflow_path(
:project_id => @project.id,
:id => wf.id,
:dmsf_workflow_step_assignment_id => dmsf_workflow_step_assignment_id,
:dmsf_file_revision_id => file.last_revision.id),
:title => l(:title_waiting_for_approval),
:remote => true) %>
<% else %>
<%= image_tag('waitingforapproval.png', :title => l(:title_waiting_for_approval), :plugin => :redmine_dmsf) %>
<% end %>
<% end %>
<% when DmsfWorkflow::STATE_APPROVED %>
<%= image_tag('approved.png', :title => l(:title_approved), :plugin => :redmine_dmsf) %>
<% when DmsfWorkflow::STATE_DRAFT %>
<%= image_tag('draft.png', :title => l(:title_draft), :plugin => :redmine_dmsf) %>
<% when DmsfWorkflow::STATE_REJECTED %>
<%= image_tag('delete.png', :title => l(:title_rejected), :plugin => :redmine_dmsf) %>
<% end %>
</td>
<%= "#{file.last_revision.version} #{file.last_revision.workflow_str(false)}" %>
</td>
<td class="author"><%= h(file.last_revision.user) %></td>
<td class="actions">
<% if User.current.allowed_to?(:file_approval, @project) %>
<div class="right_icon_box">
<div class="right_icon_box" style="width:26px;">
<% if file.notification %>
<%= link_to_function(image_tag("notify.png", :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'notify_deactivate', :id => file)}')",
@ -213,9 +187,48 @@
"manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'notify_activate', :id => file)}')",
:title => l(:title_notifications_not_active_activate)) %>
<% end %>
</div>
<% case file.last_revision.workflow %>
<% when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL %>
<% wf = DmsfWorkflow.find_by_id(file.last_revision.dmsf_workflow_id) %>
<% if wf %>
<% dmsf_workflow_step_assignment_id = wf.get_free_assignment(User.current, file.last_revision.id) %>
<% if dmsf_workflow_step_assignment_id %>
<%= link_to(
image_tag('waiting_for_approval.png', :plugin => :redmine_dmsf),
action_dmsf_workflow_path(
:project_id => @project.id,
:id => wf.id,
:dmsf_workflow_step_assignment_id => dmsf_workflow_step_assignment_id,
:dmsf_file_revision_id => file.last_revision.id),
:title => l(:title_waiting_for_approval),
:remote => true) %>
<% else %>
<%= image_tag('waiting_for_approval.png', :title => "#{l(:label_dmsf_wokflow_action_approve)} #{l(:label_dmsf_wokflow_action_reject)} #{l(:label_dmsf_wokflow_action_delegate)}", :plugin => :redmine_dmsf) %>
<% end %>
<% end %>
<% when DmsfWorkflow::STATE_APPROVED %>
<%= image_tag('approved.png', :title => l(:title_approved), :plugin => :redmine_dmsf) %>
<% when DmsfWorkflow::STATE_DRAFT %>
<%= link_to_function(image_tag('draft.png', :plugin => :redmine_dmsf),
"manipulation_link('#{start_dmsf_workflow_path(
:id => file.last_revision.dmsf_workflow_id,
:dmsf_file_revision_id => file.last_revision.id)}')",
:title => l(:label_dmsf_wokflow_action_start)) %>
<% when DmsfWorkflow::STATE_REJECTED %>
<%= image_tag('rejected.png', :title => l(:title_rejected), :plugin => :redmine_dmsf) %>
<% else %>
<%= link_to(
image_tag('none.png', :plugin => :redmine_dmsf),
assign_dmsf_workflow_path(
:project_id => @project.id,
:dmsf_workflow_step_assignment_id => dmsf_workflow_step_assignment_id,
:dmsf_file_revision_id => file.last_revision.id),
:title => l(:label_dmsf_wokflow_action_assign),
:remote => true) %>
<% end %>
</div>
<% end %>
<div class="right_icon_box" style="width: 70px;">
<div class="right_icon_box" style="width: 70px">
<div style="float: left">
<%= link_to(image_tag("filedetails.png", :plugin => :redmine_dmsf, :class =>"detail_icon"),
{:controller => "dmsf_files", :action => :show, :id => file },
@ -242,7 +255,7 @@
<%= link_to_function(image_tag("delete.png", :plugin => :redmine_dmsf),
"confirmation_link('#{url_for(:controller => "dmsf_files", :action => 'delete', :id => file)}')",
:title => l(:title_delete)) %>
<% end %>
<% end %>
</div>
</div>
<br class="clear" />

View File

@ -44,7 +44,7 @@
<%= @file.last_revision.major_version + 1 %>.0 <%= l(:option_version_major) %><br />
</div>
<p>
<%= label_tag("workflow", l(:label_workflow) + ":") %>
<%= label_tag('workflow', l(:label_workflow) + ':') %>
<%= select_tag(
'dmsf_workflow_id',
dmsf_workflows_for_select(@project, @file.last_revision.dmsf_workflow_id))%>

View File

@ -57,7 +57,8 @@
<h3><%= l(:heading_revisions) %></h3>
<% @file.revisions.visible[@revision_pages.current.offset,@revision_pages.items_per_page].each do |revision| %>
<div class="box dmsf_detail">
<div class="revision_box dmsf_detail">
<div class="ui-widget-header ui-corner-tl ui-corner-tr">
<div style="float:right">
<%= link_to(image_tag("download.png", :plugin => "redmine_dmsf"),
{:action => "show", :id => @file, :download => revision},
@ -69,22 +70,20 @@
:title => l(:title_delete_revision)) %>
<% end %>
</div>
<p class="no-ident">
<%=label_tag("", (revision.source_revision.nil? ? l(:label_created) : l(:label_changed)) + ":")%>
<%= label_tag('', l(:info_revision, :rev => revision.id)) %>
<%= (revision.source_revision.nil? ? l(:label_created) : l(:label_changed)).downcase %>
<%= l(:info_changed_by_user, :changed => format_time(revision.updated_at), :user => h(revision.user)) %>
</p>
</div>
<div class="clear">
<div class="splitcontentleft">
<p>
<%= label_tag("", l(:label_title) + ":") %>
<%= h(revision.title) %>
</p>
<div class="splitcontentleft">
<%= label_tag("", l(:label_title) + ":") %>
<%= h(revision.title) %>
</div>
<div class="splitcontentright">
<p>
<%= label_tag("", l(:label_file) + ":") %>
<%= (h(revision.folder.dmsf_path_str) + "/") unless revision.folder.nil? %><%= h(revision.name) %>
</p>
<div class="splitcontentright">
<%= label_tag("", l(:label_file) + ":") %>
<%= (h(revision.folder.dmsf_path_str) + "/") unless revision.folder.nil? %><%= h(revision.name) %>
</div>
</div>
<p class="no-ident">
@ -94,42 +93,30 @@
<%= textilizable(revision.description) %>
</div>
<div class="splitcontentleft">
<p>
<%= label_tag("", l(:label_version) + ":") %>
<%= revision.major_version %>.<%= revision.minor_version %>
</p>
<p>
<%= label_tag("", l(:label_workflow) + ":") %>
<%= #case revision.workflow
# when 1 then l(:option_workflow_waiting_for_approval)
# when 2 then l(:option_workflow_approved)
# else l(:option_workflow_none)
# end
revision.workflow_str
%>
</p>
<div class="splitcontentleft">
<%= label_tag("", l(:label_version) + ":") %>
<%= revision.major_version %>.<%= revision.minor_version %>
<br/>
<%= label_tag('', l(:label_workflow) + ':') %>
<%= revision.workflow_str true %>
</div>
<div class="splitcontentright clear">
<p>
<%= label_tag("", l(:label_mime) + ":") %>
<%= h(revision.mime_type) %>&nbsp;
</p>
<p>
<%= label_tag("", l(:label_size) + ":") %>
<%= number_to_human_size(revision.size) %>
</p>
</div>
<br style="clear: both"/>
<div class="splitcontentright clear">
<%= label_tag("", l(:label_mime) + ":") %>
<%= h(revision.mime_type) %>&nbsp;
<br/>
<%= label_tag("", l(:label_size) + ":") %>
<%= number_to_human_size(revision.size) %>
</div>
<div class="no-ident clear">
<%= render "dmsf/custom_fields", :object => revision %>
</div>
<p class="no-ident clear">
<div class="splitcontentleft clear">
<%= label_tag("", l(:label_comment) + ":") %>
<%= h(revision.comment) %>
</p>
</div>
<%= render(:partial => "revision_access", :locals => {:revision => revision}) if User.current.allowed_to?(:file_approval, @file.project) %>
</div>
<br/>
<% end %>
<p class="pagination"><%= pagination_links_full @revision_pages, @file.revisions.visible.count %></p>

View File

@ -13,7 +13,7 @@
:download => ""}) %> (<%= file.name %>),
<%= number_to_human_size(file.last_revision.size) %>,
version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %>,
<%= "#{file.last_revision.workflow_str}," unless file.last_revision.workflow_str.blank? %>
<%= "#{file.last_revision.workflow_str(true)}," unless file.last_revision.workflow_str(true).blank? %>
<%= link_to("Details",
{:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %>
<% unless file.last_revision.comment.blank? %>

View File

@ -1,6 +1,6 @@
User <%= @user %> actualized DMSF files in project <%= @project.name %>:
<% @files.each do |file| %>
<%= file.dmsf_path_str %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %><%= ", #{file.last_revision.workflow_str}" unless file.last_revision.workflow_str.blank? %>
<%= file.dmsf_path_str %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %><%= ", #{file.last_revision.workflow_str(true)}" unless file.last_revision.workflow_str(true).blank? %>
<%= url_for({:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %>
<% unless file.last_revision.comment.blank? %> comment: <%= file.last_revision.comment %><% end %>
<% end %>

View File

@ -13,7 +13,7 @@
:download => ""}) %> (<%= file.name %>),
<%= number_to_human_size(file.last_revision.size) %>,
version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %>,
<%= "#{file.last_revision.workflow_str}," unless file.last_revision.workflow_str.blank? %>
<%= "#{file.last_revision.workflow_str(true)}," unless file.last_revision.workflow_str(true).blank? %>
<%= link_to("Details",
{:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %>
<% unless file.last_revision.comment.blank? %>

View File

@ -1,6 +1,6 @@
User <%= @user %> actualized DMSF files in project <%= @project.name %>:
<% @files.each do |file| %>
<%= file.dmsf_path_str %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %><%= ", #{file.last_revision.workflow_str}" unless file.last_revision.workflow_str.blank? %>
<%= file.dmsf_path_str %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %><%= ", #{file.last_revision.workflow_str(true)}" unless file.last_revision.workflow_str(true).blank? %>
<%= url_for({:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %>
<% unless file.last_revision.comment.blank? %> comment: <%= file.last_revision.comment %><% end %>
<% end %>

View File

@ -1,17 +1,4 @@
<%
#disabled_workflow = []
#selected_workflow = nil
#unless User.current.allowed_to?(:file_approval, @project)
#disabled_workflow << 2
#current_workflow = upload.workflow
#if current_workflow == 1 || current_workflow == 2
#disabled_workflow << nil
#selected_workflow = 1
#end
#else
#selected_workflow = upload.workflow
#end
%>
<div class="box dmsf_detail">
<%= hidden_field_tag("commited_files[#{i}][disk_filename]", upload.disk_filename) %>
<div class="clear">

View File

@ -30,13 +30,7 @@
</p>
<p>
<%= label_tag("", l(:label_workflow) + ":") %>
<%= #case upload.workflow
# when 1 then l(:option_workflow_waiting_for_approval)
# when 2 then l(:option_workflow_approved)
# else l(:option_workflow_none)
# end
upload.workflow_str
%>
<%= upload.workflow_str true %>
</p>
</div>
<div class="splitcontentright clear">

View File

@ -1,13 +1,9 @@
<h3 class="title"><%= l(:label_dmsf_workflow) %></h3>
<%= form_tag({:controller => 'dmsf_workflows',
:action => 'new_action',
:object_type => DmsfWorkflow,
:object_id => @workflow.id,
:project_id => @project.id},
:remote => true,
<%= form_tag({:controller => 'dmsf_workflows', :action => 'new_action'},
:method => :post,
:id => 'new-action-form') do %>
:id => 'new-action-form') do %>
<%= hidden_field_tag :dmsf_workflow_step_assignment_id, params[:dmsf_workflow_step_assignment_id] %>
<%= hidden_field_tag :dmsf_file_revision_id, params[:dmsf_file_revision_id] %>
<p><label><%= radio_button_tag 'step_action', DmsfWorkflowStepAction::ACTION_APPROVE, true %> <%= l(:label_dmsf_wokflow_action_approve) %></label><br/></p>
@ -18,18 +14,14 @@
</p>
<p>
<label><%= radio_button_tag 'step_action', DmsfWorkflowStepAction::ACTION_DELEGATE %> <%= l(:label_dmsf_wokflow_action_delegate) %></label><br/>
<%= text_field_tag 'user_search', nil %>
<%= label_tag 'delegate', l(:label_dmsf_wokflow_action_delegate) %><br/>
<%= text_field_tag 'user_search', nil %>
<%= javascript_tag "observeSearchfield('user_search', 'users_for_delegate', '#{ escape_javascript autocomplete_for_user_dmsf_workflow_path(@workflow, :dmsf_workflow_step_assignment_id => params[:dmsf_workflow_step_assignment_id], :dmsf_file_revision_id => params[:dmsf_file_revision_id]) }')" %>
<%= content_tag('div', principals_radio_button_tags('step_action', @workflow.delegates(nil, params[:dmsf_workflow_step_assignment_id], params[:dmsf_file_revision_id], nil)), :id => 'users_for_delegate') %>
</p>
<%= javascript_tag "observeSearchfield('user_search', 'users_for_delegate', '#{ escape_javascript autocomplete_for_user_dmsf_workflow_path(@workflow) }')" %>
<div id="users_for_delegate">
<%= principals_check_box_tags 'watcher[user_ids][]', @workflow.delegates %>
</div>
<p class="buttons">
<%= submit_tag l(:submit_commit), :name => nil, :onclick => 'hideModal(this);' %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => 'hideModal(this);' %>
<%= submit_tag l(:submit_commit), :name => 'commit', :onclick => 'hideModal(this);' %>
<%= submit_tag l(:button_cancel), :name => 'commit', :onclick => 'hideModal(this);' %>
</p>
<% end %>

View File

@ -0,0 +1,21 @@
<h3 class="title"><%= l(:label_dmsf_workflow) %></h3>
<%= form_tag({:controller => 'dmsf_workflows', :action => 'assignment'},
:method => :post,
:id => 'assignment-form') do %>
<%= hidden_field_tag :dmsf_workflow_step_assignment_id, params[:dmsf_workflow_step_assignment_id] %>
<%= hidden_field_tag :dmsf_file_revision_id, params[:dmsf_file_revision_id] %>
<p>
<%= label_tag('workflow', l(:label_workflow) + ':') %>
<%= select_tag(
'dmsf_workflow_id',
dmsf_workflows_for_select(@project, nil))%>
</p>
<p class="buttons">
<%= submit_tag l(:button_assign), :name => 'commit', :onclick => 'hideModal(this);' %>
<%= submit_tag l(:button_cancel), :name => 'commit', :onclick => 'hideModal(this);' %>
</p>
<% end %>

View File

@ -61,10 +61,10 @@
<fieldset><legend><%=l(:label_user_new)%></legend>
<p><%= label_tag 'user_search', l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p>
<%= javascript_tag "observeSearchfield('user_search', null, '#{ escape_javascript autocomplete_for_user_dmsf_workflow_path(@workflow) }')" %>
<%= javascript_tag "observeSearchfield('user_search', 'users', '#{ escape_javascript autocomplete_for_user_dmsf_workflow_path(@workflow, :dmsf_workflow_step_assignment_id => nil, :dmsf_file_revision_id => nil, :project_id => @project ? @project.id : nil) }')" %>
<div id="users">
<%= render_principals_for_new_dmsf_workflow_users(@workflow) %>
<%= render_principals_for_new_dmsf_workflow_users(@workflow, nil, nil) %>
</div>
<p>

View File

@ -1 +0,0 @@
<h2>WorkflowController#action</h2>

View File

@ -0,0 +1,3 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'assign', :locals => {:workflow => @workflow}) %>');
showModal('ajax-modal', '400px');
$('#ajax-modal').addClass('assignment');

View File

@ -0,0 +1 @@
<%= render_principals_for_new_dmsf_workflow_users(@workflow, params[:dmsf_workflow_step_assignment_id], params[:dmsf_file_revision_id]) %>

View File

@ -1 +0,0 @@
$('#users').html('<%= escape_javascript(render_principals_for_new_dmsf_workflow_users(@workflow)) %>');

Binary file not shown.

Before

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 459 B

BIN
assets/images/none.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

BIN
assets/images/rejected.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -19,8 +19,8 @@ table.entries td.modified {
}
table.entries td.actions {
min-width: 108px;
width: 108px;
min-width: 116px;
width: 116px;
}
table.entries td.title {
@ -237,4 +237,26 @@ table.access-table tbody td, table.access-table tbody tr:hover td {
/* Approval workflow */
#admin-menu a.approvalworkflows { background-image: url(../images/ticket_go.png); }
#users_for_delegate {height: 200px; overflow:auto;}
#users_for_delegate label {display: block;}
#users_for_delegate label {display: block;}
.revision_box{
padding: 0px 0px 0px 0px;
margin-bottom: 10px;
background-color:#f6f6f6;
color:#505050;
line-height:1.5em;
/*border: 1px solid #e4e4e4;*/
}
div.revision_box .ui-widget-header {
font-weight: normal;
}
td.workflow {
font-size: 0.8em;
white-space: nowrap;
}
td.workflow img {
vertical-align:text-top;
}

View File

@ -45,7 +45,7 @@ en:
:link_title: "Title"
:link_size: "Size"
:link_modified: "Modified"
:link_ver: "Ver."
:link_ver: "Version"
:link_author: "Author"
:title_check_for_zip_download_or_email: "Check for Zip download or email"
:title_delete: "Delete"
@ -222,7 +222,12 @@ en:
label_dmsf_wokflow_action_approve: Approve
label_dmsf_wokflow_action_reject: Reject
label_dmsf_wokflow_action_delegate: 'Delegate to'
label_dmsf_wokflow_action_assign: 'Assign an approval workflow'
message_dmsf_wokflow_note: Your note...
title_draft: Draft
title_rejected: Rejected
label_dmsf_wokflow_action_start: Start workflow
label_dmsf_wokflow_action_start: Start workflow
info_revision: "r%{rev}"
link_workflow: Workflow
button_assign: Assign
error_empty_note: "The note can't be empty"

View File

@ -106,11 +106,14 @@ RedmineApp::Application.routes.draw do
member do
get 'autocomplete_for_user'
get 'action'
get 'assign'
post 'new_action'
post 'start'
post 'assignment'
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
match 'dmsf_workflows/:id/edit', :controller => 'dmsf_workflows', :action => 'reorder_steps', :id => /\d+/, :via => :put
end

10
init.rb
View File

@ -51,14 +51,14 @@ Redmine::Plugin.register :redmine_dmsf do
permission :view_dmsf_folders, {:dmsf => [:show], :dmsf_folders_copy => [:new, :copy_to, :move_to]}
permission :user_preferences, {:dmsf_state => [:user_pref_save]}
permission :view_dmsf_files, {:dmsf => [:entries_operation, :entries_email],
:dmsf_files => [:show], :dmsf_files_copy => [:new, :create, :move]}
:dmsf_files => [:show], :dmsf_files_copy => [:new, :create, :move]}
permission :folder_manipulation, {:dmsf => [:new, :create, :delete, :edit, :save, :edit_root, :save_root, :lock, :unlock]}
permission :file_manipulation, {:dmsf_files => [:create_revision, :delete, :lock, :unlock],
:dmsf_upload => [:upload_files, :upload_file, :commit_files]}
:dmsf_upload => [:upload_files, :upload_file, :commit_files]}
permission :file_approval, {:dmsf_files => [:delete_revision, :notify_activate, :notify_deactivate],
:dmsf => [:notify_activate, :notify_deactivate]}
permission :force_file_unlock, {}
permission :approval_workflows, {:dmsf_workflows => [:new, :create, :destroy, :edit, :add_step, :remove_step, :reorder_steps, :update]}
:dmsf => [:notify_activate, :notify_deactivate],
:dmsf_workflows => [:new, :create, :destroy, :edit, :add_step, :remove_step, :reorder_steps, :update, :start, :assign, :assignment, :action, :new_action]}
permission :force_file_unlock, {}
end
# Administration menu extension