From 7548211c816af70f6c5dfe92897f82527de3986d Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 6 Dec 2023 23:28:38 -0500 Subject: final simplification of info ui fsa structure --- .../CollectionFreeFormInfoUI.tsx | 77 ++++++++-------------- 1 file changed, 29 insertions(+), 48 deletions(-) (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx index dfe77482f..74b5545bd 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx @@ -25,73 +25,54 @@ export class CollectionFreeFormInfoUI extends React.Component this.props.Freeform.childDocs.slice(), - actions: (docs: Doc[]) => { - if (docs.length === 1) this.currState = this.state1; - if (docs.length > 1) this.currState = this.state2; - }, - }, - ], + Events: () => this.props.Freeform.childDocs, + Actions: (docs: Doc[]) => { + if (docs.length === 1) this.currState = this.state1; + if (docs.length > 1) this.currState = this.state2; + }, }; state1: infoState = { Message: 'Create a second doc', - Arcs: [ - { - events: () => this.props.Freeform.childDocs.slice(), - actions: (docs: Doc[]) => { - if (docs.length === 0) this.currState = this.state0; - if (docs.length === 2) this.currState = this.state2; - }, - }, - ], + Events: () => this.props.Freeform.childDocs, + Actions: (docs: Doc[]) => { + if (docs.length === 0) this.currState = this.start; + if (docs.length === 2) this.currState = this.state2; + }, }; state2: infoState = { Message: 'Create a link', - Arcs: [ - { - events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), docs: this.props.Freeform.childDocs.slice() }), - actions: arc => { - const { links, docs } = arc; - if (docs.length === 0) this.currState = this.state0; - if (docs.length === 1) this.currState = this.state1; - if (links?.length) this.currState = this.state3; - }, - }, - ], + Events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), docs: this.props.Freeform.childDocs.slice() }), + Actions: arc => { + const { links, docs } = arc; + if (docs.length === 0) this.currState = this.start; + if (docs.length === 1) this.currState = this.state1; + if (links?.length) this.currState = this.state3; + }, }; state3: infoState = { Message: 'View links', - Arcs: [ - { - events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), viewingLinks: DocumentLinksButton.LinkEditorDocView }), - actions: arc => { - const { links, viewingLinks } = arc; - if (viewingLinks) this.currState = this.state4; - if (links?.length === 0) this.currState = this.state2; - }, - }, - ], + Events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), viewingLinks: DocumentLinksButton.LinkEditorDocView }), + Actions: arc => { + const { links, viewingLinks } = arc; + if (viewingLinks) this.currState = this.state4; + if (links?.length === 0) this.currState = this.state2; + }, }; state4: infoState = { Message: 'You did it!', - Arcs: [ - { - events: () => false, - actions: arc => {}, - }, - ], + Events: () => false, + Actions: arc => {}, }; /* -- cgit v1.2.3-70-g09d2