fonteva-design-guide
Version:
## Dev, Build and Test
41 lines (35 loc) • 1.25 kB
JavaScript
import { LightningElement, api, track } from 'lwc';
export default class PfmTableCustomBadge extends LightningElement {
rowId;
colId;
badgeAttributes;
get val() {
return this.val;
}
set val(value) {
this.additionalText = value.additionalText;
this.showBadge = value.showBadge;
}
classes = 'pfm-custom_badge';
additionalText;
hasAdditionalText = true;
showBadge = true;
renderedCallbackTriggered = false;
valMargin = 'right:xx-small';
badgeName;
renderedCallback() {
if (!this.renderedCallbackTriggered && this.badgeAttributes) {
this.badgeName = 'pfm-custom_badge-' + this.rowId;
if (this.showBadge) {
const badge = this.template.querySelector('c-pfm-badge');
Object.keys(this.badgeAttributes).forEach(key => {
badge[key] = this.badgeAttributes[key];
});
badge.refreshAttributes();
}
this.valMargin = this.showBadge ? 'right:xx-small' : '';
this.renderedCallbackTriggered = true;
}
}
}