aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-12-06 22:29:26 -0500
committerbobzel <zzzman@gmail.com>2023-12-06 22:29:26 -0500
commitdd1d3d84df28e24c51be9fd8b367b1fcf5141dd5 (patch)
tree21cc42c79abdd5e9a11c55db5044ebe5778b9f4c /src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
parent75915bfb1699959c9684a19d93389f8a9cb4518a (diff)
created basic state machine for info ui.
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx76
1 files changed, 75 insertions, 1 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
index 09df4bfab..0e62bc388 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx
@@ -12,6 +12,7 @@ import { InkTool } from '../../../../fields/InkField';
import { LinkDocPreview } from '../../nodes/LinkDocPreview';
import { DocumentLinksButton } from '../../nodes/DocumentLinksButton';
import { DocumentManager } from '../../../util/DocumentManager';
+import { CollectionFreeFormInfoState, infoState } from './CollectionFreeFormInfoState';
export interface CollectionFreeFormInfoUIProps {
Document: Doc;
@@ -22,6 +23,78 @@ export interface CollectionFreeFormInfoUIProps {
export class CollectionFreeFormInfoUI extends React.Component<CollectionFreeFormInfoUIProps> {
private _disposers: { [name: string]: IReactionDisposer } = {};
+ constructor(props: any) {
+ super(props);
+ this.currState = this.state0;
+ }
+
+ @computed get first_doc() {
+ return this.props.Freeform.childDocs.lastElement();
+ }
+ @observable currState: infoState;
+ state0: infoState = {
+ Message: 'Click to create Object',
+ Arcs: [
+ {
+ events: () => this.props.Freeform.childDocs.slice(),
+ 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;
+ },
+ },
+ ],
+ };
+ 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;
+ },
+ },
+ ],
+ };
+
+ 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;
+ },
+ },
+ ],
+ };
+ state4: infoState = {
+ Message: 'You did it!',
+ Arcs: [
+ {
+ events: () => false,
+ actions: arc => {},
+ },
+ ],
+ };
+
+ /*
componentDidMount(): void {
this._disposers.reaction1 = reaction(
() => this.props.Freeform.childDocs.slice(),
@@ -110,9 +183,10 @@ export class CollectionFreeFormInfoUI extends React.Component<CollectionFreeForm
@observable message = 'Click anywhere and begin typing to create your first document!';
@observable firstDoc: Doc | undefined;
@observable secondDoc: Doc | undefined;
+ */
firstDocPos = { x: 0, y: 0 };
render() {
- return <div className="infoUI">{this.message}</div>;
+ return <CollectionFreeFormInfoState state={this.currState} />;
}
}