diff --git a/src/designer/elsa-workflows-studio/package.json b/src/designer/elsa-workflows-studio/package.json index 5361bb834..482a07f9c 100644 --- a/src/designer/elsa-workflows-studio/package.json +++ b/src/designer/elsa-workflows-studio/package.json @@ -1,6 +1,6 @@ { "name": "@elsa-workflows/elsa-workflows-studio", - "version": "2.1.2", + "version": "2.1.3", "description": "Elsa Workflow Studio is a collection of web components to manage Elsa workflows stored on an Elsa Workflows server.", "repository": { "type": "git", diff --git a/src/designer/elsa-workflows-studio/src/components/designers/tree/elsa-designer-tree/elsa-designer-tree.tsx b/src/designer/elsa-workflows-studio/src/components/designers/tree/elsa-designer-tree/elsa-designer-tree.tsx index e9c1c15a5..fe097ce09 100644 --- a/src/designer/elsa-workflows-studio/src/components/designers/tree/elsa-designer-tree/elsa-designer-tree.tsx +++ b/src/designer/elsa-workflows-studio/src/components/designers/tree/elsa-designer-tree/elsa-designer-tree.tsx @@ -130,6 +130,7 @@ export class ElsaWorkflowDesigner { const displayContext: ActivityDesignDisplayContext = { activityModel: model, + activityDescriptor: descriptor, activityIcon: , bodyDisplay: bodyDisplay, displayName: displayName, diff --git a/src/designer/elsa-workflows-studio/src/models/events.ts b/src/designer/elsa-workflows-studio/src/models/events.ts index 250f8a978..6c81933ad 100644 --- a/src/designer/elsa-workflows-studio/src/models/events.ts +++ b/src/designer/elsa-workflows-studio/src/models/events.ts @@ -28,6 +28,7 @@ export interface ActivityPickedEventArgs { export interface ActivityDesignDisplayContext { activityModel: ActivityModel; + activityDescriptor: ActivityDescriptor; activityIcon: any; displayName?: string; bodyDisplay: string; diff --git a/src/designer/elsa-workflows-studio/src/plugins/switch-plugin.tsx b/src/designer/elsa-workflows-studio/src/plugins/switch-plugin.tsx index 65a55fdee..504853eff 100644 --- a/src/designer/elsa-workflows-studio/src/plugins/switch-plugin.tsx +++ b/src/designer/elsa-workflows-studio/src/plugins/switch-plugin.tsx @@ -12,15 +12,28 @@ export class SwitchPlugin implements ElsaPlugin { onActivityDesignDisplaying(context: ActivityDesignDisplayContext) { const activityModel = context.activityModel; + const activityDescriptor = context.activityDescriptor; + const propertyDescriptors = activityDescriptor.inputProperties; + const switchCaseProperties = propertyDescriptors.filter(x => x.uiHint == 'switch-case-builder'); - if (activityModel.type !== 'Switch') + if (switchCaseProperties.length == 0) return; - - const props = activityModel.properties || []; + + let outcomesHash: any = {}; const syntax = 'Switch'; - const casesProp = props.find(x => x.name == 'Cases') || { expressions: {'Switch': ''}, syntax: syntax }; - const expression: any = casesProp.expressions[syntax] || []; - const cases: Array = !!expression['$values'] ? expression['$values'] : Array.isArray(expression) ? expression : parseJson(expression) || []; - context.outcomes = [...cases.map(x => x.name), 'Default']; + + for (const propertyDescriptor of switchCaseProperties) { + const props = activityModel.properties || []; + const casesProp = props.find(x => x.name == propertyDescriptor.name) || {expressions: {'Switch': ''}, syntax: syntax}; + + const expression: any = casesProp.expressions[syntax] || []; + const cases: Array = !!expression['$values'] ? expression['$values'] : Array.isArray(expression) ? expression : parseJson(expression) || []; + + for(const c of cases) + outcomesHash[c.name] = true; + } + + const outcomes = Object.keys(outcomesHash); + context.outcomes = [...outcomes, 'Default']; } } diff --git a/src/samples/server/Elsa.Samples.Server.Host/appsettings.json b/src/samples/server/Elsa.Samples.Server.Host/appsettings.json index 476ea05df..13494783d 100644 --- a/src/samples/server/Elsa.Samples.Server.Host/appsettings.json +++ b/src/samples/server/Elsa.Samples.Server.Host/appsettings.json @@ -13,7 +13,7 @@ "Redis": "localhost:6379,abortConnect=false", "MySql": "Server=LAPTOP-B76STK67;Database=Elsa;Uid=myUsername;Pwd=myPassword;", "SqlServer": "Server=LAPTOP-B76STK67;Database=Elsa;Integrated Security=true;MultipleActiveResultSets=True;Max Pool Size=500;Connection Timeout=3600", - "Sqlite": "Data Source=elsa.sqlite.yes.db;Cache=Shared;", + "Sqlite": "Data Source=elsa.sqlite.db;Cache=Shared;", "MongoDb": "mongodb://localhost:27017/Elsa", "PostgreSql": "Server=127.0.0.1;Port=5432;Database=elsa;User Id=postgres;Password=password;" },