diff --git a/src/Squidex/app/features/content/pages/content/content-page.component.ts b/src/Squidex/app/features/content/pages/content/content-page.component.ts
index 3de4e28b6..e9e5bd65e 100644
--- a/src/Squidex/app/features/content/pages/content/content-page.component.ts
+++ b/src/Squidex/app/features/content/pages/content/content-page.component.ts
@@ -81,7 +81,7 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone
this.contentDeletedSubscription =
this.messageBus.of(ContentDeleted)
.subscribe(message => {
- if (message.contentId === this.contentId) {
+ if (message.content.id === this.contentId) {
this.router.navigate(['../'], { relativeTo: this.route });
}
});
diff --git a/src/Squidex/app/features/content/pages/contents/contents-page.component.ts b/src/Squidex/app/features/content/pages/contents/contents-page.component.ts
index 8dc82061b..1130ed7e1 100644
--- a/src/Squidex/app/features/content/pages/contents/contents-page.component.ts
+++ b/src/Squidex/app/features/content/pages/contents/contents-page.component.ts
@@ -148,7 +148,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
this.contentItems = this.contentItems.removeAll(x => x.id === content.id);
this.contentsPager = this.contentsPager.decrementCount();
- this.messageBus.publish(new ContentDeleted(content.id));
+ this.messageBus.publish(new ContentDeleted(content));
}, error => {
this.notifyError(error);
});
diff --git a/src/Squidex/app/features/content/pages/messages.ts b/src/Squidex/app/features/content/pages/messages.ts
index 8e90c1acd..580651082 100644
--- a/src/Squidex/app/features/content/pages/messages.ts
+++ b/src/Squidex/app/features/content/pages/messages.ts
@@ -23,7 +23,7 @@ export class ContentUpdated {
export class ContentDeleted {
constructor(
- public readonly contentId: string
+ public readonly content: ContentDto
) {
}
}
\ No newline at end of file
diff --git a/src/Squidex/app/features/schemas/pages/messages.ts b/src/Squidex/app/features/schemas/pages/messages.ts
index db040dba3..4b59f0725 100644
--- a/src/Squidex/app/features/schemas/pages/messages.ts
+++ b/src/Squidex/app/features/schemas/pages/messages.ts
@@ -16,7 +16,7 @@ export class SchemaUpdated {
export class SchemaDeleted {
constructor(
- public readonly schemaId: string
+ public readonly schema: SchemaDto
) {
}
}
\ No newline at end of file
diff --git a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html
index b6500f1a3..2bb696632 100644
--- a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html
+++ b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html
@@ -30,7 +30,7 @@
- {{schemaInformation | sqxDisplayName}}
+ {{schema | sqxDisplayName:'properties.label':'name'}}
@@ -40,8 +40,8 @@
-
-
+
+
this.schemasService.deleteSchema(app, this.schema.name, this.schema.version)).retry(2)
.subscribe(() => {
- this.messageBus.publish(new SchemaDeleted(this.schema.id));
+ this.messageBus.publish(new SchemaDeleted(this.schema));
this.router.navigate(['../'], { relativeTo: this.route });
}, error => {
diff --git a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts
index 3892dd475..725d46c52 100644
--- a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts
+++ b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts
@@ -80,7 +80,7 @@ export class SchemasPageComponent extends AppComponentBase implements OnDestroy,
this.schemaDeletedSubscription =
this.messageBus.of(SchemaDeleted)
.subscribe(m => {
- this.updateSchemas(this.schemas.filter(s => s.id !== m.schemaId));
+ this.updateSchemas(this.schemas.filter(s => s.id !== m.schema.id));
});
this.load();
@@ -111,18 +111,7 @@ export class SchemasPageComponent extends AppComponentBase implements OnDestroy,
schemas = schemas.filter(t => t.name.indexOf(query!) >= 0);
}
- schemas =
- schemas.sort((a, b) => {
- if (a.name < b.name) {
- return -1;
- }
- if (a.name > b.name) {
- return 1;
- }
- return 0;
- });
-
- this.schemasFiltered = schemas;
+ this.schemasFiltered = schemas.sortByStringAsc(x => x.name);
}
}
diff --git a/src/Squidex/app/framework/utils/immutable-array.spec.ts b/src/Squidex/app/framework/utils/immutable-array.spec.ts
index 5523b1761..737f48c35 100644
--- a/src/Squidex/app/framework/utils/immutable-array.spec.ts
+++ b/src/Squidex/app/framework/utils/immutable-array.spec.ts
@@ -161,6 +161,34 @@ describe('ImmutableArray', () => {
expect(array_2.values).toEqual([1, 2, 3, 4]);
});
+ it('should sort ascending by numbers', () => {
+ const array_1 = ImmutableArray.of([{ id: 3 }, { id: 2 }, { id: 1 }]);
+ const array_2 = array_1.sortByNumberAsc(x => x.id);
+
+ expect(array_2.values).toEqual([{ id: 1 }, { id: 2 }, { id: 3 }]);
+ });
+
+ it('should sort descending by numbers', () => {
+ const array_1 = ImmutableArray.of([{ id: 1 }, { id: 2 }, { id: 3 }]);
+ const array_2 = array_1.sortByNumberDesc(x => x.id);
+
+ expect(array_2.values).toEqual([{ id: 3 }, { id: 2 }, { id: 1 }]);
+ });
+
+ it('should sort ascending by string', () => {
+ const array_1 = ImmutableArray.of([{ id: '3' }, { id: '2' }, { id: '1' }]);
+ const array_2 = array_1.sortByStringAsc(x => x.id);
+
+ expect(array_2.values).toEqual([{ id: '1' }, { id: '2' }, { id: '3' }]);
+ });
+
+ it('should sort descending by string', () => {
+ const array_1 = ImmutableArray.of([{ id: '1' }, { id: '2' }, { id: '3' }]);
+ const array_2 = array_1.sortByStringDesc(x => x.id);
+
+ expect(array_2.values).toEqual([{ id: '3' }, { id: '2' }, { id: '1' }]);
+ });
+
it('should provide mutable values', () => {
const array_1 = ImmutableArray.of([3, 1, 4, 2]);
diff --git a/src/Squidex/app/framework/utils/immutable-array.ts b/src/Squidex/app/framework/utils/immutable-array.ts
index 9472e12f3..bc21c0b32 100644
--- a/src/Squidex/app/framework/utils/immutable-array.ts
+++ b/src/Squidex/app/framework/utils/immutable-array.ts
@@ -73,6 +73,66 @@ export class ImmutableArray implements Iterable {
return new ImmutableArray(clone);
}
+ public sortByStringAsc(filter: (a: T) => string): ImmutableArray {
+ return this.sort((a, b) => {
+ const av = filter(a);
+ const bv = filter(b);
+
+ if (av < bv) {
+ return -1;
+ }
+ if (av > bv) {
+ return 1;
+ }
+ return 0;
+ });
+ }
+
+ public sortByStringDesc(filter: (a: T) => string): ImmutableArray {
+ return this.sort((a, b) => {
+ const av = filter(a);
+ const bv = filter(b);
+
+ if (av < bv) {
+ return 1;
+ }
+ if (av > bv) {
+ return -1;
+ }
+ return 0;
+ });
+ }
+
+ public sortByNumberAsc(filter: (a: T) => number): ImmutableArray {
+ return this.sort((a, b) => {
+ const av = filter(a);
+ const bv = filter(b);
+
+ if (av < bv) {
+ return -1;
+ }
+ if (av > bv) {
+ return 1;
+ }
+ return 0;
+ });
+ }
+
+ public sortByNumberDesc(filter: (a: T) => number): ImmutableArray {
+ return this.sort((a, b) => {
+ const av = filter(a);
+ const bv = filter(b);
+
+ if (av < bv) {
+ return 1;
+ }
+ if (av > bv) {
+ return -1;
+ }
+ return 0;
+ });
+ }
+
public pushFront(...items: T[]): ImmutableArray {
if (!items || items.length === 0) {
return this;
diff --git a/src/Squidex/app/shared/services/apps.service.spec.ts b/src/Squidex/app/shared/services/apps.service.spec.ts
index 7ac5392b9..30b05c152 100644
--- a/src/Squidex/app/shared/services/apps.service.spec.ts
+++ b/src/Squidex/app/shared/services/apps.service.spec.ts
@@ -79,7 +79,7 @@ describe('AppsService', () => {
let app: AppDto | null = null;
- appsService.postApp(dto).subscribe(result => {
+ appsService.postApp(dto, now).subscribe(result => {
app = result;
});
diff --git a/src/Squidex/app/shared/services/assets.service.spec.ts b/src/Squidex/app/shared/services/assets.service.spec.ts
index 125e40e55..43a87ce53 100644
--- a/src/Squidex/app/shared/services/assets.service.spec.ts
+++ b/src/Squidex/app/shared/services/assets.service.spec.ts
@@ -207,7 +207,7 @@ describe('AssetsService', () => {
let asset: AssetDto | null = null;
- assetsService.uploadFile('my-app', null!, user).subscribe(result => {
+ assetsService.uploadFile('my-app', null!, user, now).subscribe(result => {
asset = result;
});
diff --git a/src/Squidex/app/shared/services/schemas.service.spec.ts b/src/Squidex/app/shared/services/schemas.service.spec.ts
index 50e4829e5..c04efe6cd 100644
--- a/src/Squidex/app/shared/services/schemas.service.spec.ts
+++ b/src/Squidex/app/shared/services/schemas.service.spec.ts
@@ -241,7 +241,7 @@ describe('SchemasService', () => {
const dto = new CreateSchemaDto('name');
- let schema: SchemaDto | null = null;
+ let schema: SchemaDetailsDto | null = null;
schemasService.postSchema('my-app', dto, user, now, version).subscribe(result => {
schema = result;
@@ -255,7 +255,7 @@ describe('SchemasService', () => {
req.flush({ id: '1' });
expect(schema).toEqual(
- new SchemaDto('my-schema', dto.name, new SchemaPropertiesDto(null, null), false, user, user, now, now, version));
+ new SchemaDetailsDto('1', dto.name, new SchemaPropertiesDto(null, null), false, user, user, now, now, version, []));
}));
it('should make post request to add field',