diff --git a/src/app/_dialogs/workflow-spec-dialog/workflow-spec-dialog.component.ts b/src/app/_dialogs/workflow-spec-dialog/workflow-spec-dialog.component.ts index 5866dab..1369002 100644 --- a/src/app/_dialogs/workflow-spec-dialog/workflow-spec-dialog.component.ts +++ b/src/app/_dialogs/workflow-spec-dialog/workflow-spec-dialog.component.ts @@ -33,8 +33,8 @@ export class WorkflowSpecDialogComponent { label: c.display_name, })); - this.api.getWorkflowSpecList().subscribe(wfs => { - this.specs = wfs.map(w => w.id); + this.api.getWorkflowSpecList().subscribe(wfs => { + this.specs = wfs.map(w => w.id); this.fields = [ { diff --git a/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts b/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts index eee089a..2f7d54b 100644 --- a/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts +++ b/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts @@ -283,6 +283,7 @@ describe('WorkflowSpecListComponent', () => { const _updateWorkflowSpecCategorySpy = spyOn((component as any), '_updateWorkflowSpecCategory').and.stub(); component.selectedCat = undefined; + mockWorkflowSpecCategory1.id = null; (component as any)._upsertWorkflowSpecCategory(mockWorkflowSpecCategory1 as WorkflowSpecCategoryDialogData); expect(_addWorkflowSpecCategorySpy).toHaveBeenCalled(); expect(_updateWorkflowSpecCategorySpy).not.toHaveBeenCalled(); diff --git a/src/app/workflow-spec-list/workflow-spec-list.component.ts b/src/app/workflow-spec-list/workflow-spec-list.component.ts index 0a13054..36548a5 100644 --- a/src/app/workflow-spec-list/workflow-spec-list.component.ts +++ b/src/app/workflow-spec-list/workflow-spec-list.component.ts @@ -32,7 +32,7 @@ import { SettingsService } from '../settings.service'; export interface WorkflowSpecCategoryGroup { - id: number; + id?: number; display_name: string; workflow_specs?: WorkflowSpec[]; display_order: number; @@ -173,7 +173,7 @@ export class WorkflowSpecListComponent implements OnInit { }, }); dialogRef.afterClosed().subscribe((data: WorkflowSpecCategoryDialogData) => { - if (data && isNumberDefined(data.id) && data.display_name) { + if (data && data.display_name) { this._upsertWorkflowSpecCategory(data); } }); @@ -329,21 +329,21 @@ export class WorkflowSpecListComponent implements OnInit { } private _upsertWorkflowSpecCategory(data: WorkflowSpecCategoryDialogData) { - if (isNumberDefined(data.id) && data.display_name) { - - // Save old workflow spec id, in case it's changed - const catId = this.selectedCat ? this.selectedCat.id : undefined; - - const newCat: WorkflowSpecCategory = { - id: data.id, - display_name: data.display_name, - display_order: data.display_order, - admin: data.admin, + if (data.display_name) { + if (isNumberDefined(data.id)) { + const newCat: WorkflowSpecCategory = { + id: data.id, + display_name: data.display_name, + display_order: data.display_order, + admin: data.admin, }; - - if (isNumberDefined(catId)) { - this._updateWorkflowSpecCategory(catId, newCat); + this._updateWorkflowSpecCategory(data.id, newCat); } else { + const newCat: WorkflowSpecCategory = { + display_name: data.display_name, + display_order: data.display_order, + admin: data.admin, + }; this._addWorkflowSpecCategory(newCat); } }