diff --git a/src/designer/elsa-workflows-studio/src/components.d.ts b/src/designer/elsa-workflows-studio/src/components.d.ts index 920448d19..8752c3122 100644 --- a/src/designer/elsa-workflows-studio/src/components.d.ts +++ b/src/designer/elsa-workflows-studio/src/components.d.ts @@ -75,6 +75,7 @@ export namespace Components { "editorHeight": string; "propertyDescriptor": ActivityPropertyDescriptor; "propertyModel": ActivityDefinitionProperty; + "showLabel": boolean; "singleLineMode": boolean; } interface ElsaScriptProperty { @@ -330,9 +331,10 @@ declare namespace LocalJSX { interface ElsaPropertyEditor { "context"?: string; "editorHeight"?: string; - "onLiteralValueChanged"?: (event: CustomEvent) => void; + "onDefaultSyntaxValueChanged"?: (event: CustomEvent) => void; "propertyDescriptor"?: ActivityPropertyDescriptor; "propertyModel"?: ActivityDefinitionProperty; + "showLabel"?: boolean; "singleLineMode"?: boolean; } interface ElsaScriptProperty { diff --git a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-check-list-property/elsa-check-list-property.tsx b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-check-list-property/elsa-check-list-property.tsx index 737711b14..526c2b484 100644 --- a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-check-list-property/elsa-check-list-property.tsx +++ b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-check-list-property/elsa-check-list-property.tsx @@ -1,5 +1,5 @@ import {Component, h, Prop, State} from '@stencil/core'; -import {ActivityDefinitionProperty, ActivityPropertyDescriptor} from "../../../../models"; +import {ActivityDefinitionProperty, ActivityPropertyDescriptor, SyntaxNames} from "../../../../models"; import {parseJson} from "../../../../utils/utils"; @Component({ @@ -11,42 +11,45 @@ export class ElsaCheckListProperty { @Prop() propertyDescriptor: ActivityPropertyDescriptor; @Prop() propertyModel: ActivityDefinitionProperty; - @State() currentValues?: Array + @State() currentValue?: string; monacoEditor: HTMLElsaMonacoElement; async componentWillLoad() { - const expression = this.propertyModel.expressions['Literal'] || '[]'; - this.currentValues = parseJson(expression) ?? []; + this.currentValue = this.propertyModel.expressions[SyntaxNames.Json] || '[]'; } onCheckChanged(e: Event) { const checkbox = (e.target as HTMLInputElement); const checked = checkbox.checked; const value = checkbox.value; + let newValue = parseJson(this.currentValue); if(checked) - this.currentValues = [...this.currentValues, value].distinct(); + newValue = [...newValue, value].distinct(); else - this.currentValues = this.currentValues.filter(x => x !== value); + newValue = newValue.filter(x => x !== value); + + this.currentValue = JSON.stringify(newValue); + this.propertyModel.expressions[SyntaxNames.Json] = this.currentValue; + } + + onDefaultSyntaxValueChanged(e: CustomEvent) { + this.currentValue = e.detail; } render() { const propertyDescriptor = this.propertyDescriptor; - const propertyName = propertyDescriptor.name; - const fieldId = propertyName; - const fieldName = propertyName; - const fieldLabel = propertyDescriptor.label || propertyName; - const fieldHint = propertyDescriptor.hint; + const propertyModel = this.propertyModel; + const fieldId = propertyDescriptor.name; const options = propertyDescriptor.options as Array; - const values = this.currentValues.map(x => x ? x.trim() : '').filter(x => x.length > 0); - const valuesJson = JSON.stringify(values); + const values = parseJson(this.currentValue) || []; return ( -
- - + this.onDefaultSyntaxValueChanged(e)} + editor-height="2.75em" + single-line={true}>
{options.map((option, index) => { const inputId = `${fieldId}_${index}`; @@ -64,10 +67,7 @@ export class ElsaCheckListProperty { ); })}
- - {fieldHint ?

{fieldHint}

: undefined} - -
- ) + + ); } } diff --git a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-checkbox-property/elsa-checkbox-property.tsx b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-checkbox-property/elsa-checkbox-property.tsx index a832f8c7a..d76fa29fb 100644 --- a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-checkbox-property/elsa-checkbox-property.tsx +++ b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-checkbox-property/elsa-checkbox-property.tsx @@ -1,5 +1,5 @@ import {Component, h, Prop, State} from '@stencil/core'; -import {ActivityDefinitionProperty, ActivityPropertyDescriptor} from "../../../../models"; +import {ActivityDefinitionProperty, ActivityPropertyDescriptor, SyntaxNames} from "../../../../models"; @Component({ tag: 'elsa-checkbox-property', @@ -11,29 +11,39 @@ export class ElsaCheckBoxProperty { @Prop() propertyDescriptor: ActivityPropertyDescriptor; @Prop() propertyModel: ActivityDefinitionProperty; @State() isChecked: boolean - monacoEditor: HTMLElsaMonacoElement; async componentWillLoad() { - this.isChecked = (this.propertyModel.expressions['Literal'] || '').toLowerCase() == 'true'; + this.isChecked = (this.propertyModel.expressions[SyntaxNames.Literal] || '').toLowerCase() == 'true'; } onCheckChanged(e: Event) { const checkbox = (e.target as HTMLInputElement); this.isChecked = checkbox.checked; + const defaultSyntax = this.propertyDescriptor.defaultSyntax || SyntaxNames.Literal; + this.propertyModel.expressions[defaultSyntax] = this.isChecked.toString(); + } + + onDefaultSyntaxValueChanged(e: CustomEvent) { + this.isChecked = (e.detail || '').toLowerCase() == 'true'; } render() { const propertyDescriptor = this.propertyDescriptor; + const propertyModel = this.propertyModel; const propertyName = propertyDescriptor.name; const fieldId = propertyName; const fieldName = propertyName; const fieldLabel = propertyDescriptor.label || propertyName; - const fieldHint = propertyDescriptor.hint; const isChecked = this.isChecked; return ( -
-
+ this.onDefaultSyntaxValueChanged(e)} + editor-height="2.75em" + single-line={true} + showLabel={false}> +
this.onCheckChanged(e)} class="focus:ring-blue-500 h-4 w-4 text-blue-600 border-gray-300 rounded"/> @@ -43,9 +53,7 @@ export class ElsaCheckBoxProperty {
- - {fieldHint ?

{fieldHint}

: undefined} -
+ ) } } diff --git a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-dropdown-property/elsa-dropdown-property.tsx b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-dropdown-property/elsa-dropdown-property.tsx index 3a4b7b838..1d5160971 100644 --- a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-dropdown-property/elsa-dropdown-property.tsx +++ b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-dropdown-property/elsa-dropdown-property.tsx @@ -1,5 +1,5 @@ import {Component, h, Prop, State} from '@stencil/core'; -import {ActivityDefinitionProperty, ActivityPropertyDescriptor} from "../../../../models"; +import {ActivityDefinitionProperty, ActivityPropertyDescriptor, SyntaxNames} from "../../../../models"; @Component({ tag: 'elsa-dropdown-property', @@ -13,40 +13,43 @@ export class ElsaDropdownProperty { @State() currentValue?: string; async componentWillLoad() { - this.currentValue = this.propertyModel.expressions['Literal'] || ''; + const defaultSyntax = this.propertyDescriptor.defaultSyntax || SyntaxNames.Literal; + this.currentValue = this.propertyModel.expressions[defaultSyntax] || ''; } - onChanged(e: Event) { + onChange(e: Event) { const select = (e.target as HTMLSelectElement); - this.currentValue = select.value; + const defaultSyntax = this.propertyDescriptor.defaultSyntax || SyntaxNames.Literal; + this.propertyModel.expressions[defaultSyntax] = this.currentValue = select.value; + } + + onDefaultSyntaxValueChanged(e: CustomEvent) { + this.currentValue = e.detail; } render() { const propertyDescriptor = this.propertyDescriptor; + const propertyModel = this.propertyModel; const propertyName = propertyDescriptor.name; const fieldId = propertyName; const fieldName = propertyName; - const fieldLabel = propertyDescriptor.label || propertyName; - const fieldHint = propertyDescriptor.hint; const options = propertyDescriptor.options as Array || []; const currentValue = this.currentValue; return ( -
- - - this.onChange(e)} class="mt-1 block focus:ring-blue-500 focus:border-blue-500 w-full shadow-sm sm:max-w-xs sm:text-sm border-gray-300 rounded-md"> {options.map(option => { const value = option.value || option; const text = option.text || option; return ; })} - - {fieldHint ?

{fieldHint}

: undefined} -
- ) + + ); } } diff --git a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-multi-line-property/elsa-multi-line-property.tsx b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-multi-line-property/elsa-multi-line-property.tsx index db31d8df0..1916a8f52 100644 --- a/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-multi-line-property/elsa-multi-line-property.tsx +++ b/src/designer/elsa-workflows-studio/src/components/editors/properties/elsa-multi-line-property/elsa-multi-line-property.tsx @@ -29,7 +29,7 @@ export class ElsaMultiLineProperty { this.propertyModel.expressions['Literal'] = this.currentValue = input.value; } - onLiteralValueChanged(e: CustomEvent) { + onDefaultSyntaxValueChanged(e: CustomEvent) { this.currentValue = e.detail; } @@ -52,7 +52,7 @@ export class ElsaMultiLineProperty { return ( this.onLiteralValueChanged(e)} + onDefaultSyntaxValueChanged={e => this.onDefaultSyntaxValueChanged(e)} editor-height={editorHeight.propertyEditor} context={context}>