New categories don't got an ID to start with, we will assign it to them
This commit is contained in:
parent
392f3d7ef2
commit
95af509383
|
@ -283,6 +283,7 @@ describe('WorkflowSpecListComponent', () => {
|
||||||
const _updateWorkflowSpecCategorySpy = spyOn((component as any), '_updateWorkflowSpecCategory').and.stub();
|
const _updateWorkflowSpecCategorySpy = spyOn((component as any), '_updateWorkflowSpecCategory').and.stub();
|
||||||
|
|
||||||
component.selectedCat = undefined;
|
component.selectedCat = undefined;
|
||||||
|
mockWorkflowSpecCategory1.id = null;
|
||||||
(component as any)._upsertWorkflowSpecCategory(mockWorkflowSpecCategory1 as WorkflowSpecCategoryDialogData);
|
(component as any)._upsertWorkflowSpecCategory(mockWorkflowSpecCategory1 as WorkflowSpecCategoryDialogData);
|
||||||
expect(_addWorkflowSpecCategorySpy).toHaveBeenCalled();
|
expect(_addWorkflowSpecCategorySpy).toHaveBeenCalled();
|
||||||
expect(_updateWorkflowSpecCategorySpy).not.toHaveBeenCalled();
|
expect(_updateWorkflowSpecCategorySpy).not.toHaveBeenCalled();
|
||||||
|
|
|
@ -32,7 +32,7 @@ import { SettingsService } from '../settings.service';
|
||||||
|
|
||||||
|
|
||||||
export interface WorkflowSpecCategoryGroup {
|
export interface WorkflowSpecCategoryGroup {
|
||||||
id: number;
|
id?: number;
|
||||||
display_name: string;
|
display_name: string;
|
||||||
workflow_specs?: WorkflowSpec[];
|
workflow_specs?: WorkflowSpec[];
|
||||||
display_order: number;
|
display_order: number;
|
||||||
|
@ -173,7 +173,7 @@ export class WorkflowSpecListComponent implements OnInit {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
dialogRef.afterClosed().subscribe((data: WorkflowSpecCategoryDialogData) => {
|
dialogRef.afterClosed().subscribe((data: WorkflowSpecCategoryDialogData) => {
|
||||||
if (data && isNumberDefined(data.id) && data.display_name) {
|
if (data && data.display_name) {
|
||||||
this._upsertWorkflowSpecCategory(data);
|
this._upsertWorkflowSpecCategory(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -329,21 +329,21 @@ export class WorkflowSpecListComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _upsertWorkflowSpecCategory(data: WorkflowSpecCategoryDialogData) {
|
private _upsertWorkflowSpecCategory(data: WorkflowSpecCategoryDialogData) {
|
||||||
if (isNumberDefined(data.id) && data.display_name) {
|
if (data.display_name) {
|
||||||
|
if (isNumberDefined(data.id)) {
|
||||||
// Save old workflow spec id, in case it's changed
|
|
||||||
const catId = this.selectedCat ? this.selectedCat.id : undefined;
|
|
||||||
|
|
||||||
const newCat: WorkflowSpecCategory = {
|
const newCat: WorkflowSpecCategory = {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
display_name: data.display_name,
|
display_name: data.display_name,
|
||||||
display_order: data.display_order,
|
display_order: data.display_order,
|
||||||
admin: data.admin,
|
admin: data.admin,
|
||||||
};
|
};
|
||||||
|
this._updateWorkflowSpecCategory(data.id, newCat);
|
||||||
if (isNumberDefined(catId)) {
|
|
||||||
this._updateWorkflowSpecCategory(catId, newCat);
|
|
||||||
} else {
|
} else {
|
||||||
|
const newCat: WorkflowSpecCategory = {
|
||||||
|
display_name: data.display_name,
|
||||||
|
display_order: data.display_order,
|
||||||
|
admin: data.admin,
|
||||||
|
};
|
||||||
this._addWorkflowSpecCategory(newCat);
|
this._addWorkflowSpecCategory(newCat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue