diff --git a/lib/WebGUI/Operation.pm b/lib/WebGUI/Operation.pm
index cd0a13474..bf32d65b5 100644
--- a/lib/WebGUI/Operation.pm
+++ b/lib/WebGUI/Operation.pm
@@ -79,6 +79,8 @@ sub getOperations {
return {
'addWorkflow' => 'WebGUI::Operation::Workflow',
'deleteWorkflow' => 'WebGUI::Operation::Workflow',
+ 'editWorkflowActivity' => 'WebGUI::Operation::Workflow',
+ 'editWorkflowActivitySave' => 'WebGUI::Operation::Workflow',
'deleteWorkflowActivity' => 'WebGUI::Operation::Workflow',
'addWorkflowSave' => 'WebGUI::Operation::Workflow',
'editWorkflow' => 'WebGUI::Operation::Workflow',
diff --git a/lib/WebGUI/Operation/Workflow.pm b/lib/WebGUI/Operation/Workflow.pm
index 360558c72..4019f1285 100644
--- a/lib/WebGUI/Operation/Workflow.pm
+++ b/lib/WebGUI/Operation/Workflow.pm
@@ -16,6 +16,7 @@ use WebGUI::AdminConsole;
use WebGUI::HTMLForm;
use WebGUI::International;
use WebGUI::Workflow;
+use WebGUI::Workflow::Activity;
=head1 NAME
@@ -55,6 +56,7 @@ sub www_addWorkflow {
value=>"none",
hoverHelp=>$i18n->get("object type help")
);
+ $f->submit;
my $ac = WebGUI::AdminConsole->new($session,"workflow");
$ac->addSubmenuItem($session->url->page("op=manageWorkflows"), $i18n->get("manage workflows"));
return $ac->render($f->print);
@@ -72,7 +74,7 @@ sub www_addWorkflowSave {
my $session = shift;
return $session->privilege->insufficient() unless ($session->user->isInGroup("pbgroup000000000000015"));
my $workflow = WebGUI::Workflow->create($session, {type=>$session->form->get("type")});
- return www_editWorkflowSave($session, $workflow);
+ return www_editWorkflow($session, $workflow);
}
#-------------------------------------------------------------------
@@ -103,7 +105,10 @@ sub www_deleteWorkflowActivity {
my $session = shift;
return $session->privilege->insufficient() unless ($session->user->isInGroup("pbgroup000000000000015"));
my $workflow = WebGUI::Workflow->new($session, $session->form->get("workflowId"));
- $workflow->deleteActivity($session->form->get("activityId")) if defined $workflow;
+ if (defined $workflow) {
+ $workflow->deleteActivity($session->form->get("activityId"));
+ $workflow->set({enabled=>0});
+ }
return www_editWorkflow($session);
}
@@ -121,6 +126,19 @@ sub www_editWorkflow {
return $session->privilege->insufficient() unless ($session->user->isInGroup("pbgroup000000000000015"));
$workflow = WebGUI::Workflow->new($session, $session->form->get("workflowId")) unless (defined $workflow);
my $i18n = WebGUI::International->new($session, "Workflow");
+ my $workflowActivities = $session->config->get("workflowActivities");
+ my $addmenu = '
';
+ foreach my $activity (@{$workflowActivities->{$workflow->get("type")}}) {
+ my $cmd = "use $activity";
+ eval ($cmd);
+ if ($@) {
+ $session->errorHandler->warn("Couldn't compile activity package: ".$activity.". Root cause: ".$@);
+ return undef;
+ } else {
+ $addmenu .= '
getId).'">'.$activity->getName($session)."\n";
+ }
+ }
+ $addmenu .= '
';
my $f = WebGUI::HTMLForm->new($session);
$f->hidden(
name=>"op",
@@ -165,10 +183,19 @@ sub www_editWorkflow {
hoverHelp=>$i18n->get("is serial help")
);
$f->submit;
+ my $steps = '';
+ my $rs = $session->db->read("select activityId, title from workflowActivity where workflowId=?",[$workflow->getId]);
+ while (my ($id, $title) = $rs->array) {
+ $steps .= '| '
+ .$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)
+ .' | '.$title.' |
';
+ }
+ $steps .= '
';
my $ac = WebGUI::AdminConsole->new($session,"workflow");
$ac->addSubmenuItem($session->url->page("op=addWorkflow"), $i18n->get("add a new workflow"));
$ac->addSubmenuItem($session->url->page("op=manageWorkflows"), $i18n->get("manage workflows"));
- return $ac->render($f->print);
+ return $ac->render($f->print.$addmenu.$steps);
}
@@ -196,7 +223,61 @@ sub www_editWorkflowSave {
#-------------------------------------------------------------------
-=head2 www_manageCron ( )
+=head2 www_editWorkflowActivity ( )
+
+Displays a form to edit the properties of a workflow activity.
+
+=cut
+
+sub www_editWorkflowActivity {
+ my $session = shift;
+ return $session->privilege->insufficient() unless ($session->user->isInGroup("pbgroup000000000000015"));
+ my $activity = '';
+ if ($session->form->get("className")) {
+ $activity = WebGUI::Workflow::Activity->newByPropertyHashRef($session, {activityId=>"new",className=>$session->form->get("className")});
+ } else {
+ $activity = WebGUI::Workflow::Activity->new($session, $session->form->get("activityId"));
+ }
+ my $form = $activity->getEditForm;
+ $form->hidden( name=>"op", value=>"editWorkflowActivitySave");
+ $form->hidden( name=>"workflowId", value=>$session->form->get("workflowId"));
+ $form->submit;
+ my $i18n = WebGUI::International->new($session, "Workflow");
+ my $ac = WebGUI::AdminConsole->new($session,"workflow");
+ $ac->addSubmenuItem($session->url->page("op=addWorkflow"), $i18n->get("add a new workflow"));
+ $ac->addSubmenuItem($session->url->page("op=manageWorkflows"), $i18n->get("manage workflows"));
+ return $ac->render($form->print,$activity->getName($session));
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_editWorkflowActivitySave ( )
+
+Saves the results of www_editWorkflowActivity().
+
+=cut
+
+sub www_editWorkflowActivitySave {
+ my $session = shift;
+ return $session->privilege->insufficient() unless ($session->user->isInGroup("pbgroup000000000000015"));
+ my $workflow = WebGUI::Workflow->new($session, $session->form->get("workflowId"));
+ if (defined $workflow) {
+ my $activityId = $session->form->get("activityId");
+ my $activity = '';
+ if ($activityId eq "new") {
+ $activity = $workflow->addActivity($session->form->get("className"));
+ } else {
+ $activity = $workflow->getActivity($activityId);
+ }
+ $activity->processPropertiesFromFormPost;
+ $workflow->set({enabled=>0});
+ }
+ return www_editWorkflow($session);
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_manageWorkflows ( )
Display a list of the workflows.
diff --git a/lib/WebGUI/Workflow/Activity.pm b/lib/WebGUI/Workflow/Activity.pm
index b2fae351b..d0d9e8aaa 100644
--- a/lib/WebGUI/Workflow/Activity.pm
+++ b/lib/WebGUI/Workflow/Activity.pm
@@ -192,14 +192,17 @@ Returns the form that will be used to edit the properties of an activity.
sub getEditForm {
my $self = shift;
my $form = WebGUI::HTMLForm->new($self->session);
- foreach my $definition (reverse @{$self->definition($self->session)}) {
+ $form->hidden(name=>"activityId", value=>$self->getId);
+ $form->hidden(name=>"className", value=>$self->get("className"));
+ my $fullDefinition = $self->definition($self->session);
+ foreach my $definition (reverse @{$fullDefinition}) {
my $properties = $definition->{properties};
foreach my $fieldname (keys %{$properties}) {
my %params;
foreach my $key (keys %{$properties->{$fieldname}}) {
$params{$key} = $properties->{$fieldname}{$key};
if ($fieldname eq "title" && lc($params{$key}) eq "untitled") {
- $params{$key} = $definition->[0]{name};
+ $params{$key} = $fullDefinition->[0]{name};
}
}
$params{value} = $self->get($fieldname);
@@ -285,6 +288,38 @@ sub new {
#-------------------------------------------------------------------
+=head2 newByPropertyHashRef ( session, properties )
+
+Constructor.
+
+=head3 session
+
+A reference to the current session.
+
+=head3 properties
+
+A properties hash reference. The className of the properties hash must be valid.
+
+=cut
+
+sub newByPropertyHashRef {
+ my $class = shift;
+ my $session = shift;
+ my $properties = shift;
+ return undef unless defined $properties;
+ return undef unless exists $properties->{className};
+ my $className = $properties->{className};
+ my $cmd = "use ".$className;
+ eval ($cmd);
+ if ($@) {
+ $session->errorHandler->warn("Couldn't compile activity package: ".$className.". Root cause: ".$@);
+ return undef;
+ }
+ bless {_session=>$session, _id=>$properties->{activityId}, _data => $properties}, $className;
+}
+
+#-------------------------------------------------------------------
+
=head2 processPropertiesFromFormPost ( )
Updates activity with data from Form.
diff --git a/lib/WebGUI/i18n/English/Workflow.pm b/lib/WebGUI/i18n/English/Workflow.pm
index dae2c79c1..99112af8d 100644
--- a/lib/WebGUI/i18n/English/Workflow.pm
+++ b/lib/WebGUI/i18n/English/Workflow.pm
@@ -1,6 +1,12 @@
package WebGUI::i18n::English::Workflow;
our $I18N = {
+ 'confirm delete activity' => {
+ message => q|Are you certain you wish to delete this activity from this workflow?|,
+ context => q|prompt the user before deleting an activity from a workflow|,
+ lastUpdated => 0,
+ },
+
'are you sure you want to delete this workflow' => {
message => q|Are you certain you wish to delete this workflow and all running instances of it?|,
context => q|prompt the user before deleting a workflow|,