[Rt-commit] rt branch, admin_ui, updated. 9238f934c272e9ce28e78925f7210173c7d3486e
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Tue Dec 15 02:50:49 EST 2009
The branch, admin_ui has been updated
via 9238f934c272e9ce28e78925f7210173c7d3486e (commit)
from 97d695c2afe34a2185f0c3c6e4dd0c82c6d6a6c3 (commit)
Summary of changes:
lib/RT/Action/EditWorkflowStatuses.pm | 74 +++++++++++++++++++++++++++++++++
1 files changed, 74 insertions(+), 0 deletions(-)
create mode 100644 lib/RT/Action/EditWorkflowStatuses.pm
- Log -----------------------------------------------------------------
commit 9238f934c272e9ce28e78925f7210173c7d3486e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Dec 15 15:50:22 2009 +0800
add EditWorkflowStatuses action
diff --git a/lib/RT/Action/EditWorkflowStatuses.pm b/lib/RT/Action/EditWorkflowStatuses.pm
new file mode 100644
index 0000000..33a3d48
--- /dev/null
+++ b/lib/RT/Action/EditWorkflowStatuses.pm
@@ -0,0 +1,74 @@
+use strict;
+use warnings;
+
+package RT::Action::EditWorkflowStatuses;
+use base qw/RT::Action Jifty::Action/;
+use RT::Workflow;
+use Scalar::Defer;
+
+__PACKAGE__->mk_accessors('name');
+
+sub arguments {
+ my $self = shift;
+ return {} unless $self->name;
+ my $args = {
+ name => {
+ render_as => 'hidden',
+ default_value => $self->name,
+ },
+ };
+
+ my $schema = RT::Workflow->new->load( $self->name );
+
+ for my $type (qw/initial active inactive/) {
+ $args->{$type} =
+ { default_value => defer { ( join ', ', $schema->$type ) || '' }, };
+ }
+
+ return $args;
+}
+
+=head2 take_action
+
+=cut
+
+sub take_action {
+ my $self = shift;
+
+ my $name = $self->argument_value('name');
+ return unless $name;
+
+ my $schema = RT::Workflow->new->load( $name );
+ my %tmp;
+ foreach my $type ( qw(initial active inactive) ) {
+ $tmp{$type} = [
+ grep length && defined,
+ map { s/^\s+//; s/\s+$//; $_ }
+ split /\s*,\s*/,
+ $self->argument_value($type),
+ ];
+ }
+ my ($status, $msg) = $schema->set_statuses( %tmp );
+ unless ($status) {
+ Jifty->log->error(
+ 'failed to set statuses for workflow ' . $name . ': ' . $msg );
+ return;
+ }
+
+ $self->report_success;
+ return 1;
+}
+
+=head2 report_success
+
+=cut
+
+sub report_success {
+ my $self = shift;
+
+ # Your success message here
+ $self->result->message('Success');
+}
+
+1;
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list