Editing user in an approval workflow step #801
This commit is contained in:
parent
a1ddf4e45f
commit
b25bdf18bb
@ -26,6 +26,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
before_action :find_project
|
||||
before_action :authorize_custom
|
||||
before_action :permissions, :only => [:new_action, :assignment, :start]
|
||||
before_action :approver_candidates, :only => [:remove_step, :show, :reorder_steps, :add_step]
|
||||
|
||||
layout :workflows_layout
|
||||
|
||||
@ -425,14 +426,16 @@ class DmsfWorkflowsController < ApplicationController
|
||||
end
|
||||
end
|
||||
end
|
||||
# Operators
|
||||
# Operators/Assignees
|
||||
if params[:operator_step].present?
|
||||
params[:operator_step].each do |id, operator|
|
||||
step = DmsfWorkflowStep.find_by_id id
|
||||
if step
|
||||
step.operator = operator.to_i
|
||||
step.user_id = params[:assignee][id]
|
||||
unless step.save
|
||||
flash[:error] = step.errors.full_messages.to_sentence
|
||||
Rails.logger.error step.errors.full_messages.to_sentence
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -492,4 +495,9 @@ private
|
||||
require_admin
|
||||
end
|
||||
end
|
||||
|
||||
def approver_candidates
|
||||
@approving_candidates = @project ? @project.users.to_a : User.active.to_a
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -93,7 +93,9 @@
|
||||
<%= delete_link delete_step_dmsf_workflow_path(:step => step.id) %>
|
||||
</div>
|
||||
<div class="dmsf_child_container">
|
||||
<%= link_to_user step.user %>
|
||||
<%= select_tag "assignee[#{step.id}]",
|
||||
principals_options_for_select(@approving_candidates | [step.user], step.user),
|
||||
:include_blank => false %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@ -381,12 +381,27 @@ class DmsfWorkflowsControllerTest < RedmineDmsf::Test::TestCase
|
||||
end
|
||||
|
||||
def test_update_step_operators
|
||||
put :update_step, :id => @wf1, :step => '1', :operator_step => {@wfs1.id.to_s => DmsfWorkflowStep::OPERATOR_OR.to_s}
|
||||
put :update_step,
|
||||
:id => @wf1,
|
||||
:step => '1',
|
||||
:operator_step => { @wfs1.id.to_s => DmsfWorkflowStep::OPERATOR_OR.to_s },
|
||||
:assignee => { @wfs1.id.to_s => @wfs1.user_id.to_s }
|
||||
assert_response :redirect
|
||||
@wfs1.reload
|
||||
assert_equal @wfs1.operator, DmsfWorkflowStep::OPERATOR_OR
|
||||
end
|
||||
|
||||
def test_update_step_assignee
|
||||
put :update_step,
|
||||
:id => @wf1,
|
||||
:step => '1',
|
||||
:operator_step => { @wfs1.id.to_s => DmsfWorkflowStep::OPERATOR_OR.to_s },
|
||||
:assignee => { @wfs1.id.to_s => @user_non_member.id.to_s }
|
||||
assert_response :redirect
|
||||
@wfs1.reload
|
||||
assert_equal @user_non_member.id, @wfs1.user_id
|
||||
end
|
||||
|
||||
def test_delete_step
|
||||
name = @wfs2.name
|
||||
assert_difference 'DmsfWorkflowStep.count', -1 do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user