Browse Source

Field ordering fixed.

pull/372/head
Sebastian Stehle 7 years ago
parent
commit
f8520d2bc1
  1. 6
      src/Squidex/Areas/Api/Controllers/Schemas/Models/FieldDto.cs
  2. 2
      src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs
  3. 2
      src/Squidex/app/features/schemas/pages/schema/field.component.ts
  4. 2
      src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts
  5. 4
      src/Squidex/app/shared/services/schemas.service.spec.ts
  6. 4
      src/Squidex/app/shared/services/schemas.service.ts
  7. 4
      src/Squidex/app/shared/state/schemas.state.spec.ts
  8. 2
      src/Squidex/app/shared/state/schemas.state.ts

6
src/Squidex/Areas/Api/Controllers/Schemas/Models/FieldDto.cs

@ -88,9 +88,11 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
if (Properties is ArrayFieldPropertiesDto)
{
AddPostLink("fields/add", controller.Url<SchemaFieldsController>(x => nameof(x.PostNestedField), values));
var parentValues = new { app, name = schema, parentId = FieldId };
AddPutLink("order", controller.Url<SchemaFieldsController>(x => nameof(x.PutNestedFieldOrdering), values));
AddPostLink("fields/add", controller.Url<SchemaFieldsController>(x => nameof(x.PostNestedField), parentValues));
AddPutLink("fields/order", controller.Url<SchemaFieldsController>(x => nameof(x.PutNestedFieldOrdering), parentValues));
}
AddPutLink("lock", controller.Url<SchemaFieldsController>(x => nameof(x.LockField), values));

2
src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs

@ -119,7 +119,7 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
if (allowUpdate)
{
AddPutLink("order", controller.Url<SchemaFieldsController>(x => nameof(x.PutSchemaFieldOrdering), values));
AddPutLink("fields/order", controller.Url<SchemaFieldsController>(x => nameof(x.PutSchemaFieldOrdering), values));
AddPutLink("update", controller.Url<SchemasController>(x => nameof(x.PutSchema), values));
AddPutLink("update/category", controller.Url<SchemasController>(x => nameof(x.PutCategory), values));

2
src/Squidex/app/features/schemas/pages/schema/field.component.ts

@ -95,7 +95,7 @@ export class FieldComponent implements OnChanges {
}
public sortFields(fields: NestedFieldDto[]) {
this.schemasState.sortFields(this.schema, fields, <any>this.field).subscribe();
this.schemasState.orderFields(this.schema, fields, <any>this.field).subscribe();
}
public lockField() {

2
src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts

@ -87,7 +87,7 @@ export class SchemaPageComponent extends ResourceOwner implements OnInit {
}
public sortFields(fields: FieldDto[]) {
this.schemasState.sortFields(this.schema, fields).subscribe();
this.schemasState.orderFields(this.schema, fields).subscribe();
}
public trackByField(index: number, field: FieldDto) {

4
src/Squidex/app/shared/services/schemas.service.spec.ts

@ -236,7 +236,7 @@ describe('SchemasService', () => {
const resource: Resource = {
_links: {
['update/urls'] { method: 'PUT', href: '/api/apps/my-app/schemas/my-schema/preview-urls' }
['update/urls']: { method: 'PUT', href: '/api/apps/my-app/schemas/my-schema/preview-urls' }
}
};
@ -387,7 +387,7 @@ describe('SchemasService', () => {
const resource: Resource = {
_links: {
order: { method: 'PUT', href: '/api/apps/my-app/schemas/my-schema/fields/ordering' }
['fields/order']: { method: 'PUT', href: '/api/apps/my-app/schemas/my-schema/fields/ordering' }
}
};

4
src/Squidex/app/shared/services/schemas.service.ts

@ -385,11 +385,11 @@ export class SchemasService {
}
public putFieldOrdering(appName: string, resource: Resource, dto: number[], version: Version): Observable<SchemaDetailsDto> {
const link = resource._links['order'];
const link = resource._links['fields/order'];
const url = this.apiUrl.buildUrl(link.href);
return HTTP.requestVersioned(this.http, link.method, url, version, dto).pipe(
return HTTP.requestVersioned(this.http, link.method, url, version, { fieldIds: dto }).pipe(
map(({ version: newVersion, payload }) => {
return parseSchemaWithDetails(payload.body, newVersion);
}),

4
src/Squidex/app/shared/state/schemas.state.spec.ts

@ -373,7 +373,7 @@ describe('SchemasState', () => {
schemasService.setup(x => x.putFieldOrdering(app, schema1, [schema.fields[1].fieldId, schema.fields[2].fieldId], version))
.returns(() => of(updated)).verifiable();
schemasState.sortFields(schema1, [schema.fields[1], schema.fields[2]]).subscribe();
schemasState.orderFields(schema1, [schema.fields[1], schema.fields[2]]).subscribe();
const schema1New = <SchemaDetailsDto>schemasState.snapshot.schemas.at(0);
@ -387,7 +387,7 @@ describe('SchemasState', () => {
schemasService.setup(x => x.putFieldOrdering(app, schema.fields[0], [schema.fields[1].fieldId, schema.fields[2].fieldId], version))
.returns(() => of(updated)).verifiable();
schemasState.sortFields(schema1, [schema.fields[1], schema.fields[2]], schema.fields[0]).subscribe();
schemasState.orderFields(schema1, [schema.fields[1], schema.fields[2]], schema.fields[0]).subscribe();
const schema1New = <SchemaDetailsDto>schemasState.snapshot.schemas.at(0);

2
src/Squidex/app/shared/state/schemas.state.ts

@ -233,7 +233,7 @@ export class SchemasState extends State<Snapshot> {
shareMapSubscribed(this.dialogs, x => getField(x, request, parent), { silent: true }));
}
public sortFields(schema: SchemaDto, fields: any[], parent?: RootFieldDto): Observable<SchemaDetailsDto> {
public orderFields(schema: SchemaDto, fields: any[], parent?: RootFieldDto): Observable<SchemaDetailsDto> {
return this.schemasService.putFieldOrdering(this.appName, parent || schema, fields.map(t => t.fieldId), schema.version).pipe(
tap(updated => {
this.replaceSchema(updated);

Loading…
Cancel
Save