Skip to content

Component Workflow engine

donvadicastro edited this page Oct 2, 2015 · 2 revisions

Form should support workflow configuration to move document through some sequential process. All form expressions should have access to current workflow state to be capable to change control visibility state based on current workflow state.

This configuration should describe steps which document should move through. Simple workflow example:

{
  workflow: {
    'first': { next: 'second' },
    'second': { previous: 'first', next: 'third' },
    'third': { previous: 'third' }
  }
}

Workflow step contains pointers to next and previous steps. If step do not have previous step in declaration - consider as the initial workflow step. If step do not have next step in declaration - consider as final step in sequential process. Form expression should support special variable - $workflowCurrentStep - as the name of workflow step when document currently stand.

Command engine should support special command - WorkflowMove - as the process of moving document to the next step in workflow sequence.

Workflow configuration should support SWITCH statement to move document to different steps based on data model state.

Workflow declaration with SWITCH statement example:

{
  workflow: {
    'first': { next: 'second' },
    'second': { previous: 'first', next: {  
      'first': condition,
      'third': condition
    } },
    'third': { previous: 'third' }
  }
}

where condition - regular data model condition with expressions only and optional operator. When WorkflowMove command executed - condition should be revaluated and document should be moved to the first step in sequence where condition was evaluated as true. To have default step to move when no others conditions meets requirements - use Boolean "true" value as condition expression at the end of declaration.

Workflow definition example with default step in SWITCH:

{  
  workflow: {
    'first': { next: 'second' },
    'second': { previous: 'first', next: {  
      'first': condition,
      'third': true
    } },
    'third': { previous: 'third' }
  }
}

Workflow engine should also send messages when state changes and form engine should support appropriate workflow events listening:

  • "workflow:start"
  • "workflow:finish"
  • "workflow:enter" (step)
  • "workflow:exit" (step)
  • "workflow:enter:stepName"
  • "workflow:exit:stepName"