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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 1x 1x 1x | import { ComponentRender } from '@zeedhi/common';
import { FormatterParserProvider } from '@zeedhi/core';
import { IProductCard } from './interfaces';
/**
* Teknisa product card component
*/
export class ProductCard extends ComponentRender implements IProductCard {
/**
* Route path.
*/
public to: string = '';
/**
* Product Id.
*/
public id: string = '';
/**
* Image source Product.
*/
public src: string = '';
/**
* Product name.
*/
public productName: string = '';
/**
* Product supplier
*/
public productSupplier?: string;
/**
* Product brand
*/
public productBrand?: string;
/**
* Product price
*/
public productPrice?: number | string;
/**
* Path to image to be shown when error
*/
public errorImagePath: string = '';
/**
* Text to be shown when error
*/
public errorImageText: string = 'UNAVAILABLE_IMAGE';
/**
* Card width
*/
public width: string = '';
/**
* Sets the height for the component.
*/
public height: number | string = 'auto';
/**
* Sets the maximum height for the component.
*/
public maxHeight: number | string = 'none';
/**
* Sets the minimum height for the component.
*/
public minHeight: number | string = 'none';
protected currencyFormatterFn = FormatterParserProvider.getFormatter('ZdCurrency');
/**
* Creates a new instance of ProductCard
* @param props Product Card props
*/
constructor(props: IProductCard) {
super(props);
this.id = this.getInitValue('id', props.id, this.id);
this.productName = this.getInitValue('productName', props.productName, this.productName);
this.productSupplier = this.getInitValue('productSupplier', props.productSupplier, this.productSupplier);
this.productBrand = this.getInitValue('productBrand', props.productBrand, this.productBrand);
this.productPrice = this.getInitValue('productPrice', props.productPrice, this.productPrice);
this.to = this.getInitValue('to', props.to, this.to);
this.src = this.getInitValue('src', props.src, this.src);
this.errorImagePath = this.getInitValue('errorImagePath', props.errorImagePath, this.errorImagePath);
this.errorImageText = this.getInitValue('errorImageText', props.errorImageText, this.errorImageText);
this.width = this.getInitValue('width', props.width, this.width);
this.height = this.getInitValue('height', props.height, this.height);
this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
this.createAccessors();
}
get productPriceFormat() {
const price = +(this.productPrice || 0);
return this.currencyFormatterFn(price);
}
}
|