Subject: | Re: Proposal change to the Workflow Module |
Date: | Thu, 17 Dec 2009 14:00:21 +0100 |
To: | Jonas Brømsø Nielsen <jonasbn [...] gmail.com> |
From: | Steven van der Vegt <steven [...] echelon.nl> |
Hi Jonas,
Thanks for your response and looking at my changes!
I've another proposal for the library:
When a validation error occurs I'd like to see which fields caused the error. Therefore I added the following lines to Workflow::Exception :
'Workflow::Exception::Validation' => {
isa => 'Workflow::Exception',
description => 'Validation errors',
--> fields => 'invalid_fields', <--
},
This creates an getter and setter in the exception for the invalid_fields
And I added the following line to Workflow::Validator::HasRequiredField :
validation_error "The following fields require a value: ",
join ( ', ',@no_value) ,
--> { invalid_fields => \@no_value }; <--
Now it is possible to access the fields like this:
if ($e = Exception::Class->caught('Workflow::Exception::Validation') ) {
my @invalid_fields = $e->invalid_fields;
# do something with the fields like coloring this borders of the field or give feedback to the user.
}
What do you think about it? If you rather like a diff file instead of this code, I can send you one.
Kind regards,
Steven van der Vegt
Jonas Brømsø Nielsen schreef:
Show quoted text
> Hi Steven,
>
> Thanks for the contribution - I am forwarding it to RT for the reference.
>
> I will let you now how it goes with your patch.
>
> jonasbn
>
> On 03/12/2009, at 16.45, Steven van der Vegt wrote:
>
>
--
Steven van der Vegt
Echelon BV
E: steven@echelon.nl
T: (053)4836585
F: (053)4336222
W: www.echelon.nl
KVK: 06055381
>> Hello Jonas,
>>
>> I'm using your Workflow module for a few months with great satisfaction.
>> I noticed that the autorun functionality doesn't work on the INITIAL state. Because I think this feature is kind of handy I made a patch for the Factory.pm file. I also added the feature to include a context in the create_workflow and fetch_workflow method call.
>> The reason for this change is that from the moment a workflow is created I want to connect this to a customer. Therefor direct after the creation an action must be executed.
>>
>> I'm really interested in your view upon this change.
>>
>> Kind regards,
>>
>> --
>> Steven van der Vegt
>> Echelon BV
>>
>> E: steven@echelon.nl
>> T: (053)4836585
>> F: (053)4336222
>> W: www.echelon.nl
>>
>> KVK: 06055381
>>
>> 329c329
>> < my ( $self, $wf_type, $context ) = @_;
>> ---
>>
>
>
>>> my ( $self, $wf_type ) = @_;
>>>
>> 339c339
>> < $wf->context( $context || Workflow::Context->new );
>> ---
>>
>>> $wf->context( Workflow::Context->new );
>>>
>> 369,378d368
>> < my $state = $wf->_get_workflow_state();
>> < if ($state->autorun) {
>> < $log->is_info
>> < && $log->info(
>> < "State '$state' marked to be run ",
>> < "automatically; executing that state/action..."
>> < );
>> < $wf->_auto_execute_state($state);
>> < }
>> <
>> 383c373
>> < my ( $self, $wf_type, $wf_id, $context) = @_;
>> ---
>>
>>> my ( $self, $wf_type, $wf_id ) = @_;
>>>
>> 402c392
>> < $wf->context( $context || Workflow::Context->new ) if (not $wf->context());
>> ---
>>
>>> $wf->context( Workflow::Context->new ) if (not $wf->context());
>>>