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 | 1x 1x 1x 1x 8x 5x 7x 7x | import { formatNumber } from '@angular/common'; import { Pipe, PipeTransform } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { VariationAttribute } from 'ish-core/models/product-variation/variation-attribute.model'; /** * Pipe * * Used on a variation attribute (of type VariationAttribute), this pipe will return the corresponding display (string) value, considering the current locale for number attribute values. */ @Pipe({ name: 'ishVariationAttribute', pure: false }) export class VariationAttributePipe implements PipeTransform { constructor(private translateService: TranslateService) {} private toDecimal(val: number): string { return formatNumber(val, this.translateService.currentLang); } transform(attr: VariationAttribute): string { Iif (!this.translateService.currentLang) { return 'undefined'; } return typeof attr?.value === 'object' ? `${this.toDecimal(attr.value.value)}\xA0${attr.value.unit}` : typeof attr?.value === 'number' ? this.toDecimal(attr.value) : attr?.value || 'undefined'; } } |