Changed table load

This commit is contained in:
mpetrov 2025-01-31 13:11:12 +02:00
parent a82d3690f3
commit d3216f3ee7

View File

@ -18,8 +18,8 @@ import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
Component, Component,
DestroyRef, DestroyRef,
Input, effect,
OnInit, input,
ViewChild, ViewChild,
} from '@angular/core'; } from '@angular/core';
import { EntityId } from '@shared/models/id/entity-id'; import { EntityId } from '@shared/models/id/entity-id';
@ -39,36 +39,14 @@ import { CalculatedFieldsService } from '@core/http/calculated-fields.service';
styleUrls: ['./calculated-fields-table.component.scss'], styleUrls: ['./calculated-fields-table.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class CalculatedFieldsTableComponent implements OnInit { export class CalculatedFieldsTableComponent {
@Input()
set entityId(entityId: EntityId) {
if (this.entityIdValue !== entityId) {
this.entityIdValue = entityId;
if (!this.activeValue) {
this.hasInitialized = true;
}
}
}
@Input()
set active(active: boolean) {
if (this.activeValue !== active) {
this.activeValue = active;
if (this.activeValue && this.hasInitialized) {
this.hasInitialized = false;
this.entitiesTable.updateData();
}
}
}
@ViewChild(EntitiesTableComponent, {static: true}) entitiesTable: EntitiesTableComponent; @ViewChild(EntitiesTableComponent, {static: true}) entitiesTable: EntitiesTableComponent;
calculatedFieldsTableConfig: CalculatedFieldsTableConfig; active = input();
entityId = input<EntityId>();
private activeValue = false; calculatedFieldsTableConfig: CalculatedFieldsTableConfig;
private hasInitialized = false;
private entityIdValue: EntityId;
constructor(private calculatedFieldsService: CalculatedFieldsService, constructor(private calculatedFieldsService: CalculatedFieldsService,
private translate: TranslateService, private translate: TranslateService,
@ -77,20 +55,20 @@ export class CalculatedFieldsTableComponent implements OnInit {
private durationLeft: DurationLeftPipe, private durationLeft: DurationLeftPipe,
private popoverService: TbPopoverService, private popoverService: TbPopoverService,
private destroyRef: DestroyRef) { private destroyRef: DestroyRef) {
}
ngOnInit() { effect(() => {
this.hasInitialized = !this.activeValue; if (this.active()) {
this.calculatedFieldsTableConfig = new CalculatedFieldsTableConfig(
this.calculatedFieldsTableConfig = new CalculatedFieldsTableConfig( this.calculatedFieldsService,
this.calculatedFieldsService, this.translate,
this.translate, this.dialog,
this.dialog, this.entityId(),
this.entityIdValue, this.store,
this.store, this.durationLeft,
this.durationLeft, this.popoverService,
this.popoverService, this.destroyRef,
this.destroyRef, );
); }
});
} }
} }