storeWorkflow
Overview
A pinia store for current workflow states, available transitions, and workflow histories for objects or possible states for models.
Signature
storeWorkflow(pinia, hot)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| pinia | Pinia | no | Pinia instance to retrieve the store |
| hot | StoreGeneric | no | dev only hot module replacement |
Returns
Store
Examples
js
import { ref, unref, computed } from "vue";
import { storeWorkflowStore } from "@vueda";
import { useArrayFind } from "@vueuse/core";
const workflowStore = storeWorkflowStore();
workflowStore.objectStates; // array of objects with app, model, pk, and state
workflowStore.objectTransitions; // array of objects with app, model, pk, and transitions
workflowStore.objectHistories; // array of objects with app, model, pk, and history
workflowStore.modelStates; // object with keys of app.model and values of array of states
// examples of reactively looking at a particular object's state, transitions, and history
const myApp = ref("myApp"); // reactive will work
const myModel = ref("myModel"); // reactive will work
const objectPk = ref("myObjectPk"); // reactive will work
const objectState = useArrayFind(workflowStore.objectStates, (state) => state.app === myApp && state.model === myModel && state.pk === objectPk);
const objectTransitions = useArrayFind(workflowStore.objectTransitions, (transition) => transition.app === myApp && transition.model === myModel && transition.pk === objectPk);
const objectHistory = useArrayFind(workflowStore.objectHistories, (history) => history.app === myApp && history.model === myModel && history.pk === objectPk);
const modelStates = computed(() => workflowStore.modelStates[`${unref(myApp)}.${unref(myModel)}`]);
await workflowStore.fetchModelStates(app, model);
await workflowStore.fetchObjectState(app, model, objectPk);
await workflowStore.fetchObjectTransitions(app, model, objectPk);
await workflowStore.fetchObjectHistory(app, model, objectPk);
await workflowStore.executeTransition(app, model, objectPk, transition_code);Properties
$id
Id of the store. Used by map helpers.
Type: "workflow"
Source: node_modules/.pnpm/pinia@3.0.4_typescript@5.9.3_vue@3.5.27_typescript@5.9.3_/node_modules/pinia/dist/pinia.d.ts:654
Source
client/lib/stores/storeWorkflow.js:279