can now move workflow activities up and down within a workflow
This commit is contained in:
parent
a794fbd0d7
commit
70c501f8f2
3 changed files with 114 additions and 1 deletions
|
|
@ -87,6 +87,8 @@ sub getOperations {
|
||||||
'manageRevisionsInTag' => 'WebGUI::Operation::VersionTag',
|
'manageRevisionsInTag' => 'WebGUI::Operation::VersionTag',
|
||||||
'rollbackVersionTag' => 'WebGUI::Operation::VersionTag',
|
'rollbackVersionTag' => 'WebGUI::Operation::VersionTag',
|
||||||
'setWorkingVersionTag' => 'WebGUI::Operation::VersionTag',
|
'setWorkingVersionTag' => 'WebGUI::Operation::VersionTag',
|
||||||
|
'promoteWorkflowActivity' => 'WebGUI::Operation::Workflow',
|
||||||
|
'demoteWorkflowActivity' => 'WebGUI::Operation::Workflow',
|
||||||
'addWorkflow' => 'WebGUI::Operation::Workflow',
|
'addWorkflow' => 'WebGUI::Operation::Workflow',
|
||||||
'deleteWorkflow' => 'WebGUI::Operation::Workflow',
|
'deleteWorkflow' => 'WebGUI::Operation::Workflow',
|
||||||
'runWorkflow' => 'WebGUI::Operation::Workflow',
|
'runWorkflow' => 'WebGUI::Operation::Workflow',
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,26 @@ sub www_deleteWorkflowActivity {
|
||||||
return www_editWorkflow($session);
|
return www_editWorkflow($session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_demoteWorkflowActivity ( session )
|
||||||
|
|
||||||
|
Moves a workflow activity down one position in the execution order.
|
||||||
|
|
||||||
|
=head3 session
|
||||||
|
|
||||||
|
A reference to the current session.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_demoteWorkflowActivity {
|
||||||
|
my $session = shift;
|
||||||
|
return $session->privilege->insufficient() unless ($session->user->isInGroup("pbgroup000000000000015"));
|
||||||
|
my $workflow = WebGUI::Workflow->new($session, $session->form->param("workflowId"));
|
||||||
|
$workflow->demoteActivity($session->form->param("activityId"));
|
||||||
|
return www_editWorkflow($session);
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_editWorkflow ( session, workflow )
|
=head2 www_editWorkflow ( session, workflow )
|
||||||
|
|
@ -184,11 +204,13 @@ sub www_editWorkflow {
|
||||||
);
|
);
|
||||||
$f->submit;
|
$f->submit;
|
||||||
my $steps = '<table class="content">';
|
my $steps = '<table class="content">';
|
||||||
my $rs = $session->db->read("select activityId, title from workflowActivity where workflowId=?",[$workflow->getId]);
|
my $rs = $session->db->read("select activityId, title from workflowActivity where workflowId=? order by sequenceNumber",[$workflow->getId]);
|
||||||
while (my ($id, $title) = $rs->array) {
|
while (my ($id, $title) = $rs->array) {
|
||||||
$steps .= '<tr><td>'
|
$steps .= '<tr><td>'
|
||||||
.$session->icon->delete("op=deleteWorkflowActivity;workflowId=".$workflow->getId.";activityId=".$id, undef, $i18n->get("confirm delete activity"))
|
.$session->icon->delete("op=deleteWorkflowActivity;workflowId=".$workflow->getId.";activityId=".$id, undef, $i18n->get("confirm delete activity"))
|
||||||
.$session->icon->edit("op=editWorkflowActivity;workflowId=".$workflow->getId.";activityId=".$id)
|
.$session->icon->edit("op=editWorkflowActivity;workflowId=".$workflow->getId.";activityId=".$id)
|
||||||
|
.$session->icon->moveDown("op=demoteWorkflowActivity;workflowId=".$workflow->getId.";activityId=".$id)
|
||||||
|
.$session->icon->moveUp("op=promoteWorkflowActivity;workflowId=".$workflow->getId.";activityId=".$id)
|
||||||
.'</td><td>'.$title.'</td></tr>';
|
.'</td><td>'.$title.'</td></tr>';
|
||||||
}
|
}
|
||||||
$steps .= '</table>';
|
$steps .= '</table>';
|
||||||
|
|
@ -302,6 +324,27 @@ sub www_manageWorkflows {
|
||||||
return $ac->render($output);
|
return $ac->render($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_promoteWorkflowActivity ( session )
|
||||||
|
|
||||||
|
Moves a workflow activity up one position in the execution order.
|
||||||
|
|
||||||
|
=head3 session
|
||||||
|
|
||||||
|
A reference to the current session.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_promoteWorkflowActivity {
|
||||||
|
my $session = shift;
|
||||||
|
return $session->privilege->insufficient() unless ($session->user->isInGroup("pbgroup000000000000015"));
|
||||||
|
my $workflow = WebGUI::Workflow->new($session, $session->form->param("workflowId"));
|
||||||
|
$workflow->promoteActivity($session->form->param("activityId"));
|
||||||
|
return www_editWorkflow($session);
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_runWorkflow ( )
|
=head2 www_runWorkflow ( )
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,31 @@ sub deleteActivity {
|
||||||
$activity->delete if ($activity);
|
$activity->delete if ($activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 demoteActivity ( activityId )
|
||||||
|
|
||||||
|
Moves an activity down one position in the execution order.
|
||||||
|
|
||||||
|
=head3 activityId
|
||||||
|
|
||||||
|
The id of the activity to move.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub demoteActivity {
|
||||||
|
my $self = shift;
|
||||||
|
my $thisId = shift;
|
||||||
|
my ($thisSeq) = $self->session->db->quickArray("select sequenceNumber from WorkflowActivity where activityId=?",[$thisId]);
|
||||||
|
my ($otherId) = $self->session->db->quickArray("select activityId from WorkflowActivity where workflowId=? and sequenceNumber=?",[$self->getId, $thisSeq+1]);
|
||||||
|
if ($otherId ne "") {
|
||||||
|
$self->session->db->write("update WorkflowActivity set sequenceNumber=sequenceNumber+1 where activityId=?", [$thisId]);
|
||||||
|
$self->session->db->write("update WorkflowActivity set sequenceNumber=sequenceNumber-1 where activityId=?", [$otherId]);
|
||||||
|
$self->reorderActivities;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 DESTROY ( )
|
=head2 DESTROY ( )
|
||||||
|
|
@ -286,6 +311,49 @@ sub new {
|
||||||
bless {_session=>$session, _id=>$workflowId, _data=>$data}, $class;
|
bless {_session=>$session, _id=>$workflowId, _data=>$data}, $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 promoteActivity ( activityId )
|
||||||
|
|
||||||
|
Moves an activity up one position in the execution order.
|
||||||
|
|
||||||
|
=head3 activityId
|
||||||
|
|
||||||
|
The id of the activity to move.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub promoteActivity {
|
||||||
|
my $self = shift;
|
||||||
|
my $thisId = shift;
|
||||||
|
my ($thisSeq) = $self->session->db->quickArray("select sequenceNumber from WorkflowActivity where activityId=?",[$thisId]);
|
||||||
|
my ($otherId) = $self->session->db->quickArray("select activityId from WorkflowActivity where workflowId=? and sequenceNumber=?",[$self->getId, $thisSeq-1]);
|
||||||
|
if ($otherId ne "") {
|
||||||
|
$self->session->db->write("update WorkflowActivity set sequenceNumber=sequenceNumber-1 where activityId=?", [$thisId]);
|
||||||
|
$self->session->db->write("update WorkflowActivity set sequenceNumber=sequenceNumber+1 where activityId=?", [$otherId]);
|
||||||
|
$self->reorderActivities;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head3 reorderActivities ( )
|
||||||
|
|
||||||
|
Reorders the acitivities to make sure they're consecutive.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub reorderActivities {
|
||||||
|
my $self = shift;
|
||||||
|
my $sth = $self->session->db->read("select activityId from WorkflowActivity where workflowId=? order by sequenceNumber",[$self->getId]);
|
||||||
|
my $i = 0;
|
||||||
|
while (my ($id) = $sth->array) {
|
||||||
|
$i++;
|
||||||
|
$self->session->db->write("update WorkflowActivity set sequenceNumber=? where activityId=?",[$i, $id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 session ( )
|
=head2 session ( )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue