Yii Framework Forum: [EXTENSION] simpleWorkflow - Yii Framework Forum

Jump to content

  • (8 Pages)
  • +
  • « First
  • 5
  • 6
  • 7
  • 8
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] simpleWorkflow a small workflow handler for models Rate Topic: ***** 3 Votes

#121 User is offline   Markz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 16-April 13

Posted 25 April 2013 - 04:04 AM

Hi raoul,

I got this error "Non-static method SWHelper::_createListData() should not be called statically".
I used the latest simpleWorkflow-1.1.0.0 version. I have edited the method to static and its working now.
I just wonder if it is a bug or there is something wrong on how I used the workflow?

Thanks.
0

#122 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 637
  • Joined: 29-November 08
  • Location:Paris, France

Posted 25 April 2013 - 09:19 AM

Hi Jan,
you are right, this is a bug I fixed but did not commit. Good job ! I will release a new version that includes the fix.
ciao
8)
0

#123 User is offline   Markz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 16-April 13

Posted 25 April 2013 - 10:48 AM

Thanks Raoul.

I have this problem on auto update of the status on one of my table.
I have been reading your documentation and as well as the previous issues posted on this thread to find the solution but I was not able to got an answer or maybe I was not able to understand.

Maybe it is better to ask directly from the developer itself.
As what I have understand, the simpleworkflow extension it will handle the update of the status field of the model.
On my code, when a new record is created/inserted to the table, the status field is set automatically base on the initial status I set on the workflow files. That is without me doing anything to set the status.

However, when I update the record I expect it change the status to next status on my workflow. But it did not change.
What could be possible problem on this.

Below is the content of my swNotice.php on /protected/models/workflows:
return array(
		'initial' => 'Draft',
		'node' => array(
			array('id'=>'Draft', 'transition'=>'Published',),
			array('id'=>'Published')
		)
	);


Below is the code for my model update:

if(isset($_POST['Notice']))
		{
			$model->attributes=$_POST['Notice'];
			
			$model->swNextStatus('swNotice/Draft');
			
			if($model->save()){
				$this->redirect(array('view','id'=>$model->id));
			}
		}


I believe the line $model->swNextStatus('swNotice/Draft'); will trigger the change but it won't.
Am I right with this assumption, or do I need add some code somewhere else.

I also tried $model->swNextStatus('Draft');, still the same result.

Right now, I just manually change the status with $model->status = 'swNotice/Published';
But I would really want to make this to auto change the status. Since I will be using the workflow on another model that will have 5 statuses.


I would greatly appreciate if you could enlighten me this problem of mine.
Thanks.
0

#124 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 637
  • Joined: 29-November 08
  • Location:Paris, France

Posted 25 April 2013 - 01:57 PM

Hi Jan,
in fact, the method swNextStatus("swNotice/Draft") will not send the model into the "next status" from "swNoticeDraft", but will set the status to "swNotice/Draft".

In other words, the model is sent into the status whose name is passed as argument to the swNextStatus() method (if of course, it can be reached from the current status).

Ok, maybe the name of the method is not correctly choosen ! ::)

On the other hand, it is not always possible to find a single "next status". In your case it is obvious because 'draft' has only one next status (that is 'published'), but most of the time, more than one status can be reached from a given status.

One "weakness" of the simpleWorkflow extension is it ability to automatically change status of the model ... it has been designed to be driven by user.

Now, how to solve your issue ? one possible solution is to get the list of all status that can be reached from the current status, and if there is only one, then use it.
Below is a sample (not tested ... away from computer).

$next = $model->swGetNextStatus();
if( count($next) == 1){
	$model->swNextStatus($next[0]);
}else {
	// well ... more than one status can be reached from the
	// current model status : do what you want here ;)
}

(If it doesn't work as expected, tell me)

Hope this helps
B)

0

#125 User is offline   hacmieu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 21-April 12

Posted 11 May 2013 - 05:52 AM

Dear Raoul,
I'm newbie in Yii & PHP. Could you send me full source code of demo + DB. I downloaded your extension but I can't run it.
Thank a lot!
0

#126 User is offline   hacmieu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 21-April 12

Posted 11 May 2013 - 11:14 AM

Dear Raoul,
I followed your tutorial to modify YiiBlog. Everything is okie. But now I want use SimpleWorkflow with x-editable & yiiBootstrap.
	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
        <?php echo $form->dropDownList($model,'status',SWHelper::nextStatuslistData($model)); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

        <?php echo $form->labelEx($model,'status'); ?>
        <?php
        $this->widget('editable.EditableField', array(
            'type'      => 'select',
            'model'     => $model,
            'attribute' => 'status',
            'url'       => $this->createUrl('post/updatePost'),
            'source'    => (SWHelper::allStatuslistData($model)),
//            'source'    => array('site/getStatusList'),
            'placement' => 'right',
        ));
        ?>

But the result is:
Attached File  incorrect.png (7.81K)
Number of downloads: 11
I want result is.
Attached File  correct.png (4.16K)
Number of downloads: 13
Please tell me how to do that.
Many many thanks!
0

#127 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 637
  • Joined: 29-November 08
  • Location:Paris, France

Posted 11 May 2013 - 05:31 PM

Hi Hacmieu,
I'm not familiar with the x-editable extension but maybe that if your replace

'source'	=> (SWHelper::allStatuslistData($model)),


...by ...

'source'	=> SWHelper::nextStatuslistData($model),


..the dropdown box should contain only possible next statuses).

Hope this helps
ciao
B)
0

#128 User is offline   hacmieu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 21-April 12

Posted 12 May 2013 - 02:42 AM

View PostRaoul, on 11 May 2013 - 05:31 PM, said:

Hi Hacmieu,
I'm not familiar with the x-editable extension but maybe that if your replace

'source'	=> (SWHelper::allStatuslistData($model)),


...by ...

'source'	=> SWHelper::nextStatuslistData($model),


..the dropdown box should contain only possible next statuses).

Hope this helps
ciao
B)


It doesn't work. But by the way, thank you very much :D I love this extension :D
0

#129 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 637
  • Joined: 29-November 08
  • Location:Paris, France

Posted 12 May 2013 - 03:18 PM

humm ... strange.
Could you please try to replace the call to SWHelper::nextStatuslistData() by an array like

'source' => array('id1'=>'value1','id2'=>'value2')


Just to check if the x-editable extension is all right

Then could you dump the value returned by SWHelper::nextStatuslistData() ? Normally it should return an array where each key is the status id and each value is the status label, ans that only for statuses that can be reached from the current model status.

I'll be glad yo help you but I need more info ;)

ciao
B)
0

#130 User is offline   hacmieu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 21-April 12

Posted 13 May 2013 - 05:41 AM

View PostRaoul, on 12 May 2013 - 03:18 PM, said:

humm ... strange.
Could you please try to replace the call to SWHelper::nextStatuslistData() by an array like

'source' => array('id1'=>'value1','id2'=>'value2')


Just to check if the x-editable extension is all right

Then could you dump the value returned by SWHelper::nextStatuslistData() ? Normally it should return an array where each key is the status id and each value is the status label, ans that only for statuses that can be reached from the current model status.

I'll be glad yo help you but I need more info ;)

ciao
B)

Here you are!
Attached File  5-13-2013 5-39-46 PM.png (8.15K)
Number of downloads: 7
0

#131 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 637
  • Joined: 29-November 08
  • Location:Paris, France

Posted 13 May 2013 - 07:52 AM

ok, so the x-editable seems fine.

Now what about the value returned by SWHelper::nextStatuslistData() ? Could you print it somewhere so we have a look ?

B)
0

#132 User is offline   hacmieu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 21-April 12

Posted 13 May 2013 - 07:59 AM

View PostRaoul, on 13 May 2013 - 07:52 AM, said:

ok, so the x-editable seems fine.

Now what about the value returned by SWHelper::nextStatuslistData() ? Could you print it somewhere so we have a look ?

B)


And here :D
I found that if I refresh page then x-editable reload SWHelper::nextStatuslistData is update ok.
Attached File  5-13-2013 7-56-28 PM.png (5.94K)
Number of downloads: 8
0

#133 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 637
  • Joined: 29-November 08
  • Location:Paris, France

Posted 13 May 2013 - 09:09 AM

Thanks.
The value returned seems ok .. I mean, I don't know what are the actual next Statuses for the model you used for this test, but assuming that they are "ready" and "onLoan", the dropdown bow should contain them.


I don't know how x-editable works, but what you say is intresting : "when I refresh it's ok" ... but then when does it not work ? .. on which circumstances ?

Please note that if there some ajax call made by the x-editable extension, what you wrote will initialize the dorpdown when the page is rendered by you controller ... and no more. So, the list of next statuses you will always get, is the one corresponding to the model at the time the page is rendered ! ... no dynamic update here.

Again, I suspect that the problem comes from how you want to use x-editable but as I've never used it, it's quite difficult for me to help (sorry)


ciao
B)
0

#134 User is offline   hacmieu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 21-April 12

Posted 14 May 2013 - 10:09 AM

View PostRaoul, on 13 May 2013 - 09:09 AM, said:

Thanks.
The value returned seems ok .. I mean, I don't know what are the actual next Statuses for the model you used for this test, but assuming that they are "ready" and "onLoan", the dropdown bow should contain them.


I don't know how x-editable works, but what you say is intresting : "when I refresh it's ok" ... but then when does it not work ? .. on which circumstances ?

Please note that if there some ajax call made by the x-editable extension, what you wrote will initialize the dorpdown when the page is rendered by you controller ... and no more. So, the list of next statuses you will always get, is the one corresponding to the model at the time the page is rendered ! ... no dynamic update here.

Again, I suspect that the problem comes from how you want to use x-editable but as I've never used it, it's quite difficult for me to help (sorry)


ciao
B)

Thank you very much!
I disable x-editable for Status. Everything ok now! :D
0

#135 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 637
  • Joined: 29-November 08
  • Location:Paris, France

Posted 26 May 2013 - 10:38 AM

Hi,
A new version of the simpleWorkflow extension has been released.

VERSION 1.1.0.8

  • gii command : add SWyEdConverterDOM that uses DOM extension. If domxml extension is available, use it in priority otherwise use DOM.
  • add swSetStatus() to replace swNextStatus() which is still supported, but deprecated

This is a minor update so unless you want to use the Gii command to import workflow created with yEd and you don't have domxml installed, no update is needed.

ciao

B)
0

#136 User is offline   salsero 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 80
  • Joined: 05-September 12
  • Location:Italia

Posted 26 May 2013 - 11:25 AM

Thank's Raoul for your work!
;)

i did read in SWValidator:
const SW_SCENARIO_STATUS_SEPARATOR='-';


instead of
 const SW_SCENARIO_STATUS_SEPARATOR='_';


which are the effects/repercussions of that modify?

best regards!
0

#137 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 637
  • Joined: 29-November 08
  • Location:Paris, France

Posted 22 June 2013 - 10:26 PM

This modification is only relevant if you're using validation based on transition scenario. In this case, the scenario name to go from status "workflow1/statusA" to "workflow1/statusB" is should be :

"sw:workflow1/statusA-workflow1/statusB" instead of "sw:workflow1/statusA_workflow1/statusB"

(basically, the '-' is replaced by '_')

ciao
B)

ps: sorry for this late reply but the notification did not notified by of your message Salsero !!
0

#138 User is offline   salsero 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 80
  • Joined: 05-September 12
  • Location:Italia

Posted 24 June 2013 - 02:19 AM

ok raoul i suspected it and now i have the confirmation!
thank's for your replay ;)
0

#139 User is offline   Ferllings 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 14-November 10

Posted 09 July 2013 - 05:41 AM

Hello,

I'm using your great extension for months now.
I'm looking for a way to achieve a specific behavior:

I have another field 'category'. I is possible to insert an extra node, only if category is equal to a specific value?

Or maybe to use another workflow, for this specific category value?
0

#140 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 637
  • Joined: 29-November 08
  • Location:Paris, France

Posted 09 July 2013 - 01:39 PM

Hi Ferlings,
I'm not sure to understand what you mean by "insert an extra node" but please note that the workflow definition has been designed to be static and consequently "inserting a node" based on some external condition, is something that you "should not" be able to do.

If you want your model to be able to reach an existing node only if this 'categroy' field is equal to a specific value, that could indeed be achieved using status constraints. In the example provided, the constraint is applied on the current user access rights, but it could also be applied to the model and so, you could write some condition on the 'category' field.

Could you please elaborate on the use case that would require such behavior ? ... maybe that could help me understand how to solve your problem using the current implementation.

ciao
B)
0

Share this topic:


  • (8 Pages)
  • +
  • « First
  • 5
  • 6
  • 7
  • 8
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users