From 129ecea60a0ddda312ecd72676e57399147ae025 Mon Sep 17 00:00:00 2001 From: Julian-Mueller-GIP <139366124+Julian-Mueller-GIP@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:09:58 +0100 Subject: [PATCH] changed change detection strategy to onpush (#224) * changed change detection strategy to onpush * removed closedSubject --- package-lock.json | 4 +- package.json | 2 +- .../xc-definition-stack-item.component.ts | 38 +++++++++++-------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 91fabb2..0cba8db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "zeta", - "version": "17.0.13", + "version": "17.0.15", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "zeta", - "version": "17.0.13", + "version": "17.0.15", "dependencies": { "@angular/animations": "17.3.3", "@angular/cdk": "16.2.13", diff --git a/package.json b/package.json index 45bc753..b0a9e19 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zeta", "title": "Zeta", - "version": "17.0.14", + "version": "17.0.15", "private": true, "engines": { "node": "^18.13.0 || ^20.9.0" diff --git a/xc/xc-form/definitions/xc-definition-stack/xc-definition-stack-item/xc-definition-stack-item.component.ts b/xc/xc-form/definitions/xc-definition-stack/xc-definition-stack-item/xc-definition-stack-item.component.ts index fe90ad5..05467e1 100644 --- a/xc/xc-form/definitions/xc-definition-stack/xc-definition-stack-item/xc-definition-stack-item.component.ts +++ b/xc/xc-form/definitions/xc-definition-stack/xc-definition-stack-item/xc-definition-stack-item.component.ts @@ -15,21 +15,23 @@ * limitations under the License. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -import { AfterViewInit, Component, Injector, OnDestroy } from '@angular/core'; +import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, Injector, OnDestroy } from '@angular/core'; + import { environment } from '@environments/environment'; -import { XcStackItemComponent, XcStackItemComponentData } from '../../../../xc-stack/xc-stack-item/xc-stack-item.component'; -import { Observable, of, Subject, Subscription, throwError } from 'rxjs'; +import { Observable, of, Subscription, throwError } from 'rxjs'; import { filter, map, switchMap, tap } from 'rxjs/operators'; -import { XoFormDefinition } from '../../xo/containers.model'; + import { ApiService, StartOrderOptionsBuilder, Xo, XoManagedFileID, XoXPRCRuntimeContext, XoXPRCRuntimeContextFromRuntimeContext } from '../../../../../api'; -import { XcStackItem, XcStackItemInterface, XcStackItemObserver } from '../../../../xc-stack/xc-stack-item/xc-stack-item'; -import { XoBaseDefinition, XoCloseDefinitionData, XoDefinition, XoDefinitionBundle, XoDefinitionObserver } from '../../xo/base-definition.model'; -import { XcDialogService } from '../../../../xc-dialog/xc-dialog.service'; import { I18nService } from '../../../../../i18n'; +import { XcDialogService } from '../../../../xc-dialog/xc-dialog.service'; +import { XcStackItem, XcStackItemInterface, XcStackItemObserver } from '../../../../xc-stack/xc-stack-item/xc-stack-item'; +import { XcStackItemComponent, XcStackItemComponentData } from '../../../../xc-stack/xc-stack-item/xc-stack-item.component'; import { XcComponentTemplate } from '../../../../xc-template/xc-template'; -import { XoStartOrderButtonDefinition } from '../../xo/item-definition.model'; import { XcDialogDefinitionComponent } from '../../xc-dialog-definition/xc-dialog-definition.component'; +import { XoBaseDefinition, XoCloseDefinitionData, XoDefinition, XoDefinitionBundle, XoDefinitionObserver } from '../../xo/base-definition.model'; +import { XoFormDefinition } from '../../xo/containers.model'; +import { XoStartOrderButtonDefinition } from '../../xo/item-definition.model'; export interface DefinitionStackItemComponentData extends XcStackItemComponentData { @@ -46,16 +48,22 @@ interface DefinitionStackItem { @Component({ templateUrl: './xc-definition-stack-item.component.html', - styleUrls: ['./xc-definition-stack-item.component.scss'] + styleUrls: ['./xc-definition-stack-item.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush }) export class XcDefinitionStackItemComponent extends XcStackItemComponent implements XoDefinitionObserver, AfterViewInit, OnDestroy { private detailsItem: DefinitionStackItem; - private readonly closedSubject = new Subject(); private readonly subscriptions: Subscription[] = []; - constructor(readonly injector: Injector, private readonly api: ApiService, private readonly dialogs: XcDialogService, private readonly i18n: I18nService) { + constructor( + readonly injector: Injector, + private readonly api: ApiService, + private readonly dialogs: XcDialogService, + private readonly i18n: I18nService, + private readonly cdr: ChangeDetectorRef + ) { super(injector); } @@ -97,7 +105,8 @@ export class XcDefinitionStackItemComponent extends XcStackItemComponent{ stackItem: this.detailsItem.item, definition: definition, data: data } )); - return this.stackItem.stack.open(this.detailsItem.item); + // markForCheck has to be called before stack.open to work propperly + return of(null).pipe(tap(() => this.cdr.markForCheck()), switchMap(() => this.stackItem.stack.open(this.detailsItem.item))); }; // close current details item, if any @@ -111,7 +120,7 @@ export class XcDefinitionStackItemComponent extends XcStackItemComponent { - return this.dialogs.custom(XcDialogDefinitionComponent, {definition: definition, data: data}).afterDismiss(); + return this.dialogs.custom(XcDialogDefinitionComponent, { definition: definition, data: data }).afterDismiss(); } @@ -123,8 +132,7 @@ export class XcDefinitionStackItemComponent extends XcStackItemComponent { if (closed) { - this.closedSubject.next(data); - this.closedSubject.complete(); + this.cdr.markForCheck(); } }) );