fonteva-design-guide
Version:
## Dev, Build and Test
42 lines (35 loc) • 1.49 kB
JavaScript
import { LightningElement, api, track } from 'lwc';
import { publishEvent } from 'c/pubsub';
export default class PfmTableCustomActionButton extends LightningElement {
rowId;
actionButtonAttributes;
iconName = '';
iconSize = 'x-small';
buttonType = 'outline';
buttonName = '';
classes = 'pfm-custom_action_button';
renderedCallbackTriggered = false;
renderedCallback() {
if (!this.renderedCallbackTriggered && this.actionButtonAttributes) {
const actionName = this.actionButtonAttributes.actionName;
this.buttonName = actionName + '-' + this.rowId;
this.classes += ' pfm-custom_action_button-' + actionName;
const button = this.template.querySelector('c-pfm-button');
Object.keys(this.actionButtonAttributes).forEach(key => {
button[key] = this.actionButtonAttributes[key];
});
button.icon = this.actionButtonAttributes.iconName;
if (this.actionButtonAttributes.buttonType) {
button.type = this.actionButtonAttributes.buttonType;
}
button.refreshAttributes();
this.renderedCallbackTriggered = true;
}
}
handleClick() {
publishEvent(this.actionButtonAttributes.actionName, {
rowId: this.rowId,
thisButton: this
});
}
}