OpusCapita / fsm-workflow

FSM workflow (for Node.js)
https://demo.core.dev.opuscapita.com/fsm-workflow/master
Apache License 2.0
28 stars 3 forks source link

Introduce state 'release' guards (editor) #91

Closed asergeev-sc closed 5 years ago

asergeev-sc commented 5 years ago
Meta-Info Value
ExtProjectId JCINV-01
Original Estimation 12h
Remaining Estimation 12h

We need to add "release" guards support into the editor (see new enhancements issue #90).

An editor UI should provide the possibility to define state release guards. This Ui should be supported by an additional configuration that optionally could be passed to the editor from the outside that defines which kind of target states could be defined at all:

  stateReleaseGuards {
    toState: none/single/multiple (default)
  }
}

depending on the configuration release guards UI should allow:

estambakio-sc commented 5 years ago

QA

How it works

Release guards are conditions defined in schema per state like this:

states: [
  {
    name: "inspectionRequired",
    release: [
      {
        to: string|array<string> // optional
        guards: [
          // same as in transitions
        ]
      }
    ]
  }
]

There's a property in Editor's component:

schemaConfig = {
    state: {
      releaseGuards: {
        toState: 'single' // all, single, multiple (default)
      },
    }
  }

toState is optional. If not defined then the default value is multiple.

Cases

toState = all

It means release[i].to is empty because guards are relevant for any target state. In this case, pressing Guards button in States editor page shows editor for a list of guards just like on Transitions page. If guards are added/edited/deleted here, they appear in the schema in release property of the corresponding state without to field.

toState = single

It means release[i].to can be either a single string (name of a target state) or empty. In this case, pressing Guards button in States editor page shows editor for a list of release guards. Input for To value allows to pick a single name or make it empty. On the right side, there's Guards button which opens the same editor for a list of guards as mentioned in the previous case.

A list of options can come from 2 places:

toState = multiple (default)

The same as above, but to can also be an array. Input for To allows multiple selections. If only one name is selected then it's saved in a schema as a single string for to; otherwise, an array is saved.

A list of options can come from 2 places:

estambakio-sc commented 5 years ago

i18n

Two new messages need to be translated into all supported languages (de, sv, fi, no, ru): states.releaseGuards block.

Where these messages are used on UI:

fsm-release-guards-i18n

In code: https://github.com/OpusCapita/fsm-workflow/blob/issue-91/packages/editor/src/i18n/en.js#L46 (example for en)

nstoliar-sc commented 5 years ago

Tested. Guards are added correctly. Alerts about existing changes appear correctly while closing pop-ups. Please, merge with master branch.