From 2c3eb9a005868b89b9b7e3990949b8541ae2d5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 1 Nov 2021 15:21:39 +0200 Subject: [PATCH 1/3] Entity model, workflow updates --- src/lib/listing/models/entity.model.ts | 13 +++++++++++++ src/lib/listing/models/index.ts | 1 + src/lib/listing/workflow/workflow.component.ts | 4 ++++ 3 files changed, 18 insertions(+) create mode 100644 src/lib/listing/models/entity.model.ts diff --git a/src/lib/listing/models/entity.model.ts b/src/lib/listing/models/entity.model.ts new file mode 100644 index 0000000..f1491f8 --- /dev/null +++ b/src/lib/listing/models/entity.model.ts @@ -0,0 +1,13 @@ +import { IListable } from './listable'; + +export abstract class Entity implements IListable { + abstract readonly id: string; + abstract readonly routerLink?: string; + abstract readonly searchKey: string; + + protected constructor(private readonly _interface: I) {} + + isEqual(entity: Entity): boolean { + return JSON.stringify(this._interface) === JSON.stringify(entity?._interface); + } +} diff --git a/src/lib/listing/models/index.ts b/src/lib/listing/models/index.ts index 1096e80..586e11a 100644 --- a/src/lib/listing/models/index.ts +++ b/src/lib/listing/models/index.ts @@ -1,3 +1,4 @@ export * from './listable'; +export * from './entity.model'; export * from './table-column-config.model'; export * from './listing-modes'; diff --git a/src/lib/listing/workflow/workflow.component.ts b/src/lib/listing/workflow/workflow.component.ts index 2035962..d5f1149 100644 --- a/src/lib/listing/workflow/workflow.component.ts +++ b/src/lib/listing/workflow/workflow.component.ts @@ -1,5 +1,6 @@ import { ChangeDetectionStrategy, + ChangeDetectorRef, Component, EventEmitter, forwardRef, @@ -63,6 +64,7 @@ export class WorkflowComponent extends Au constructor( @Inject(forwardRef(() => ListingComponent)) readonly listingComponent: ListingComponent, private readonly _loadingService: LoadingService, + private readonly _changeRef: ChangeDetectorRef, readonly listingService: ListingService, readonly entitiesService: EntitiesService, ) { @@ -152,6 +154,8 @@ export class WorkflowComponent extends Au this._addEntity(entity); } }); + + this._changeRef.detectChanges(); } private _addEntity(entity: T): void { From f8ef27c49d44e0f05ebbc07594ff1b9a36029320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Wed, 3 Nov 2021 01:17:38 +0200 Subject: [PATCH 2/3] Autounsubscribe & entity updates --- src/lib/listing/models/entity.model.ts | 4 ++++ src/lib/utils/auto-unsubscribe.directive.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/lib/listing/models/entity.model.ts b/src/lib/listing/models/entity.model.ts index f1491f8..b8fc65f 100644 --- a/src/lib/listing/models/entity.model.ts +++ b/src/lib/listing/models/entity.model.ts @@ -7,6 +7,10 @@ export abstract class Entity implements IListable { protected constructor(private readonly _interface: I) {} + get model(): I { + return this._interface; + } + isEqual(entity: Entity): boolean { return JSON.stringify(this._interface) === JSON.stringify(entity?._interface); } diff --git a/src/lib/utils/auto-unsubscribe.directive.ts b/src/lib/utils/auto-unsubscribe.directive.ts index f912ca1..ff46bb7 100644 --- a/src/lib/utils/auto-unsubscribe.directive.ts +++ b/src/lib/utils/auto-unsubscribe.directive.ts @@ -17,6 +17,10 @@ export abstract class AutoUnsubscribe implements OnDestroy { this._subscriptions.add(subscription); } + set removeSubscription(subscription: Subscription) { + this._subscriptions.remove(subscription); + } + /** * This method unsubscribes active subscriptions * If you implement OnDestroy in a component that inherits AutoUnsubscribeComponent, From d3e27a384e7755839e31e22dfa7fd487f5a1ad05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Tue, 9 Nov 2021 03:50:58 +0200 Subject: [PATCH 3/3] Revert autounsubscribe change --- src/lib/utils/auto-unsubscribe.directive.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lib/utils/auto-unsubscribe.directive.ts b/src/lib/utils/auto-unsubscribe.directive.ts index ff46bb7..f912ca1 100644 --- a/src/lib/utils/auto-unsubscribe.directive.ts +++ b/src/lib/utils/auto-unsubscribe.directive.ts @@ -17,10 +17,6 @@ export abstract class AutoUnsubscribe implements OnDestroy { this._subscriptions.add(subscription); } - set removeSubscription(subscription: Subscription) { - this._subscriptions.remove(subscription); - } - /** * This method unsubscribes active subscriptions * If you implement OnDestroy in a component that inherits AutoUnsubscribeComponent,