raoul2000 / yii2-workflow

A simple workflow engine for Yii2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visualisation of Workflow Definition

philippfrenzel opened this issue · comments

Hi,

have you ever thought about a simple "Widget" that shows a visualisation of the Workflow definition?

Would love to implement something so a user can see in which state of the workflow he is and what would be the next options for him....

commented

Hi,

yes, that's something that is among future dev I would like to implement. I thought about creating a module dedicated to workflow management for admin (the module would depend on yii2-workflow). It could be possible to get a graphical representation of a workflow and perform usual operations like create or update.

I found the vis.js library that provides examples really close to what could be included in the module (for instance this example).

Another option would be to something equivalent to the Gii command I created for the previous version. The goal was to us this great yEd editor to create a workflow,, save it as graphml file, and then convert it into a yii2-workflow format (PHP class + array).

Your idea of widget is also intresting. Up to now I've been using some very standard dropdown list that contains possible next statuses ... but a more graphical representation would indeed be very intresting.

...but as you may have guessed, my free time is currently difficult to find, so if you feel like starting something, be sure I'll be there to help !

Hi, like the vis.js - I will write a general yii2 extension for this and then I'll try to figure out how to link it to your extension;)

Btw. I would although love to see some kind of "progress" like implementation?
I'll make a mockup and post it later today!

And I totally understand the issue of beeing short in time - same here ;)

commented

cool ! linking with yii2-workflow should be easy as the only thing is being able to obtain a JSON representation of a workflow compatible with vis.js.

Regarding the "progress" like implementation do you mean a way to know what have been the statuses a model has been through ? If yes, I did some tests on a WorkflowBehaviorHistory component (what you call "progress" I called "history" ;) ) that would store in a table all statuses a model has been through. Nevertheless I'm interested in your vision of this "progress" ...

Hi,

I think your history is my progress! ;) So i have something like this already implemented within a table called events... linked to an action which is kind of

  • Action: StatusChanged
  • FromStatus: xyz
  • ToStatus: zyx
  • updated_by
  • updated_at

as I use the blamable behaviour and the timestampbehaviour;)

ok, I think i have the "wrapper" done... I need to make some samples, but I hope this could make it!

https://github.com/philippfrenzel/yii2visjs

let's see;)

And for the UserInterface I wannted to build something like here:

http://semantic-ui.com/elements/step.html

Ordered Steps...

And thinking about an implementation... Always the first element in the array which manages transitions should be the "shortest way" -> so fallbacks don't matter in visualisation...:)

commented

tis seems very promising ;)

... and the semantic UI is indeed good looking.

Hi,

I'm trying to set the workflow widget up, but i "fail" as
I wanna get the "getTransitions()"
"getWorkflowDefinition()"
the only thing that works is -> "getWorkflowStatus()"

$this->model->workflowStatus->getTransitions(); returns "EMPTY"...

commented

yes, this is something not implemented yet (sorry). In the meantime, another option is to use directly the workflowSource component.

For example the following should return an array containing all outgoing transitions for the model $this->model.

$this->model->getWorkflowSource()->getTransitions(
    $this->model->getWorkflowStatus()->getId()
);

hey, got a "version" staticaly up and running!

image

And I use the following code to get the possible workflow steps:

$stati = WorkflowHelper::getAllStatusListData(
            $this->model->getWorkflow()->getId(),
            $this->model->getWorkflowSource()
        );

$html.= <<<EOF
<div class="panel panel-default">
<div class="panel-heading">
    Workflow
</div>
EOF;

        $html .= "<ul class='nav nav-wizard'>";

        foreach($stati AS $key => $value)
        {
            $html .= Html::tag('li',$value,[
                'class'=> $this->model->getWorkflowStatus()->getId() == $key?'active':''
            ]);
        }

$html.= <<<EOF
</div>
commented

great ! ..
Is it going to be a yii2 widget ?

yes, that's the plan! But will work with your extension "only"!

btw. do I always need to define a ready statement?

commented

what do you mean by "ready statement" ?

inside the workflow source you'll ask for a ready status... I think it should be the last item without transistions?!

commented

I'm sorry I still don't understand to what you're refering to. If there indeed is an initial status (entry point into a workflow) there is no end status : a model can leave the workflow from any status.

Note that I'm currently refactoring the workflowSource component to make it more flexible and load workflow definition from any formatted file (Php class - the default - Php array, Graphml file - to be able to use an application like yEd to design a complex workflow).

Ok, Looking forward to see;) and today in the evening I find the time to explain in detail;) salut

commented

Hi,
I have release today a very basic widget to render a workflow made with yii2-workflow. The widget is using vis.js to handle display.

check yii2-workflow-view