Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
}
private onListItemChange(propertyPath: string, oldValue: any, newValue: any): void {
//update the property value
update(this.properties, propertyPath, (): any => { return newValue; });
// store selected item reset in web part properties
this.onPropertyPaneFieldChanged(propertyPath, oldValue, newValue);
}
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;
}
// If the templateText have changed, update the "hasDefaultTemplateBeenUpdated" to true so the WebPart doesn't override the user template after updating view fields
if(propertyPath == ContentQueryConstants.propertyTemplateText && !this.properties.hasDefaultTemplateBeenUpdated) {
update(this.properties, ContentQueryConstants.propertyhasDefaultTemplateBeenUpdated, (): any => { return true; });
}
// Refreshes the web part manually because custom fields don't update since sp-webpart-base@1.1.1
// https://github.com/SharePoint/sp-dev-docs/issues/594
if (!this.disableReactivePropertyChanges)
this.render();
if(rerenderTemplateTextDialog) {
this.templateTextDialog.render();
private resetViewFieldsPropertyPane() {
Log.verbose(this.logSource, "Resetting 'viewFields' property...", this.context.serviceScope);
this.properties.viewFields = null;
this.ContentQueryService.clearCachedViewFields();
update(this.properties, ContentQueryConstants.propertyViewFields, (): any => { return this.properties.viewFields; });
this.viewFieldsChecklist.properties.checkedItems = null;
this.viewFieldsChecklist.properties.disable = isEmpty(this.properties.webUrl) || isEmpty(this.properties.listId);
this.viewFieldsChecklist.render();
}
}
private resetOrderByPropertyPane() {
Log.verbose(this.logSource, "Resetting 'orderBy' property...", this.context.serviceScope);
this.properties.orderBy = null;
this.ContentQueryService.clearCachedOrderByOptions();
update(this.properties, ContentQueryConstants.propertyOrderBy, (): any => { return this.properties.orderBy; });
this.orderByDropdown.properties.selectedKey = "";
this.orderByDropdown.properties.disabled = isEmpty(this.properties.webUrl) || isEmpty(this.properties.listId);
this.orderByDropdown.render();
}
private resetWebUrlPropertyPane() {
Log.verbose(this.logSource, "Resetting 'webUrl' property...", this.context.serviceScope);
this.properties.webUrl = "";
this.ContentQueryService.clearCachedWebUrlOptions();
update(this.properties, ContentQueryConstants.propertyWebUrl, (): any => { return this.properties.webUrl; });
this.webUrlDropdown.properties.selectedKey = "";
this.webUrlDropdown.properties.disabled = isEmpty(this.properties.siteUrl);
this.webUrlDropdown.render();
}
private resetFiltersPropertyPane() {
Log.verbose(this.logSource, "Resetting 'filters' property...", this.context.serviceScope);
this.properties.filters = null;
this.ContentQueryService.clearCachedFilterFields();
update(this.properties, ContentQueryConstants.propertyFilters, (): any => { return this.properties.filters; });
this.filtersPanel.properties.filters = null;
this.filtersPanel.properties.disabled = isEmpty(this.properties.webUrl) || isEmpty(this.properties.listId);
this.filtersPanel.render();
}
private resetListTitlePropertyPane() {
Log.verbose(this.logSource, "Resetting 'listTitle' property...", this.context.serviceScope);
this.properties.listId = null;
this.ContentQueryService.clearCachedListTitleOptions();
update(this.properties, ContentQueryConstants.propertyListId, (): any => { return this.properties.listId; });
this.listTitleDropdown.properties.selectedKey = "";
this.listTitleDropdown.properties.disabled = isEmpty(this.properties.webUrl);
this.listTitleDropdown.render();
}