Added a "Search within folders" switch and fixed a bug (#463)

* Added the "Search within folders" switch which enables the WebPart to return results from within folders as well (recursive). Also fixed a bug where webs could sometimes not appear under the web url dropdown.

* Fixed a bug which prevented to load webs correctly out of private groups

* Fixed a bug with the automatic current web selection

* Previously committed wrong .sppkg
This commit is contained in:
Simon-Pierre Plante 2018-04-04 10:52:31 -04:00 committed by Vesa Juvonen
parent 4acdd442bd
commit f9e039511d
14 changed files with 32 additions and 9 deletions

View File

@ -32,6 +32,7 @@ Version|Date|Comments
1.0.6|September 19, 2017|Upgraded to SharePoint drop 1.2.0 and added the site url and web url preselection when adding the WebPart for the first time on a page. Also fixed a bug with fields that had spaces in their internal names (automatically replaced with `_x0020_` by SharePoint).
1.0.7|November 17, 2017|Reverted to drop 1.1.0 in order to keep compatibility for SP2016 on-premise
1.0.8|March 17, 2018|Updated to store the selected list using its ID instead of its title, so the webpart keeps working if the list title gets updated.
1.0.9|March 28, 2018|Added a switch to enable the WebPart to apply it's query recursively within folders, and fixed a bug where webs could sometimes not appear under the web url dropdown
## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

View File

@ -3,7 +3,7 @@
"solution": {
"name": "React Content Query",
"id": "00406271-0276-406f-9666-512623eb6709",
"version": "1.0.8.0"
"version": "1.0.9.0"
},
"paths": {
"zippedPackage": "solution/react-content-query-webpart.sppkg"

View File

@ -1,4 +1,4 @@
{
"$schema": "https://dev.office.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "https://publiccdn.sharepointonline.com/spptechnologies.sharepoint.com/110700492eeea162ee5bad0f35b1f0061ded8bf436ce0199efe2a4d24109e1c0df1ec594/react-content-query-1.0.8"
"cdnBasePath": "https://publiccdn.sharepointonline.com/spptechnologies.sharepoint.com/110700492eeea162ee5bad0f35b1f0061ded8bf436ce0199efe2a4d24109e1c0df1ec594/react-content-query-1.0.9"
}

View File

@ -1,6 +1,6 @@
{
"name": "react-content-query-webpart",
"version": "1.0.7",
"version": "1.0.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "react-content-query-webpart",
"version": "1.0.8",
"version": "1.0.9",
"private": true,
"engines": {
"node": ">=0.10.0"

View File

@ -11,6 +11,7 @@ export class ContentQueryConstants {
public static readonly propertOrderByDirection = "orderByDirection";
public static readonly propertyLimitEnabled = "limitEnabled";
public static readonly propertyItemLimit = "itemLimit";
public static readonly propertyRecursiveEnabled = "recursiveEnabled";
public static readonly propertyFilters = "filters";
public static readonly propertyViewFields = "viewFields";
public static readonly propertyTemplateText = "templateText";

View File

@ -43,7 +43,12 @@ export class CamlQueryHelper {
}
// Wraps the everything into a final <View /> tag
query = Text.format('<View>{0}</View>', query);
if(querySettings.recursiveEnabled) {
query = Text.format('<View Scope="RecursiveAll">{0}</View>', query);
}
else {
query = Text.format('<View>{0}</View>', query);
}
return query;
}

View File

@ -99,7 +99,7 @@ export class SearchService {
**************************************************************************************************/
public getSitesStartingWith(startingUrl: string): Promise<string[]> {
return new Promise<string[]>((resolve,reject) => {
let queryProperties = Text.format("querytext='Path:{0}/* AND contentclass:STS_Site'&selectproperties='Path'&trimduplicates=false&rowLimit=500", startingUrl);
let queryProperties = Text.format("querytext='Path:{0}/* AND contentclass:STS_Site'&selectproperties='Path'&trimduplicates=false&rowLimit=500&Properties='EnableDynamicGroups:true'", startingUrl);
this.getSearchResultsRecursive(startingUrl, queryProperties)
.then((results: any) => {
@ -119,7 +119,7 @@ export class SearchService {
**************************************************************************************************/
public getWebsFromSite(siteUrl: string): Promise<string[]> {
return new Promise<string[]>((resolve,reject) => {
let queryProperties = Text.format("querytext='SiteName:{0} AND (contentclass:STS_Site OR contentclass:STS_Web)'&selectproperties='Path'&trimduplicates=false&rowLimit=500&filter=", siteUrl);
let queryProperties = Text.format("querytext='SiteName:{0} AND (contentclass:STS_Site OR contentclass:STS_Web)'&selectproperties='Path'&trimduplicates=false&rowLimit=500&Properties='EnableDynamicGroups:true'", siteUrl);
this.getSearchResultsRecursive(siteUrl, queryProperties)
.then((results: any) => {

View File

@ -45,6 +45,7 @@ export default class ContentQueryWebPart extends BaseClientSideWebPart<IContentQ
private orderByDirectionChoiceGroup: IPropertyPaneField<IPropertyPaneChoiceGroupProps>;
private limitEnabledToggle: IPropertyPaneField<IPropertyPaneToggleProps>;
private itemLimitTextField: IPropertyPaneField<IPropertyPaneTextFieldProps>;
private recursiveEnabledToggle: IPropertyPaneField<IPropertyPaneToggleProps>;
private filtersPanel: PropertyPaneQueryFilterPanel;
private viewFieldsChecklist: PropertyPaneAsyncChecklist;
private templateTextDialog: PropertyPaneTextDialog;
@ -56,7 +57,7 @@ export default class ContentQueryWebPart extends BaseClientSideWebPart<IContentQ
* Returns the WebPart's version
***************************************************************************/
protected get dataVersion(): Version {
return Version.parse('1.0.8');
return Version.parse('1.0.9');
}
@ -66,8 +67,8 @@ export default class ContentQueryWebPart extends BaseClientSideWebPart<IContentQ
protected onInit(): Promise<void> {
return new Promise<void>((resolve, reject) => {
this.ContentQueryService = new ContentQueryService(this.context, this.context.spHttpClient);
this.properties.webUrl = this.properties.siteUrl || this.properties.webUrl ? this.properties.webUrl : this.context.pageContext.web.absoluteUrl.toLocaleLowerCase().trim();
this.properties.siteUrl = this.properties.siteUrl ? this.properties.siteUrl : this.context.pageContext.site.absoluteUrl.toLowerCase().trim();
this.properties.webUrl = this.properties.webUrl ? this.properties.webUrl : this.context.pageContext.web.absoluteUrl.toLocaleLowerCase().trim();
resolve();
});
}
@ -82,6 +83,7 @@ export default class ContentQueryWebPart extends BaseClientSideWebPart<IContentQ
listId: this.properties.listId,
limitEnabled: this.properties.limitEnabled,
itemLimit: this.properties.itemLimit,
recursiveEnabled: this.properties.recursiveEnabled,
orderBy: this.properties.orderBy,
orderByDirection: this.properties.orderByDirection,
filters: this.properties.filters,
@ -220,6 +222,15 @@ export default class ContentQueryWebPart extends BaseClientSideWebPart<IContentQ
onGetErrorMessage: this.onItemLimitChange.bind(this)
});
// Creates a PropertyPaneToggle for the limitEnabled property
this.recursiveEnabledToggle = PropertyPaneToggle(ContentQueryConstants.propertyRecursiveEnabled, {
label: strings.RecursiveEnabledFieldLabel,
offText: 'Disabled',
onText: 'Enabled',
checked: this.properties.recursiveEnabled,
disabled: thirdCascadingLevelDisabled
});
// Creates a PropertyPaneTextField for the externalScripts property
this.externalScripts = PropertyPaneTextField(ContentQueryConstants.propertyExternalScripts, {
label: strings.ExternalScriptsLabel,
@ -255,6 +266,7 @@ export default class ContentQueryWebPart extends BaseClientSideWebPart<IContentQ
this.orderByDirectionChoiceGroup,
this.limitEnabledToggle,
this.itemLimitTextField,
this.recursiveEnabledToggle,
this.filtersPanel
]
}

View File

@ -6,6 +6,7 @@ export interface IContentQueryWebPartProps {
listId: string;
limitEnabled: boolean;
itemLimit: number;
recursiveEnabled: boolean;
orderBy: string;
orderByDirection: string;
filters: IQueryFilter[];

View File

@ -5,6 +5,7 @@ export interface IQuerySettings {
listId: string;
limitEnabled: boolean;
itemLimit: number;
recursiveEnabled: boolean;
orderBy: string;
orderByDirection: string;
filters: IQueryFilter[];

View File

@ -26,6 +26,7 @@ define([], function() {
LimitEnabledFieldLabel: "Limit the number of items to display",
ItemLimitPlaceholder: "Enter a limit from 1 to 999",
ErrorItemLimit: "Value must be a number between 1 to 999",
RecursiveEnabledFieldLabel: "Search within folders",
TemplateUrlFieldLabel: "Template Url",
TemplateUrlPlaceholder: "Enter a valid HandleBars .htm file url",
ExternalScriptsLabel: "External Scripts",

View File

@ -25,6 +25,7 @@ declare interface IContentQueryStrings {
LimitEnabledFieldLabel: string;
ItemLimitPlaceholder: string;
ErrorItemLimit: string;
RecursiveEnabledFieldLabel: string;
TemplateUrlFieldLabel: string;
TemplateUrlPlaceholder: string;
ExternalScriptsLabel: string;