Updared readme (#671)
Added query variables Support query template and result id
This commit is contained in:
parent
d3c7739383
commit
0952df826b
|
@ -35,7 +35,8 @@ Version|Date|Comments
|
||||||
1.5 | Jul 2, 2018 | <ul><li>Added a templating feature for search results with Handlebars inspired by the [react-content-query-webpart](https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-content-query-webpart) sample.</li><li>Upgraded to 1.5.1-plusbeta to use the new SPFx dynamic data feature instead of event aggregator for Web Parts communication.</li> <li>Code refactoring and reorganization.</ul>
|
1.5 | Jul 2, 2018 | <ul><li>Added a templating feature for search results with Handlebars inspired by the [react-content-query-webpart](https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-content-query-webpart) sample.</li><li>Upgraded to 1.5.1-plusbeta to use the new SPFx dynamic data feature instead of event aggregator for Web Parts communication.</li> <li>Code refactoring and reorganization.</ul>
|
||||||
2.0.0.5 | Sept 18, 2018 | <ul><li>Upgraded to 1.6.0-plusbeta.</li><li>Added dynamic loading of parts needed in edit mode to reduce web part footprint.</li><li>Added configuration to sort.</li><li>Added option to set web part title.</li><li>Added result count tokens.</li><li>Added toggel to load/use handlebars helpers/moment.</li></ul>
|
2.0.0.5 | Sept 18, 2018 | <ul><li>Upgraded to 1.6.0-plusbeta.</li><li>Added dynamic loading of parts needed in edit mode to reduce web part footprint.</li><li>Added configuration to sort.</li><li>Added option to set web part title.</li><li>Added result count tokens.</li><li>Added toggel to load/use handlebars helpers/moment.</li></ul>
|
||||||
2.1.0.0 | Oct 14, 2018 | <ul><li>Bug fixes ([#641](https://github.com/SharePoint/sp-dev-fx-webparts/issues/641),[#642](https://github.com/SharePoint/sp-dev-fx-webparts/issues/642))</li><li>Added document and Office 365 videos previews for the list template.</li><li>Added SharePoint best bets support.</li></ul>
|
2.1.0.0 | Oct 14, 2018 | <ul><li>Bug fixes ([#641](https://github.com/SharePoint/sp-dev-fx-webparts/issues/641),[#642](https://github.com/SharePoint/sp-dev-fx-webparts/issues/642))</li><li>Added document and Office 365 videos previews for the list template.</li><li>Added SharePoint best bets support.</li></ul>
|
||||||
2.1.1.0 | Oct 30, 2018 | <ul><li>Bug fix for editing custom template.</li><li>bug fix for dynamic loading of video helper library.</li><li>Added support for Page context query variables.</li><li>Added `getUniqueCount` helper function.</li></ul>
|
2.1.1.0 | Oct 30, 2018 | <ul><li>Bug fix for editing custom template.</li><li>Bug fix for dynamic loading of video helper library.</li><li>Added support for Page context query variables.</li><li>Added `getUniqueCount` helper function.</li></ul>
|
||||||
|
2.1.2.0 | Nov 9, 2018 | <ul><li>Bug fix for IE11.</li><li>Added date query variables.</li><li>Added support for both result id and query template.</li><li>Added `getUniqueCount` helper function.</li></ul>
|
||||||
|
|
||||||
## Disclaimer
|
## 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.**
|
**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.**
|
||||||
|
@ -133,6 +134,10 @@ The following custom query variables are supported:
|
||||||
|
|
||||||
* {Page.<column>} - where column is the internal name of the column.
|
* {Page.<column>} - where column is the internal name of the column.
|
||||||
* When used with taxonomy columns, use `{Page.Column.Label}` or `{Page.Column.TermID}`
|
* When used with taxonomy columns, use `{Page.Column.Label}` or `{Page.Column.TermID}`
|
||||||
|
* {CurrentYear} - Todays's date four digits, 2018
|
||||||
|
* {CurrentMonth} - Today's month, 1-12
|
||||||
|
* {CurrentDate} - Today's date, 1-31
|
||||||
|
* Sample query template: {searchTerms} Write>2010-{CurrentMonth}-{CurrentDate}
|
||||||
|
|
||||||
#### Best bets
|
#### Best bets
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"solution": {
|
"solution": {
|
||||||
"name": "PnP - Search Web Parts",
|
"name": "PnP - Search Web Parts",
|
||||||
"id": "890affef-33e0-4d72-bd72-36399e02143b",
|
"id": "890affef-33e0-4d72-bd72-36399e02143b",
|
||||||
"version": "2.1.1.0",
|
"version": "2.1.2.0",
|
||||||
"includeClientSideAssets": true,
|
"includeClientSideAssets": true,
|
||||||
"skipFeatureDeployment": false,
|
"skipFeatureDeployment": false,
|
||||||
"features": [
|
"features": [
|
||||||
|
|
|
@ -82,12 +82,12 @@ class SearchService implements ISearchService {
|
||||||
|
|
||||||
if (this._resultSourceId) {
|
if (this._resultSourceId) {
|
||||||
searchQuery.SourceId = this._resultSourceId;
|
searchQuery.SourceId = this._resultSourceId;
|
||||||
} else {
|
|
||||||
// To be able to use search query variable according to the current context
|
|
||||||
// http://www.techmikael.com/2015/07/sharepoint-rest-do-support-query.html
|
|
||||||
searchQuery.QueryTemplate = this._queryTemplate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To be able to use search query variable according to the current context
|
||||||
|
// http://www.techmikael.com/2015/07/sharepoint-rest-do-support-query.html
|
||||||
|
searchQuery.QueryTemplate = this._queryTemplate;
|
||||||
|
|
||||||
searchQuery.RowLimit = this._resultsCount ? this._resultsCount : 50;
|
searchQuery.RowLimit = this._resultsCount ? this._resultsCount : 50;
|
||||||
searchQuery.SelectProperties = this._selectedProperties;
|
searchQuery.SelectProperties = this._selectedProperties;
|
||||||
searchQuery.TrimDuplicates = false;
|
searchQuery.TrimDuplicates = false;
|
||||||
|
|
|
@ -129,7 +129,7 @@ export default class SearchResultsWebPart extends BaseClientSideWebPart<ISearchR
|
||||||
resizable: true,
|
resizable: true,
|
||||||
placeholder: strings.SearchQueryPlaceHolderText,
|
placeholder: strings.SearchQueryPlaceHolderText,
|
||||||
deferredValidationTime: 300,
|
deferredValidationTime: 300,
|
||||||
disabled: this._useResultSource,
|
//disabled: this._useResultSource,
|
||||||
}),
|
}),
|
||||||
PropertyPaneTextField('resultSourceId', {
|
PropertyPaneTextField('resultSourceId', {
|
||||||
label: strings.ResultSourceIdLabel,
|
label: strings.ResultSourceIdLabel,
|
||||||
|
@ -768,6 +768,17 @@ export default class SearchResultsWebPart extends BaseClientSideWebPart<ISearchR
|
||||||
match = pagePropsVariables.exec(reQueryTemplate);
|
match = pagePropsVariables.exec(reQueryTemplate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const currentDate = /\{CurrentDate\}/gi;
|
||||||
|
const currentMonth = /\{CurrentMonth\}/gi;
|
||||||
|
const currentYear = /\{CurrentYear\}/gi;
|
||||||
|
|
||||||
|
const d = new Date();
|
||||||
|
queryTemplate = queryTemplate.replace(currentDate, d.getDate().toString());
|
||||||
|
queryTemplate = queryTemplate.replace(currentMonth, (d.getMonth()+1).toString());
|
||||||
|
queryTemplate = queryTemplate.replace(currentYear, d.getFullYear().toString());
|
||||||
|
|
||||||
return queryTemplate;
|
return queryTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue