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:
Dan 2021-03-10 16:27:22 -05:00
parent 6f023a4ac3
commit 2585201e8a
1 changed files with 5 additions and 8 deletions

View File

@ -118,7 +118,7 @@ export class WorkflowSpecListComponent implements OnInit {
dialogRef.afterClosed().subscribe((data: WorkflowSpecDialogData) => {
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) {
// Save old workflow spec id, in case it's changed
const specId = this.selectedSpec ? this.selectedSpec.id : undefined;
const newSpec: WorkflowSpec = {
id: data.id,
name: data.name,
@ -260,10 +257,10 @@ export class WorkflowSpecListComponent implements OnInit {
display_order: data.display_order,
};
if (specId) {
this._updateWorkflowSpec(specId, newSpec);
} else {
if (isNew) {
this._addWorkflowSpec(newSpec);
} else {
this._updateWorkflowSpec(data.id, newSpec);
}
}
}