@pega/dx-component-builder-sdk
Version:
Utility for building custom UI components
51 lines (41 loc) • 1.47 kB
text/typescript
import { Component, OnInit, Input, OnChanges, SimpleChanges, forwardRef } from '@angular/core';
import { Utils } from '@pega/angular-sdk-components';
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
interface UtilityProps {
// If any, enter additional props that only exist on this component
headerIcon?: string;
headerText?: string;
noItemsMessage?: string;
}
export class UtilityComponent implements OnInit, OnChanges {
pConn$: typeof PConnect;
configProps$: UtilityProps;
headerIcon$?: string;
headerText$?: string;
headerIconUrl$?: string;
noItemsMessage$?: string;
constructor(private utils: Utils) {}
ngOnInit(): void {
this.updateSelf();
}
ngOnChanges(changes: SimpleChanges): void {
const { pConn$ } = changes;
if (pConn$.previousValue && pConn$.previousValue !== pConn$.currentValue) {
this.updateSelf();
}
}
updateSelf() {
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as UtilityProps;
this.headerIcon$ = this.configProps$.headerIcon;
this.headerIconUrl$ = this.utils.getSDKStaticContentUrl();
this.headerText$ = this.configProps$.headerText;
this.noItemsMessage$ = this.configProps$.noItemsMessage;
}
}