Didn't completely work, as it was basing whether something was new on the currently selected spec, better to just check if it is new.
This commit is contained in:
parent
6f023a4ac3
commit
2585201e8a
|
@ -118,7 +118,7 @@ export class WorkflowSpecListComponent implements OnInit {
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe((data: WorkflowSpecDialogData) => {
|
dialogRef.afterClosed().subscribe((data: WorkflowSpecDialogData) => {
|
||||||
if (data && data.id && data.name && data.display_name && data.description) {
|
if (data && data.id && data.name && data.display_name && data.description) {
|
||||||
this._upsertWorkflowSpecification(data);
|
this._upsertWorkflowSpecification(selectedSpec == null, data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -245,12 +245,9 @@ export class WorkflowSpecListComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _upsertWorkflowSpecification(data: WorkflowSpecDialogData) {
|
private _upsertWorkflowSpecification(isNew: boolean, data: WorkflowSpecDialogData) {
|
||||||
if (data.id && data.name && data.display_name && data.description) {
|
if (data.id && data.name && data.display_name && data.description) {
|
||||||
|
|
||||||
// Save old workflow spec id, in case it's changed
|
|
||||||
const specId = this.selectedSpec ? this.selectedSpec.id : undefined;
|
|
||||||
|
|
||||||
const newSpec: WorkflowSpec = {
|
const newSpec: WorkflowSpec = {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
|
@ -260,10 +257,10 @@ export class WorkflowSpecListComponent implements OnInit {
|
||||||
display_order: data.display_order,
|
display_order: data.display_order,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (specId) {
|
if (isNew) {
|
||||||
this._updateWorkflowSpec(specId, newSpec);
|
|
||||||
} else {
|
|
||||||
this._addWorkflowSpec(newSpec);
|
this._addWorkflowSpec(newSpec);
|
||||||
|
} else {
|
||||||
|
this._updateWorkflowSpec(data.id, newSpec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue