Changed table load
This commit is contained in:
parent
a82d3690f3
commit
d3216f3ee7
@ -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() {
|
|
||||||
this.hasInitialized = !this.activeValue;
|
|
||||||
|
|
||||||
|
effect(() => {
|
||||||
|
if (this.active()) {
|
||||||
this.calculatedFieldsTableConfig = new CalculatedFieldsTableConfig(
|
this.calculatedFieldsTableConfig = new CalculatedFieldsTableConfig(
|
||||||
this.calculatedFieldsService,
|
this.calculatedFieldsService,
|
||||||
this.translate,
|
this.translate,
|
||||||
this.dialog,
|
this.dialog,
|
||||||
this.entityIdValue,
|
this.entityId(),
|
||||||
this.store,
|
this.store,
|
||||||
this.durationLeft,
|
this.durationLeft,
|
||||||
this.popoverService,
|
this.popoverService,
|
||||||
this.destroyRef,
|
this.destroyRef,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user