Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private onCustomPropertyPaneChange(propertyPath: string, newValue: any): void {
Log.verbose(this.logSource, "WebPart property '" + propertyPath + "' has changed, refreshing WebPart...", this.context.serviceScope);
let rerenderTemplateTextDialog = false;
const oldValue = get(this.properties, propertyPath);
// Stores the new value in web part properties
update(this.properties, propertyPath, (): any => { return newValue; });
this.onPropertyPaneFieldChanged(propertyPath, oldValue, newValue);
// Resets dependent property panes if needed
this.resetDependentPropertyPanes(propertyPath);
// If the viewfields have changed, update the default template text if it hasn't been altered by the user
if(propertyPath == ContentQueryConstants.propertyViewFields && !this.properties.hasDefaultTemplateBeenUpdated) {
let generatedTemplate = this.ContentQueryService.generateDefaultTemplate(newValue);
update(this.properties, ContentQueryConstants.propertyTemplateText, (): any => { return generatedTemplate; });
this.templateTextDialog.properties.dialogTextFieldValue = generatedTemplate;
rerenderTemplateTextDialog = true;
}
private onListChange(propertyPath: string, oldValue: any, newValue: any): void {
//update the property value
update(this.properties, propertyPath, (): any => { return newValue; });
// trigger that propertyPath was changed
this.onPropertyPaneFieldChanged(propertyPath, oldValue, newValue);
// reset selected item
const oldItemValue : any = get(this.properties, 'item');
this.properties.item = undefined;
update(this.properties, 'item', (): any => { return this.properties.item; });
// store selected item reset in web part properties
this.onPropertyPaneFieldChanged('item', oldItemValue, this.properties.item);
// reset selected values in item dropdown
//this.itemsDropDown.properties.selectedKey = this.properties.item;
this.itemsDropDown.properties.selectedKey = "";
// allow to load items
this.itemsDropDown.properties.disabled = false;
// load items and re-render items dropdown
this.itemsDropDown.render();
}
private onListChange(propertyPath: string, newValue: any): void {
const oldValue: any = get(this.properties, propertyPath);
if (oldValue !== newValue) {
this.properties.fields = null;
}
// store new value in web part properties
update(this.properties, propertyPath, (): any => newValue);
// refresh property Pane
this.context.propertyPane.refresh();
// refresh web part
this.render();
}