diff --git a/src/Squidex/app/shared/services/schemas.service.ts b/src/Squidex/app/shared/services/schemas.service.ts index e02391b2a..d2f6f7517 100644 --- a/src/Squidex/app/shared/services/schemas.service.ts +++ b/src/Squidex/app/shared/services/schemas.service.ts @@ -213,7 +213,7 @@ export class SchemaPropertiesDto { export interface AddFieldDto { readonly name: string; - readonly partitioning: string; + readonly partitioning?: string; readonly properties: FieldPropertiesDto; } diff --git a/src/Squidex/app/shared/state/schemas.state.spec.ts b/src/Squidex/app/shared/state/schemas.state.spec.ts index 4e8c74c74..0f0315218 100644 --- a/src/Squidex/app/shared/state/schemas.state.spec.ts +++ b/src/Squidex/app/shared/state/schemas.state.spec.ts @@ -13,6 +13,7 @@ import { SchemasState } from './schemas.state'; import { DialogService, + FieldDto, SchemaDetailsDto, SchemasService, UpdateSchemaCategoryDto, @@ -329,28 +330,38 @@ describe('SchemasState', () => { schemasService.setup(x => x.postField(app, schema1, It.isAny(), version)) .returns(() => of(updated)).verifiable(); - schemasState.addField(schema1, request).subscribe(); + let newField: FieldDto; + + schemasState.addField(schema1, request).subscribe(result => { + newField = result; + }); const schema1New = schemasState.snapshot.schemas.at(0); expect(schema1New).toEqual(updated); expect(schemasState.snapshot.selectedSchema).toEqual(updated); + expect(newField!).toBeDefined(); }); it('should update schema and selected schema when nested field added', () => { - const request = { ...schema.fields[0] }; + const request = { ...schema.fields[0].nested[0] }; const updated = createSchemaDetails(1, newVersion, '-new'); schemasService.setup(x => x.postField(app, schema.fields[0], It.isAny(), version)) .returns(() => of(updated)).verifiable(); - schemasState.addField(schema1, request, schema.fields[0]).subscribe(); + let newField: FieldDto; + + schemasState.addField(schema1, request, schema.fields[0]).subscribe(result => { + newField = result; + }); const schema1New = schemasState.snapshot.schemas.at(0); expect(schema1New).toEqual(updated); expect(schemasState.snapshot.selectedSchema).toEqual(updated); + expect(newField!).toBeDefined(); }); it('should update schema and selected schema when field removed', () => { diff --git a/src/Squidex/app/shared/state/schemas.state.ts b/src/Squidex/app/shared/state/schemas.state.ts index 68c3ea6d5..131fc1ad2 100644 --- a/src/Squidex/app/shared/state/schemas.state.ts +++ b/src/Squidex/app/shared/state/schemas.state.ts @@ -322,7 +322,7 @@ export class SchemasState extends State { function getField(x: SchemaDetailsDto, request: AddFieldDto, parent?: RootFieldDto): FieldDto { if (parent) { - return parent.nested.find(f => f.name === request.name)!; + return x.fields.find(f => f.fieldId === parent.fieldId)!.nested.find(f => f.name === request.name)!; } else { return x.fields.find(f => f.name === request.name)!; }