Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 7x 7x 7x 7x 7x 7x 7x 2x 7x 2x 2x 3x 3x 1x 1x 1x 3x 2x 2x 2x 1x 1x 1x 1x 2x 2x 1x 1x | import { Component, OnChanges, OnDestroy } from '@angular/core';
import { Input } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { Subscription } from 'rxjs';
import { ViewRenderer } from '@unpispas/upp-wdgt';
import { languageService, languageSupport } from '@unpispas/upp-base';
import { dataService } from '@unpispas/upp-data';
import { viewService } from '@unpispas/upp-base';
import { FamilyProduct } from '@unpispas/upp-data';
import { PreselectView } from '@unpispas/upp-data';
import { ProductView } from '@unpispas/upp-data';
@Component({
selector: 'upp-familyitem-view',
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './upp-item.html',
styleUrls: [
'./upp-item.scss'
],
providers: [{
provide: ViewRenderer,
useFactory: (change: ChangeDetectorRef) => new ViewRenderer(change),
deps: [ChangeDetectorRef]
}]
})
export class UppFamilyItemComponent extends languageSupport implements OnChanges, OnDestroy {
@Input() product: FamilyProduct | null = null;
private _item: ProductView | PreselectView | null = null;
get item(): ProductView | PreselectView | null {
Iif (!this.product){
return null;
}
if (!this._item){
if (this.product.product){
this._item = this.data.alives.get(this.product.product) as ProductView;
}
Iif (this.product.preselect){
this._item = this.data.alives.get(this.product.preselect) as PreselectView;
}
}
return this._item;
}
private _item_subscription: Subscription | null = null
constructor(private lang: languageService, private change: ViewRenderer, private data: dataService, public view: viewService){
super(lang, change.cdref);
}
ngOnChanges(){
Iif (this._item_subscription){
this._item_subscription.unsubscribe();
this._item_subscription = null;
}
this._item = null; // will refresh the underlying item
if (this.item){
this._item_subscription = this.item.OnViewRefresh.subscribe(
() => {
this.change.markForCheck();
});
}
}
ngOnDestroy(): void {
super.OnDestroy();
if (this._item_subscription){
this._item_subscription.unsubscribe();
this._item_subscription = null;
}
}
} |