Fix designer to insert new activities connected between Start and existing target

This commit is contained in:
Sipke Schoorstra 2021-03-09 14:08:16 +01:00
parent dee30999b4
commit 98798c8dfd

View file

@ -44,7 +44,10 @@ export class ElsaWorkflowDesigner {
eventBus.on(EventTypes.ActivityPicked, async args => {
const activityDescriptor = (args as ActivityDescriptor);
const activityModel = this.addActivity(activityDescriptor, this.parentActivityId, null, this.parentActivityOutcome);
const connectFromRoot = !this.parentActivityOutcome || this.parentActivityOutcome == "";
const sourceId = connectFromRoot ? null : this.parentActivityId;
const targetId = connectFromRoot ? this.parentActivityId : null;
const activityModel = this.addActivity(activityDescriptor, sourceId, targetId, this.parentActivityOutcome);
if (activityDescriptor.properties.length > 0)
this.showActivityEditor(activityModel, false);
@ -351,9 +354,7 @@ export class ElsaWorkflowDesigner {
};
workflowModel.connections = [...connections, newConnection];
}
else
{
} else {
// Create new connection.
const newConnection: ConnectionModel = {
sourceId: sourceActivityId,
@ -416,7 +417,7 @@ export class ElsaWorkflowDesigner {
return <li key={x.activityId}>
<div class="inline-flex flex flex-col items-center">
{isRoot ? this.renderOutcomeButton(`start-button-plus-${x.activityId}`, '', activityId, e => this.onOutcomeButtonClick(e, null, null)) : undefined}
{isRoot ? this.renderOutcomeButton(`start-button-plus-${x.activityId}`, '', activityId, e => this.onOutcomeButtonClick(e, null, activityId)) : undefined}
{this.renderActivity(displayContext)}
{this.renderOutcomeButtons(displayContext)}
</div>