From e09daf97c3bf566b66684e3a506cd616035e43de Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sat, 4 Jun 2022 23:08:46 +0200 Subject: [PATCH] Incremental work on variable editor --- .../src/components.d.ts | 22 ++++++++- .../variable-editor-dialog.tsx | 44 ++++++++++++++++++ .../variables-editor/variables-editor.tsx | 46 +++++++++++++------ .../workflow-definition-browser.tsx | 1 + .../src/models/core.ts | 1 + 5 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 src/designer/elsa-workflows-designer/src/components/designer/variables-editor/variable-editor-dialog.tsx diff --git a/src/designer/elsa-workflows-designer/src/components.d.ts b/src/designer/elsa-workflows-designer/src/components.d.ts index 81779a91d..ca4ee9fc1 100644 --- a/src/designer/elsa-workflows-designer/src/components.d.ts +++ b/src/designer/elsa-workflows-designer/src/components.d.ts @@ -5,7 +5,7 @@ * It contains typing information for all components that exist in this project. */ import { HTMLStencilElement, JSXBase } from "@stencil/core/internal"; -import { ActionDefinition, ActionInvokedArgs, Activity, ActivityDescriptor, ActivitySelectedArgs, ContainerSelectedArgs, GraphUpdatedArgs, IntellisenseContext, SelectListItem, TabChangedArgs, TabDefinition, WorkflowDefinition, WorkflowDefinitionSummary, WorkflowInstance, WorkflowInstanceSummary } from "./models"; +import { ActionDefinition, ActionInvokedArgs, Activity, ActivityDescriptor, ActivitySelectedArgs, ContainerSelectedArgs, GraphUpdatedArgs, IntellisenseContext, SelectListItem, TabChangedArgs, TabDefinition, Variable, WorkflowDefinition, WorkflowDefinitionSummary, WorkflowInstance, WorkflowInstanceSummary } from "./models"; import { ActivityUpdatedArgs, DeleteActivityRequestedArgs } from "./components/designer/workflow-definition-editor/activity-properties-editor"; import { Button } from "./components/shared/button-group/models"; import { ContainerActivityComponent } from "./components/activities/container-activity-component"; @@ -184,7 +184,13 @@ export namespace Components { "tooltipContent": any; "tooltipPosition"?: string; } + interface ElsaVariableEditorDialog { + "hide": () => Promise; + "show": () => Promise; + "variable": Variable; + } interface ElsaVariablesEditor { + "variables": Array; } interface ElsaWorkflowDefinitionBrowser { "hide": () => Promise; @@ -443,6 +449,12 @@ declare global { prototype: HTMLElsaTooltipElement; new (): HTMLElsaTooltipElement; }; + interface HTMLElsaVariableEditorDialogElement extends Components.ElsaVariableEditorDialog, HTMLStencilElement { + } + var HTMLElsaVariableEditorDialogElement: { + prototype: HTMLElsaVariableEditorDialogElement; + new (): HTMLElsaVariableEditorDialogElement; + }; interface HTMLElsaVariablesEditorElement extends Components.ElsaVariablesEditor, HTMLStencilElement { } var HTMLElsaVariablesEditorElement: { @@ -559,6 +571,7 @@ declare global { "elsa-studio": HTMLElsaStudioElement; "elsa-switch-editor": HTMLElsaSwitchEditorElement; "elsa-tooltip": HTMLElsaTooltipElement; + "elsa-variable-editor-dialog": HTMLElsaVariableEditorDialogElement; "elsa-variables-editor": HTMLElsaVariablesEditorElement; "elsa-workflow-definition-browser": HTMLElsaWorkflowDefinitionBrowserElement; "elsa-workflow-definition-editor": HTMLElsaWorkflowDefinitionEditorElement; @@ -737,7 +750,12 @@ declare namespace LocalJSX { "tooltipContent"?: any; "tooltipPosition"?: string; } + interface ElsaVariableEditorDialog { + "variable"?: Variable; + } interface ElsaVariablesEditor { + "onVariablesChanged"?: (event: CustomEvent>) => void; + "variables"?: Array; } interface ElsaWorkflowDefinitionBrowser { "onWorkflowDefinitionSelected"?: (event: CustomEvent) => void; @@ -825,6 +843,7 @@ declare namespace LocalJSX { "elsa-studio": ElsaStudio; "elsa-switch-editor": ElsaSwitchEditor; "elsa-tooltip": ElsaTooltip; + "elsa-variable-editor-dialog": ElsaVariableEditorDialog; "elsa-variables-editor": ElsaVariablesEditor; "elsa-workflow-definition-browser": ElsaWorkflowDefinitionBrowser; "elsa-workflow-definition-editor": ElsaWorkflowDefinitionEditor; @@ -876,6 +895,7 @@ declare module "@stencil/core" { "elsa-studio": LocalJSX.ElsaStudio & JSXBase.HTMLAttributes; "elsa-switch-editor": LocalJSX.ElsaSwitchEditor & JSXBase.HTMLAttributes; "elsa-tooltip": LocalJSX.ElsaTooltip & JSXBase.HTMLAttributes; + "elsa-variable-editor-dialog": LocalJSX.ElsaVariableEditorDialog & JSXBase.HTMLAttributes; "elsa-variables-editor": LocalJSX.ElsaVariablesEditor & JSXBase.HTMLAttributes; "elsa-workflow-definition-browser": LocalJSX.ElsaWorkflowDefinitionBrowser & JSXBase.HTMLAttributes; "elsa-workflow-definition-editor": LocalJSX.ElsaWorkflowDefinitionEditor & JSXBase.HTMLAttributes; diff --git a/src/designer/elsa-workflows-designer/src/components/designer/variables-editor/variable-editor-dialog.tsx b/src/designer/elsa-workflows-designer/src/components/designer/variables-editor/variable-editor-dialog.tsx new file mode 100644 index 000000000..91ce7ddb6 --- /dev/null +++ b/src/designer/elsa-workflows-designer/src/components/designer/variables-editor/variable-editor-dialog.tsx @@ -0,0 +1,44 @@ +import {Component, h, Prop, Event, EventEmitter, Method} from "@stencil/core"; +import {DeleteIcon, EditIcon, PublishIcon, UnPublishIcon} from "../../icons/tooling"; +import {DefaultActions, Variable, WorkflowDefinitionSummary} from "../../../models"; +import {Filter} from "../../modals/workflow-definition-browser/filter"; + +@Component({ + tag: 'elsa-variable-editor-dialog', + shadow: false +}) +export class VariableEditorDialog { + private modalDialog: HTMLElsaModalDialogElement; + + @Prop() variable: Variable; + + @Method() + public async show() { + await this.modalDialog.show(); + } + + @Method() + public async hide() { + await this.modalDialog.hide(); + } + + render() { + const variable: Variable = this.variable ?? {name: '', type: ''}; + const closeAction = DefaultActions.Close(); + const actions = [closeAction]; + + return ( +
+ (this.modalDialog = el)} actions={actions}> +
+

Edit Variable

+
+ +
+
+
+
+ ); + } + +} diff --git a/src/designer/elsa-workflows-designer/src/components/designer/variables-editor/variables-editor.tsx b/src/designer/elsa-workflows-designer/src/components/designer/variables-editor/variables-editor.tsx index 22f608dc7..6068b6dd3 100644 --- a/src/designer/elsa-workflows-designer/src/components/designer/variables-editor/variables-editor.tsx +++ b/src/designer/elsa-workflows-designer/src/components/designer/variables-editor/variables-editor.tsx @@ -1,16 +1,23 @@ -import {Component, h} from "@stencil/core"; +import {Component, h, Prop, Event, EventEmitter} from "@stencil/core"; import {DeleteIcon, EditIcon} from "../../icons/tooling"; +import {Variable} from "../../../models"; @Component({ tag: 'elsa-variables-editor', shadow: false }) export class VariablesEditor { + private variableEditorDialog: HTMLElsaVariableEditorDialogElement; + @Prop() variables: Array = []; + @Event() variablesChanged: EventEmitter>; + render() { + const variables = this.variables; + return (
- +
@@ -23,26 +30,35 @@ export class VariablesEditor { - - - - - - + {variables.map(variable => { + return ( + + + + + + ); + } + )}
CurrentValueString - this.onEditClick(e), icon: }, - {text: 'Delete', clickHandler: e => this.onDeleteClick(e), icon: }, - ]} - /> -
{variable.name}{variable.type}{variable.defaultValue} + this.onEditClick(e), icon: }, + {text: 'Delete', clickHandler: e => this.onDeleteClick(e), icon: }, + ]} + /> +
+ this.variableEditorDialog = el} />
); } + private onAddVariableClick = async () => { + await this.variableEditorDialog.show(); + }; + private onEditClick = (e: Event) => { e.preventDefault(); }; diff --git a/src/designer/elsa-workflows-designer/src/components/modals/workflow-definition-browser/workflow-definition-browser.tsx b/src/designer/elsa-workflows-designer/src/components/modals/workflow-definition-browser/workflow-definition-browser.tsx index d0a77270c..196a96c58 100644 --- a/src/designer/elsa-workflows-designer/src/components/modals/workflow-definition-browser/workflow-definition-browser.tsx +++ b/src/designer/elsa-workflows-designer/src/components/modals/workflow-definition-browser/workflow-definition-browser.tsx @@ -31,6 +31,7 @@ export class WorkflowDefinitionBrowser { @State() private orderBy?: WorkflowDefinitionsOrderBy; @State() private labels?: string[]; @State() private selectAllChecked: boolean; + @Method() public async show() { await this.modalDialog.show(); diff --git a/src/designer/elsa-workflows-designer/src/models/core.ts b/src/designer/elsa-workflows-designer/src/models/core.ts index 54a6fe3b4..21b42be00 100644 --- a/src/designer/elsa-workflows-designer/src/models/core.ts +++ b/src/designer/elsa-workflows-designer/src/models/core.ts @@ -23,6 +23,7 @@ export interface Container extends Activity { export interface Variable { name: string; + type: string; defaultValue?: any; }