Merge pull request #1688 from albegut/master
|
@ -0,0 +1,25 @@
|
||||||
|
# EditorConfig helps developers define and maintain consistent
|
||||||
|
# coding styles between different editors and IDEs
|
||||||
|
# editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
|
||||||
|
[*]
|
||||||
|
|
||||||
|
# change these settings to your own preference
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# we recommend you to keep these unchanged
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[{package,bower}.json]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Build generated files
|
||||||
|
dist
|
||||||
|
lib
|
||||||
|
solution
|
||||||
|
temp
|
||||||
|
*.sppkg
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# OSX
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Visual Studio files
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
.vs
|
||||||
|
bin
|
||||||
|
obj
|
||||||
|
|
||||||
|
# Resx Generated Code
|
||||||
|
*.resx.ts
|
||||||
|
|
||||||
|
# Styles Generated Code
|
||||||
|
*.scss.ts
|
||||||
|
*.scss.d.ts
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"validations": {
|
||||||
|
"vulnerableDependencies": true,
|
||||||
|
"uncommittedChanges": true,
|
||||||
|
"untrackedFiles": false,
|
||||||
|
"sensitiveData": true,
|
||||||
|
"branch": "master",
|
||||||
|
"gitTag": false
|
||||||
|
},
|
||||||
|
"confirm": true,
|
||||||
|
"publishCommand": "npm publish",
|
||||||
|
"publishTag": "latest",
|
||||||
|
"prePublishScript": false,
|
||||||
|
"postPublishScript": false
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"@microsoft/generator-sharepoint": {
|
||||||
|
"version": "1.11.0",
|
||||||
|
"libraryName": "list-search-webpart",
|
||||||
|
"libraryId": "8277f088-9c30-4f95-9c15-9c18a9d40a26",
|
||||||
|
"environment": "spo",
|
||||||
|
"packageManager": "npm",
|
||||||
|
"isCreatingSolution": false,
|
||||||
|
"isDomainIsolated": false,
|
||||||
|
"componentType": "webpart"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
# List Search
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This list search web part allows the user to show data from lists or libraries. The web part can be used to (for more details see images below):
|
||||||
|
* [Show merged items from diferents lists/libraries](#merge-items-from-different-listslibraries)
|
||||||
|
* [Open item data in modal window (same data shown in the table)](#merge-items-from-different-listslibraries)
|
||||||
|
* [Select render by field type](#select-render-of-the-selected-fields)
|
||||||
|
* [Open item detail in modal window (it allows to select the fields to show by list)](#open-selected-item-with-selected-properties)
|
||||||
|
* [Open documents in modal window](#open-documents-in-modal-window)
|
||||||
|
* [Open documents in new tab](#open-documents-in-new-tab)
|
||||||
|
* [Use of dynamic data](#use-of-dynamic-data)
|
||||||
|
* [Redirect to url](#redirect-to-url-depends-on-selected-item)
|
||||||
|
|
||||||
|
* Other useful functionalities:
|
||||||
|
* General filter - the user can select which columns are filtered and which not
|
||||||
|
* Column filter on each column
|
||||||
|
* Item limit to show
|
||||||
|
* Item pagination
|
||||||
|
* Group items by any field
|
||||||
|
* Cache to retrieve the items
|
||||||
|
* Get section color
|
||||||
|
* Show item count with custom message
|
||||||
|
|
||||||
|
#### Merge items from different lists/libraries
|
||||||
|
|
||||||
|
![Merge items from different lists/libraries](assets/differentSources.gif)
|
||||||
|
|
||||||
|
#### Select render of the selected fields
|
||||||
|
|
||||||
|
![Select render of the selected fields](assets/selectFieldRenderType.gif)
|
||||||
|
|
||||||
|
#### Open documents in modal window
|
||||||
|
|
||||||
|
![Open documents in modal window](assets/docInModal.gif)
|
||||||
|
|
||||||
|
#### Open documents in new tab
|
||||||
|
|
||||||
|
![Open documents in new tab](assets/docInNewTab.gif)
|
||||||
|
|
||||||
|
#### Use of dynamic data
|
||||||
|
|
||||||
|
![Use of dynamic data](assets/dynamicData.gif)
|
||||||
|
|
||||||
|
#### Open selected item with same data
|
||||||
|
|
||||||
|
![Open selected item with same data](assets/itemCurrentData.gif)
|
||||||
|
|
||||||
|
#### Open selected item with selected properties
|
||||||
|
|
||||||
|
![Open selected item with selected properties](assets/itemSelectedData.gif)
|
||||||
|
|
||||||
|
#### Redirect to url depends on selected item
|
||||||
|
|
||||||
|
![Redirect to url depends on selected item](assets/redirectToUrl.gif)
|
||||||
|
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
![SPFx 1.11](https://img.shields.io/badge/SPFx-1.11.0-green.svg)
|
||||||
|
![Node.js LTS 10.x](https://img.shields.io/badge/Node.js-LTS%2010.x-green.svg)
|
||||||
|
![SharePoint Online](https://img.shields.io/badge/SharePoint-Online-yellow.svg)
|
||||||
|
![Teams N/A: Untested with Microsoft Teams](https://img.shields.io/badge/Teams-N%2FA-lightgrey.svg "Untested with Microsoft Teams")
|
||||||
|
![Workbench Local | Hosted](https://img.shields.io/badge/Workbench-Local%20%7C%20Hosted-green.svg)
|
||||||
|
|
||||||
|
|
||||||
|
## Applies to
|
||||||
|
|
||||||
|
* [SharePoint Framework](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
|
||||||
|
* [Office 365 tenant](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
Solution|Author(s)
|
||||||
|
--------|---------
|
||||||
|
react-list-search | Alberto Gutiérrez ([@albertogperez](https://twitter.com/albertogperez))
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
Version|Date|Comments
|
||||||
|
-------|----|--------
|
||||||
|
1.0|December 20, 2020|Initial release
|
||||||
|
|
||||||
|
## 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.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Minimal Path to Awesome
|
||||||
|
|
||||||
|
### Dev Mode
|
||||||
|
|
||||||
|
* Clone this repository
|
||||||
|
* In the command line run:
|
||||||
|
* Navigate to `list-search-webpart`
|
||||||
|
* `npm install`
|
||||||
|
* `gulp serve`
|
||||||
|
* Open the *workbench* on your Office 365 Developer tenant
|
||||||
|
* Test out the web part
|
||||||
|
|
||||||
|
### Sppkg
|
||||||
|
|
||||||
|
* Download `.sppkg` files from `sppkg` folder
|
||||||
|
* Upload files to **App Catalog**
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
This Web Part illustrates the following concepts on top of the SharePoint Framework:
|
||||||
|
|
||||||
|
* Using react for building SharePoint Framework client-side web parts
|
||||||
|
* Using [PnP Js](https://pnp.github.io/pnpjs) to retrieve SharePoint data
|
||||||
|
* Using [PnP Js](https://pnp.github.io/pnpjs/odata/caching) to cache SharePoint data
|
||||||
|
* Connection between SharePoint Framework components using dynamic data
|
||||||
|
* [Support of section backgrounds color ](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/supporting-section-backgrounds)
|
||||||
|
* [Custom property pane control](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/build-custom-property-pane-controls)
|
||||||
|
* Use [react-js-pagination](https://www.npmjs.com/package/react-js-pagination) library
|
||||||
|
|
||||||
|
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-list-search" />
|
After Width: | Height: | Size: 592 KiB |
After Width: | Height: | Size: 2.3 MiB |
After Width: | Height: | Size: 1.7 MiB |
After Width: | Height: | Size: 277 KiB |
After Width: | Height: | Size: 528 KiB |
After Width: | Height: | Size: 461 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 4.9 MiB |
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||||
|
"version": "2.0",
|
||||||
|
"bundles": {
|
||||||
|
"list-search-web-part": {
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"entrypoint": "./lib/webparts/listSearch/ListSearchWebPart.js",
|
||||||
|
"manifest": "./src/webparts/listSearch/ListSearchWebPart.manifest.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"list-search-consumer-web-part-web-part": {
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"entrypoint": "./lib/webparts/listSearchConsumerWebPart/ListSearchConsumerWebPartWebPart.js",
|
||||||
|
"manifest": "./src/webparts/listSearchConsumerWebPart/ListSearchConsumerWebPartWebPart.manifest.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"externals": {},
|
||||||
|
"localizedResources": {
|
||||||
|
"ListSearchWebPartStrings": "lib/webparts/listSearch/loc/{locale}.js",
|
||||||
|
"PropertyControlStrings": "node_modules/@pnp/spfx-property-controls/lib/loc/{locale}.js",
|
||||||
|
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js",
|
||||||
|
"ListSearchConsumerWebPartWebPartStrings": "lib/webparts/listSearchConsumerWebPart/loc/{locale}.js"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||||
|
"deployCdnPath": "temp/deploy"
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||||
|
"workingDir": "./temp/deploy/",
|
||||||
|
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||||
|
"container": "list-search-webpart",
|
||||||
|
"accessKey": "<!-- ACCESS KEY -->"
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||||
|
"solution": {
|
||||||
|
"name": "list-search-webpart",
|
||||||
|
"id": "8277f088-9c30-4f95-9c15-9c18a9d40a26",
|
||||||
|
"version": "1.0.0.0",
|
||||||
|
"includeClientSideAssets": true,
|
||||||
|
"skipFeatureDeployment": true,
|
||||||
|
"isDomainIsolated": false,
|
||||||
|
"developer": {
|
||||||
|
"name": "Alberto Gutierrez Perez",
|
||||||
|
"websiteUrl": "",
|
||||||
|
"privacyUrl": "",
|
||||||
|
"termsOfUseUrl": "",
|
||||||
|
"mpnId": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"zippedPackage": "solution/list-search-webpart.sppkg"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||||
|
"port": 4321,
|
||||||
|
"https": true,
|
||||||
|
"initialPage": "https://localhost:5432/workbench",
|
||||||
|
"api": {
|
||||||
|
"port": 5432,
|
||||||
|
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||||
|
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const build = require('@microsoft/sp-build-web');
|
||||||
|
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||||
|
|
||||||
|
const argv = build.rig.getYargs().argv;
|
||||||
|
const useCustomServe = argv['custom-serve'];
|
||||||
|
const fs = require("fs");
|
||||||
|
const workbenchApi = require("@microsoft/sp-webpart-workbench/lib/api");
|
||||||
|
|
||||||
|
if (useCustomServe) {
|
||||||
|
build.tslintCmd.enabled = false;
|
||||||
|
|
||||||
|
const ensureWorkbenchSubtask = build.subTask('ensure-workbench-task', function (gulp, buildOptions, done) {
|
||||||
|
this.log('Creating workbench.html file...');
|
||||||
|
try {
|
||||||
|
workbenchApi.default["/workbench"]();
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
build.rig.addPostBuildTask(build.task('ensure-workbench', ensureWorkbenchSubtask));
|
||||||
|
|
||||||
|
build.configureWebpack.mergeConfig({
|
||||||
|
additionalConfiguration: (generatedConfiguration) => {
|
||||||
|
fs.writeFileSync("./temp/_webpack_config.json", JSON.stringify(generatedConfiguration, null, 2));
|
||||||
|
return generatedConfiguration;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
build.initialize(require('gulp'));
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
"name": "list-search-webpart",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "gulp bundle",
|
||||||
|
"clean": "gulp clean",
|
||||||
|
"test": "gulp test",
|
||||||
|
"alldebug": "gulp clean && gulp build && gulp bundle && gulp serve",
|
||||||
|
"allpackage": "gulp clean && gulp build --ship && gulp bundle --ship && gulp package-solution --ship",
|
||||||
|
"serve": "cross-env NODE_OPTIONS=--max_old_space_size=4096 gulp bundle --custom-serve && cross-env NODE_OPTIONS=--max_old_space_size=4096 webpack-dev-server --mode development --config ./webpack.js --env.env=dev",
|
||||||
|
"publish-please": "publish-please",
|
||||||
|
"prepublishOnly": "publish-please guard"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@microsoft/sp-core-library": "1.11.0",
|
||||||
|
"@microsoft/sp-lodash-subset": "1.11.0",
|
||||||
|
"@microsoft/sp-office-ui-fabric-core": "1.11.0",
|
||||||
|
"@microsoft/sp-property-pane": "1.11.0",
|
||||||
|
"@microsoft/sp-webpart-base": "1.11.0",
|
||||||
|
"@pnp/sp": "2.0.8",
|
||||||
|
"@pnp/spfx-controls-react": "1.19.0",
|
||||||
|
"@pnp/spfx-property-controls": "1.19.0",
|
||||||
|
"react-js-pagination": "3.0.3",
|
||||||
|
"react-xml-parser": "1.1.6",
|
||||||
|
"react": "16.8.5",
|
||||||
|
"react-dom": "16.8.5",
|
||||||
|
"office-ui-fabric-react": "7.155.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@microsoft/sp-build-web": "1.11.0",
|
||||||
|
"@microsoft/sp-tslint-rules": "1.11.0",
|
||||||
|
"@microsoft/sp-module-interfaces": "1.11.0",
|
||||||
|
"@microsoft/sp-webpart-workbench": "1.11.0",
|
||||||
|
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
|
||||||
|
"gulp": "~3.9.1",
|
||||||
|
"@types/chai": "3.4.34",
|
||||||
|
"@types/mocha": "2.2.38",
|
||||||
|
"ajv": "~5.2.2",
|
||||||
|
"@types/webpack-env": "1.13.1",
|
||||||
|
"@types/es6-promise": "0.0.33",
|
||||||
|
"css-loader": "3.4.2",
|
||||||
|
"css-modules-typescript-loader": "4.0.0",
|
||||||
|
"fork-ts-checker-webpack-plugin": "4.1.0",
|
||||||
|
"node-sass": "4.13.1",
|
||||||
|
"sass-loader": "8.0.2",
|
||||||
|
"style-loader": "1.1.3",
|
||||||
|
"ts-loader": "6.2.1",
|
||||||
|
"webpack": "4.42.0",
|
||||||
|
"webpack-cli": "3.3.11",
|
||||||
|
"webpack-dev-server": "3.10.3",
|
||||||
|
"del": "5.1.0",
|
||||||
|
"cross-env": "7.0.2",
|
||||||
|
"@types/react": "16.8.8",
|
||||||
|
"@types/react-dom": "16.8.3"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||||
|
"id": "292daaa0-2474-445b-98f8-afa6ad4a9c92",
|
||||||
|
"alias": "ListSearchWebPart",
|
||||||
|
"componentType": "WebPart",
|
||||||
|
|
||||||
|
// The "*" signifies that the version should be taken from the package.json
|
||||||
|
"version": "*",
|
||||||
|
"manifestVersion": 2,
|
||||||
|
"supportsThemeVariants": true,
|
||||||
|
|
||||||
|
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||||
|
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||||
|
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||||
|
"requiresCustomScript": false,
|
||||||
|
"supportedHosts": ["SharePointWebPart", "SharePointFullPage"],
|
||||||
|
|
||||||
|
"preconfiguredEntries": [{
|
||||||
|
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||||
|
"group": { "default": "Other" },
|
||||||
|
"title": { "default": "list-search" },
|
||||||
|
"description": { "default": "SharePoitn list search custom webpart" },
|
||||||
|
"officeFabricIconFontName": "PageListFilter",
|
||||||
|
"properties": {
|
||||||
|
"description": "list-search"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||||
|
.listSearch {
|
||||||
|
@include ms-Grid;
|
||||||
|
.row {
|
||||||
|
@include ms-Grid-row;
|
||||||
|
}
|
||||||
|
.column {
|
||||||
|
@include ms-Grid-col;
|
||||||
|
@include ms-sm12;
|
||||||
|
@include ms-lg12;
|
||||||
|
.rowTopInformation {
|
||||||
|
@include ms-Grid-row;
|
||||||
|
.ColGeneralFilterWithBtn {
|
||||||
|
margin-top: 5px;
|
||||||
|
@include ms-Grid-col;
|
||||||
|
@include ms-lg10;
|
||||||
|
@include ms-sm12;
|
||||||
|
}
|
||||||
|
.ColGeneralFilterOnly {
|
||||||
|
margin-top: 5px;
|
||||||
|
@include ms-Grid-col;
|
||||||
|
@include ms-lg12;
|
||||||
|
@include ms-sm12;
|
||||||
|
}
|
||||||
|
.ColClearAll {
|
||||||
|
margin-top: 5px;
|
||||||
|
@include ms-Grid-col;
|
||||||
|
@include ms-lg2;
|
||||||
|
@include ms-sm12;
|
||||||
|
.btn {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.rowData {
|
||||||
|
@include ms-Grid-row;
|
||||||
|
.colData {
|
||||||
|
@include ms-Grid-col;
|
||||||
|
@include ms-lg12;
|
||||||
|
@include ms-sm12;
|
||||||
|
padding-top: 16px;
|
||||||
|
.template_resultCount {
|
||||||
|
padding-left: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
@include ms-fontWeight-semibold;
|
||||||
|
}
|
||||||
|
.paginationContainer {
|
||||||
|
margin: 0;
|
||||||
|
&__paginationContainer {
|
||||||
|
text-align: center;
|
||||||
|
&__pagination {
|
||||||
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
.inverted a {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.standard a {
|
||||||
|
color: "[theme: themePrimary, default: #005a9e]";
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
display: inline-block;
|
||||||
|
padding-left: 0;
|
||||||
|
margin: 0;
|
||||||
|
li {
|
||||||
|
display: inline;
|
||||||
|
a {
|
||||||
|
float: left;
|
||||||
|
padding: 5px 5px;
|
||||||
|
text-decoration: none;
|
||||||
|
i {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.active {
|
||||||
|
font-weight: 700;
|
||||||
|
color: "[theme: themeDark, default: #005a9e]";
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.active__inverted {
|
||||||
|
font-weight: 700;
|
||||||
|
color: #ffffff;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
a:visited {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.containerModal {
|
||||||
|
display: 'flex';
|
||||||
|
flex-flow: 'column nowrap';
|
||||||
|
align-items: 'stretch';
|
||||||
|
max-width: 1200px;
|
||||||
|
.headerModal {
|
||||||
|
@include ms-fontWeight-bold;
|
||||||
|
flex: '1 1 auto';
|
||||||
|
border-top: 4px solid;
|
||||||
|
color: $ms-color-themePrimary;
|
||||||
|
align-items: 'center';
|
||||||
|
font-size: x-large;
|
||||||
|
padding-right: 12px;
|
||||||
|
}
|
||||||
|
.bodyModal {
|
||||||
|
padding: 0 24px 24px 24px;
|
||||||
|
.propertyModal {
|
||||||
|
padding: 10px 0;
|
||||||
|
@include ms-fontWeight-bold;
|
||||||
|
color: $ms-color-themePrimary;
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.collectionDataField {
|
||||||
|
> span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div[class^="invalid_"] {
|
||||||
|
border-color: #a80000 !important;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
import { WebPartContext } from "@microsoft/sp-webpart-base";
|
||||||
|
import { IMappingFieldData, IListData, IDetailListFieldData, ICompleteModalData, IRedirectData } from "../model/IListConfigProps";
|
||||||
|
import { IPropertyFieldSite, } from '@pnp/spfx-property-controls/lib/PropertyFieldSitePicker';
|
||||||
|
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||||
|
import { SharePointType } from "../model/ISharePointFieldTypes";
|
||||||
|
import { IModalType } from "../model/IModalType";
|
||||||
|
import { IDynamicItem } from "../model/IDynamicItem";
|
||||||
|
|
||||||
|
|
||||||
|
export interface IListSearchProps {
|
||||||
|
Context: WebPartContext;
|
||||||
|
detailListFieldsCollectionData: Array<IDetailListFieldData>;
|
||||||
|
mappingFieldsCollectionData: Array<IMappingFieldData>;
|
||||||
|
listsCollectionData: Array<IListData>;
|
||||||
|
ShowListName: boolean;
|
||||||
|
ShowFileIcon: boolean;
|
||||||
|
ListNameTitle: string;
|
||||||
|
ShowSite: boolean;
|
||||||
|
SiteNameTitle: string;
|
||||||
|
SiteNamePropertyToShow: string;
|
||||||
|
GeneralFilter: boolean;
|
||||||
|
GeneralFilterPlaceHolderText: string;
|
||||||
|
GeneralSearcheableFields: Array<IDetailListFieldData>;
|
||||||
|
IndividualColumnFilter: boolean;
|
||||||
|
IndividualFilterPosition: string[];
|
||||||
|
ShowClearAllFilters: boolean;
|
||||||
|
ClearAllFiltersBtnColor: string;
|
||||||
|
ClearAllFiltersBtnText: string;
|
||||||
|
Sites: IPropertyFieldSite[];
|
||||||
|
ShowItemCount: boolean;
|
||||||
|
ItemCountText: string;
|
||||||
|
ItemLimit: number;
|
||||||
|
ShowPagination: boolean;
|
||||||
|
ItemsInPage: number;
|
||||||
|
themeVariant: IReadonlyTheme | undefined;
|
||||||
|
UseCache: boolean;
|
||||||
|
minutesToCache: number;
|
||||||
|
clickEnabled: boolean;
|
||||||
|
ModalType: IModalType;
|
||||||
|
completeModalFields: Array<ICompleteModalData>;
|
||||||
|
redirectData: Array<IRedirectData>;
|
||||||
|
onRedirectIdQuery: string;
|
||||||
|
onSelectedItem: (item: IDynamicItem) => void;
|
||||||
|
oneClickOption: boolean;
|
||||||
|
groupByField: string;
|
||||||
|
groupByFieldType: SharePointType;
|
||||||
|
AnyCamlQuery: boolean;
|
||||||
|
CacheType: "session" | "local";
|
||||||
|
generalFilterText: string;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
import { IColumn } from 'office-ui-fabric-react';
|
||||||
|
import IResult from '../model/IResult';
|
||||||
|
import { SharePointType } from '../model/ISharePointFieldTypes';
|
||||||
|
|
||||||
|
export interface IListSearchState {
|
||||||
|
isLoading: boolean;
|
||||||
|
errorMsg: string;
|
||||||
|
errorHeader: string;
|
||||||
|
items: Array<IResult>;
|
||||||
|
filterItems: Array<IResult>;
|
||||||
|
generalFilter: string;
|
||||||
|
columnFilters: IColumnFilter[];
|
||||||
|
activePage: number;
|
||||||
|
isModalHidden: boolean;
|
||||||
|
isModalLoading: boolean;
|
||||||
|
selectedItem: IResult;
|
||||||
|
completeModalItemData: IResult;
|
||||||
|
groupedItems: IGroupedItems[];
|
||||||
|
columns: IColumn[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default interface IGroupedItems {
|
||||||
|
GroupName: string;
|
||||||
|
Items: IResult[];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface IColumnFilter {
|
||||||
|
columnName: string;
|
||||||
|
filterToApply: string;
|
||||||
|
columnType: SharePointType;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import { Dropdown } from 'office-ui-fabric-react/lib/components/Dropdown';
|
||||||
|
import { ICustomCollectionField } from '@pnp/spfx-property-controls/lib/PropertyFieldCollectionData';
|
||||||
|
import { IPropertyPaneDropdownOption } from '@microsoft/sp-property-pane';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default class CustomCheckBox {
|
||||||
|
private static getCustomCollectionDropDown(options: IPropertyPaneDropdownOption[], field: ICustomCollectionField, row: any, updateFunction: any, errorFunction?: any, customOnchangeFunction?: any): JSX.Element {
|
||||||
|
return (<Dropdown placeholder={field.placeholder || field.title}
|
||||||
|
options={options.sort((a, b) => { return a.text.localeCompare(b.text); })}
|
||||||
|
selectedKey={row[field.id] || null}
|
||||||
|
required={field.required}
|
||||||
|
onChange={(evt, option, index) => customOnchangeFunction ? customOnchangeFunction(row, field.id, option, updateFunction, errorFunction) : updateFunction(field.id, option.key)}
|
||||||
|
onRenderOption={field.onRenderOption}
|
||||||
|
className="PropertyFieldCollectionData__panel__dropdown-field" />);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import { Dropdown } from 'office-ui-fabric-react/lib/components/Dropdown';
|
||||||
|
import { ICustomCollectionField } from '@pnp/spfx-property-controls/lib/PropertyFieldCollectionData';
|
||||||
|
import { TextField } from 'office-ui-fabric-react/lib/components/TextField';
|
||||||
|
import { IMappingFieldData, IListData, ICustomOption, SiteList, ListField, IBaseFieldData } from '../model/IListConfigProps';
|
||||||
|
import { IPropertyPaneDropdownOption } from '@microsoft/sp-property-pane';
|
||||||
|
import styles from '../ListSearchWebPart.module.scss';
|
||||||
|
import { Checkbox } from 'office-ui-fabric-react/lib/components/Checkbox';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default class CustomCollectionDataField {
|
||||||
|
private static getCustomCollectionDropDown(options: IPropertyPaneDropdownOption[], field: ICustomCollectionField, row: any, updateFunction: (fieldId: string, value: any) => void, errorFunction?: (fieldId: string, value: string) => void, customOnchangeFunction?: any): JSX.Element {
|
||||||
|
return (<Dropdown placeholder={field.placeholder || field.title}
|
||||||
|
options={options.sort((a, b) => { return a.text.localeCompare(b.text); })}
|
||||||
|
selectedKey={row[field.id] || null}
|
||||||
|
required={field.required}
|
||||||
|
onChange={(evt, option, index) => customOnchangeFunction ? customOnchangeFunction(row, field.id, option, updateFunction, errorFunction) : updateFunction(field.id, option.key)}
|
||||||
|
onRenderOption={field.onRenderOption}
|
||||||
|
className="PropertyFieldCollectionData__panel__dropdown-field" />);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getListPickerBySiteOptions(possibleOptions: Array<IListData>, field: ICustomCollectionField, row: any, updateFunction: (fieldId: string, value: any) => void, customOnChange?: any): JSX.Element {
|
||||||
|
let currentOptions = [];
|
||||||
|
possibleOptions.filter(option => {
|
||||||
|
if (row.SiteCollectionSource && option.SiteCollectionSource == row.SiteCollectionSource) {
|
||||||
|
currentOptions.push({
|
||||||
|
key: option.ListSourceField,
|
||||||
|
text: option.ListSourceFieldName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this.getCustomCollectionDropDown(currentOptions, field, row, updateFunction, null, customOnChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getListPicker(possibleOptions: Array<SiteList>, field: ICustomCollectionField, row: any, updateFunction: (fieldId: string, value: any) => void, customOnChange: any, customError?: (fieldId: string, value: string) => string): JSX.Element {
|
||||||
|
let options = [];
|
||||||
|
if (possibleOptions) {
|
||||||
|
options = possibleOptions.map(option => { return { key: option.Id, text: option.Title }; });
|
||||||
|
}
|
||||||
|
return this.getCustomCollectionDropDown(options, field, row, updateFunction, customError, customOnChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getPickerByStringOptions(possibleOptions: Array<string>, field: ICustomCollectionField, row: any, updateFunction: (fieldId: string, value: any) => void, customOnChange: any, customError?: (fieldId: string, value: string) => void): JSX.Element {
|
||||||
|
let options = [];
|
||||||
|
if (possibleOptions) {
|
||||||
|
options = possibleOptions.map(option => { return { key: option, text: option }; });
|
||||||
|
}
|
||||||
|
return this.getCustomCollectionDropDown(options, field, row, updateFunction, customError, customOnChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getFieldPickerByList(possibleOptions: Array<ListField>, field: ICustomCollectionField, row: any, updateFunction: (fieldId: string, value: any) => void, customOnchangeFunction?: any, customOptions?: Array<ICustomOption>): JSX.Element {
|
||||||
|
let options = [];
|
||||||
|
if (possibleOptions) {
|
||||||
|
options = possibleOptions.map(option => { return { key: option.InternalName, text: option.Title, title: option.InternalName, FieldType: option.TypeAsString }; });
|
||||||
|
}
|
||||||
|
if (customOptions) {
|
||||||
|
customOptions.map(option => {
|
||||||
|
options.push({
|
||||||
|
key: option.Key,
|
||||||
|
text: option.Option,
|
||||||
|
FieldType: option.CustomData
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return this.getCustomCollectionDropDown(options, field, row, updateFunction, null, customOnchangeFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getDisabledTextField(field: ICustomCollectionField, item: any, updateFunction: (fieldId: string, value: any) => void): JSX.Element {
|
||||||
|
return <TextField placeholder={field.placeholder || field.title
|
||||||
|
}
|
||||||
|
className={styles.collectionDataField}
|
||||||
|
value={item[field.id] ? item[field.id] : ""}
|
||||||
|
required={field.required}
|
||||||
|
disabled={true}
|
||||||
|
onChange={(value) => updateFunction(field.id, value)}
|
||||||
|
deferredValidationTime={field.deferredValidationTime || field.deferredValidationTime >= 0 ? field.deferredValidationTime : 200}
|
||||||
|
inputClassName="PropertyFieldCollectionData__panel__string-field" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getDisabledCheckBoxField(field: ICustomCollectionField, item: any, updateFunction: (fieldId: string, value: any) => void): JSX.Element {
|
||||||
|
return <Checkbox checked={item[field.id] ? item[field.id] : false}
|
||||||
|
onChange={(ev, value) => updateFunction(field.id, value)}
|
||||||
|
disabled={true}
|
||||||
|
className="PropertyFieldCollectionData__panel__boolean-field" />;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
//Code from https://kaboodlesoftware.com/2019/10/04/a-rather-useful-empty-spfx-property-pane-control/
|
||||||
|
import { IPropertyPaneField, PropertyPaneFieldType, IPropertyPaneCustomFieldProps } from "@microsoft/sp-property-pane";
|
||||||
|
|
||||||
|
export class EmptyPropertyPane implements IPropertyPaneField<any> {
|
||||||
|
|
||||||
|
public type: PropertyPaneFieldType = PropertyPaneFieldType.Custom;
|
||||||
|
public targetProperty: string;
|
||||||
|
public properties: IPropertyPaneCustomFieldProps;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.properties = {
|
||||||
|
onRender: this.onRender.bind(this),
|
||||||
|
key: "EmptyKey"
|
||||||
|
};
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
private onRender(elem: HTMLElement): void {
|
||||||
|
elem.innerHTML = `<div style='margin-top:-4px'></div>`;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
define([], function () {
|
||||||
|
return {
|
||||||
|
PropertyPaneDescription: "List Search general properties",
|
||||||
|
GeneralPropertiesGroup: "General Properties",
|
||||||
|
SourceSelectorGroup: "Source data",
|
||||||
|
SitesSelector: "Sites to get data",
|
||||||
|
ListSelector: "List to get the data",
|
||||||
|
ListSelectorLabel: "Select source lists",
|
||||||
|
ListSelectorPanelHeader: "Configure lists and queries to retrieve data",
|
||||||
|
CollectionDataSiteCollectionTitle: "Site Collection",
|
||||||
|
CollectionDataListTitle: "List",
|
||||||
|
CollectionDataListViewNameTitle: "List View Title",
|
||||||
|
CollectionDataListCamlQueryTitle: "CAML Query",
|
||||||
|
CollectionDataListCamlQueryPlaceHolder: "Empty - all elements",
|
||||||
|
GeneralPropertiesShowItemCount: "Show item count",
|
||||||
|
GeneralPropertiesRowLimitLabel: "Item limit to show",
|
||||||
|
GeneralPropertiesRowLimitDescription: "If 0 all items are render",
|
||||||
|
GeneralPropertiesShowPagination: "Show pagination",
|
||||||
|
GeneralPropertiesGroupByField: "Group elements",
|
||||||
|
FieldPropertiesGroup: "Fields",
|
||||||
|
CollectionDataFieldsProperties: "Lists Field Properties",
|
||||||
|
CollectionDataFieldsToRetreive: "Fields to retrieve",
|
||||||
|
CollectionDataFieldsSelectBtn: "Select fields",
|
||||||
|
CollectionDataFieldsHeader: "Select fields to retrieve and their mapping",
|
||||||
|
CollectionDataFieldsSiteCollection: "Site Collection",
|
||||||
|
CollectionDataFieldsList: "List",
|
||||||
|
CollectionDataFieldsListField: "List Field",
|
||||||
|
CollectionDataFieldsTargetField: "Detail list target column",
|
||||||
|
CollectionDataFieldsRenderType: "Render type",
|
||||||
|
CollectionDataFieldsOrder: "Order",
|
||||||
|
CollectionDataFieldTitle: "Configure display fields",
|
||||||
|
CollectionDataFieldHeader: "Configure the fields properties",
|
||||||
|
CollectionDataFieldsButton: "Configure fields",
|
||||||
|
CollectionDataFieldsSearchable: "Searcheable in general filter",
|
||||||
|
detailListFieldsColumnTitle: "Column Title",
|
||||||
|
detailListFieldsColumnMaxWidth: "Max column width",
|
||||||
|
detailListFieldsColumnMinWidth: "Min column width",
|
||||||
|
detailListFieldsIsSiteColumn: "Is Site info Column",
|
||||||
|
detailListFieldsIsListColumn: "Is List info Column",
|
||||||
|
detailListFieldsIsFileIconColumn: "Is File icon Column",
|
||||||
|
CollectionDataFieldsType: "Field render type",
|
||||||
|
DisplayFieldsPropertiesGroup: "Display Fields",
|
||||||
|
GeneralFieldsPropertiesShowListName: "Show list title",
|
||||||
|
GeneralFieldsPropertiesShowFileIcon: "Show file icon",
|
||||||
|
GeneralFieldsPropertiesShowSiteInformation: "Show site information",
|
||||||
|
FilterPropertiesGroup: "Filters",
|
||||||
|
FilterPropertiesGroupName: "Filters properties",
|
||||||
|
FilterPropertiesGeneralFilter: "General filter",
|
||||||
|
FilterPropertiesIndividualFilter: "Individual column filter",
|
||||||
|
FilterPropertiesClearAllBtn: "Show button to clear all filters",
|
||||||
|
GeneralFieldsPropertiesListDisplayName: "List column display name",
|
||||||
|
GeneralFieldsPropertiesListDisplayNameOrder: "List column display name order",
|
||||||
|
GeneralFieldsPropertiesListDisplayNameOrderDescription: "Order of list display name column",
|
||||||
|
GeneralFieldsPropertiesListDisplayNameSearcheable: "List title searchable in general filter",
|
||||||
|
GeneralFieldsPropertiesSiteDisplayName: "Site column display name",
|
||||||
|
GeneralFieldsPropertiesSiteProperty: "Site property to display",
|
||||||
|
GeneralFieldsPropertiesSiteDisplayNameOrder: "Site column display name order",
|
||||||
|
GeneralFieldsPropertiesSiteDisplayNameOrderDescription: "Order of site display name column",
|
||||||
|
GeneralFieldsPropertiesSiteDisplayNameSearcheable: "Site column searchable in general filter",
|
||||||
|
FilterPropertiesGeneralFilterPlaceHolder: "General filter placeholder",
|
||||||
|
FilterPropertiesIndividualFilterPostion: "Individual filters position",
|
||||||
|
FilterPropertiesClearAllBtnText: "Clear all button text",
|
||||||
|
FilterPropertiesClearAllBtnColor: "Clear all filters button color",
|
||||||
|
GeneralPropertiesItemCountText: "Item count text to display",
|
||||||
|
GeneralPropertiesItemCountPlaceholder: "Use {itemCount} to insert items count number",
|
||||||
|
GeneralPropertiesItemPerPage: "Items per page",
|
||||||
|
ListSearchLoading: "Loading...",
|
||||||
|
StoragePropertiesGroupName: "Cache",
|
||||||
|
UseLocalStorage: "Use cache",
|
||||||
|
MinutesToCacheData: "Time (minutes) to cache the retrieved data",
|
||||||
|
OnClickEvent: "Use on click event",
|
||||||
|
OnClickSimpleModalText: "Modal with current data",
|
||||||
|
OnClickCompleteModalText: "Modal with all item fields",
|
||||||
|
OnClickRedirectText: "Redirect to url",
|
||||||
|
OnClickDynamicText: "Dynamic data",
|
||||||
|
OnDocumentIframePreviewText: "Document modal preview",
|
||||||
|
OnDocumentNewTabPreviewText: "Document new tab preview",
|
||||||
|
OnClickOptionsToSelect: "Item on click behaviour",
|
||||||
|
OnclickRedirectIdText: "Item ID query param",
|
||||||
|
CompleteModalFieldSelector: "Select fields to show",
|
||||||
|
CompleteModalHeaderSelector: "Select fields to show in detail modal",
|
||||||
|
CompleteModalButton: "Configure modal fields",
|
||||||
|
CompleteModalFieldsSiteCollection: "Site Collection",
|
||||||
|
CompleteModalFieldsList: "List",
|
||||||
|
CompleteModalFieldsListField: "Source Field",
|
||||||
|
CompleteModalFieldsTargetField: "Display field title",
|
||||||
|
redirectDataFieldSelector: "Select urls to redirect",
|
||||||
|
redirectDataHeaderSelector: "For each list select the url to redirect",
|
||||||
|
redirectDataButton: "Configure redirect urls",
|
||||||
|
redirectDataFieldsSiteCollection: "Site Collection",
|
||||||
|
redirectDataFieldsList: "List",
|
||||||
|
redirectDataUrl: "Url",
|
||||||
|
OnClickNumberOfClickOptionsToSelect: "Trigger option",
|
||||||
|
OneClickTriggerText: "One click",
|
||||||
|
TwoClickTriggerText: "Two clicks",
|
||||||
|
InformationPropertiesGroupName: "Web part Information",
|
||||||
|
AboutPropertiesGroupName: "About",
|
||||||
|
OnClickPropertiesGroup: "On click Properties",
|
||||||
|
GroupFieldOptionsToSelect: "Field to group by",
|
||||||
|
LblCacheType: "Cache type",
|
||||||
|
LblErrorDiferentRender: "Selected target column has other render mapping type",
|
||||||
|
LblErrorSameColumn: "There are duplicate mappings from this target column and the selected field-list-Site Collection values",
|
||||||
|
GroupByEmptyValue: "Empty",
|
||||||
|
GeneralFilterConnection: 'Select query origin',
|
||||||
|
InitialSearchText: "Initial search query",
|
||||||
|
GeneralFilterInitialQueryEnabled: "Initial search enabled",
|
||||||
|
GeneralFilterInitialQueryOption: "Initial search type",
|
||||||
|
GeneralFilterInitialQueryTextValue: "Initial search value"
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,113 @@
|
||||||
|
declare interface IListSearchWebPartStrings {
|
||||||
|
PropertyPaneDescription: string;
|
||||||
|
GeneralPropertiesGroup: string;
|
||||||
|
SourceSelectorGroup: string;
|
||||||
|
SitesSelector: string;
|
||||||
|
ListSelector: string;
|
||||||
|
ListSelectorLabel: string;
|
||||||
|
ListSelectorPanelHeader: string;
|
||||||
|
CollectionDataSiteCollectionTitle: string;
|
||||||
|
CollectionDataListTitle: string;
|
||||||
|
CollectionDataListViewNameTitle: string;
|
||||||
|
CollectionDataListCamlQueryTitle: string;
|
||||||
|
CollectionDataListCamlQueryPlaceHolder: string;
|
||||||
|
GeneralPropertiesShowItemCount: string;
|
||||||
|
GeneralPropertiesRowLimitLabel: string;
|
||||||
|
GeneralPropertiesRowLimitDescription: string;
|
||||||
|
GeneralPropertiesShowPagination: string;
|
||||||
|
GeneralPropertiesGroupByField: string;
|
||||||
|
FieldPropertiesGroup: string;
|
||||||
|
CollectionDataFieldsProperties: string;
|
||||||
|
CollectionDataFieldsToRetreive: string;
|
||||||
|
CollectionDataFieldsSelectBtn: string;
|
||||||
|
CollectionDataFieldsHeader: string;
|
||||||
|
CollectionDataFieldsSiteCollection: string;
|
||||||
|
CollectionDataFieldsList: string;
|
||||||
|
CollectionDataFieldsListField: string;
|
||||||
|
CollectionDataFieldsTargetField: string;
|
||||||
|
CollectionDataFieldsRenderType: string;
|
||||||
|
CollectionDataFieldsOrder: string;
|
||||||
|
CollectionDataFieldsSearchable: string;
|
||||||
|
detailListFieldsColumnTitle: string;
|
||||||
|
detailListFieldsColumnMinWidth: string;
|
||||||
|
detailListFieldsColumnMaxWidth: string;
|
||||||
|
detailListFieldsIsSiteColumn: string;
|
||||||
|
detailListFieldsIsListColumn: string;
|
||||||
|
detailListFieldsIsFileIconColumn: string;
|
||||||
|
CollectionDataFieldsType: string;
|
||||||
|
DisplayFieldsPropertiesGroup: string;
|
||||||
|
GeneralFieldsPropertiesShowListName: string;
|
||||||
|
GeneralFieldsPropertiesShowFileIcon: string;
|
||||||
|
GeneralFieldsPropertiesShowSiteInformation: string;
|
||||||
|
FilterPropertiesGroup: string;
|
||||||
|
FilterPropertiesGroupName: string;
|
||||||
|
FilterPropertiesGeneralFilter: string;
|
||||||
|
FilterPropertiesIndividualFilter: string;
|
||||||
|
FilterPropertiesClearAllBtn: string;
|
||||||
|
GeneralFieldsPropertiesListDisplayName: string;
|
||||||
|
GeneralFieldsPropertiesListDisplayNameOrder: string;
|
||||||
|
GeneralFieldsPropertiesListDisplayNameOrderDescription: string;
|
||||||
|
GeneralFieldsPropertiesListDisplayNameSearcheable: string;
|
||||||
|
GeneralFieldsPropertiesSiteDisplayName: string;
|
||||||
|
GeneralFieldsPropertiesSiteProperty: string;
|
||||||
|
GeneralFieldsPropertiesSiteDisplayNameOrder: string;
|
||||||
|
GeneralFieldsPropertiesSiteDisplayNameOrderDescription: string;
|
||||||
|
GeneralFieldsPropertiesSiteDisplayNameSearcheable: string;
|
||||||
|
FilterPropertiesGeneralFilterPlaceHolder: string;
|
||||||
|
FilterPropertiesIndividualFilterPostion: string;
|
||||||
|
FilterPropertiesClearAllBtnText: string;
|
||||||
|
FilterPropertiesClearAllBtnColor: string;
|
||||||
|
GeneralPropertiesItemCountText: string;
|
||||||
|
GeneralPropertiesItemCountPlaceholder: string;
|
||||||
|
GeneralPropertiesItemPerPage: string;
|
||||||
|
ListSearchLoading: string;
|
||||||
|
StoragePropertiesGroupName: string;
|
||||||
|
UseLocalStorage: string;
|
||||||
|
MinutesToCacheData: string;
|
||||||
|
CollectionDataFieldTitle: string;
|
||||||
|
CollectionDataFieldHeader: string;
|
||||||
|
CollectionDataFieldsButton: string;
|
||||||
|
OnClickEvent: string;
|
||||||
|
OnClickSimpleModalText: string;
|
||||||
|
OnClickCompleteModalText: string;
|
||||||
|
OnClickRedirectText: string;
|
||||||
|
OnClickDynamicText: string;
|
||||||
|
OnDocumentIframePreviewText: string;
|
||||||
|
OnDocumentNewTabPreviewText: string;
|
||||||
|
OnClickOptionsToSelect: string;
|
||||||
|
OnclickRedirectIdText: string;
|
||||||
|
CompleteModalFieldSelector: string;
|
||||||
|
CompleteModalHeaderSelector: string;
|
||||||
|
CompleteModalButton: string;
|
||||||
|
CompleteModalFieldsSiteCollection: string;
|
||||||
|
CompleteModalFieldsList: string;
|
||||||
|
CompleteModalFieldsListField: string;
|
||||||
|
CompleteModalFieldsTargetField: string;
|
||||||
|
redirectDataFieldSelector: string;
|
||||||
|
redirectDataHeaderSelector: string;
|
||||||
|
redirectDataButton: string;
|
||||||
|
redirectDataFieldsSiteCollection: string;
|
||||||
|
redirectDataFieldsList: string;
|
||||||
|
redirectDataUrl: string;
|
||||||
|
OnClickNumberOfClickOptionsToSelect: string;
|
||||||
|
OneClickTriggerText: string;
|
||||||
|
TwoClickTriggerText: string;
|
||||||
|
InformationPropertiesGroupName: string;
|
||||||
|
AboutPropertiesGroupName: string;
|
||||||
|
OnClickPropertiesGroup: string;
|
||||||
|
GroupFieldOptionsToSelect: string;
|
||||||
|
LblCacheType: string;
|
||||||
|
LblErrorDiferentRender: string;
|
||||||
|
LblErrorSameColumn: string;
|
||||||
|
GroupByEmptyValue: string;
|
||||||
|
GeneralFilterConnection: string;
|
||||||
|
InitialSearchText: string;
|
||||||
|
GeneralFilterInitialQueryEnabled: string;
|
||||||
|
GeneralFilterInitialQueryOption: string;
|
||||||
|
GeneralFilterInitialQueryTextValue: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'ListSearchWebPartStrings' {
|
||||||
|
const strings: IListSearchWebPartStrings;
|
||||||
|
export = strings;
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
export interface ICamlQueryXml {
|
||||||
|
name: string;
|
||||||
|
attributes: IViewField | undefined;
|
||||||
|
value: string;
|
||||||
|
children: Array<ICamlQueryXml>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IViewQuery {
|
||||||
|
Query: string;
|
||||||
|
RowLimit: any;
|
||||||
|
ViewFields: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IViewField {
|
||||||
|
Name: string;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
export interface IDynamicItem {
|
||||||
|
// The URL of the web site where the selected item comes from
|
||||||
|
webUrl: string;
|
||||||
|
// The name of the list that contains the selected item
|
||||||
|
listId: string;
|
||||||
|
// The ID of the selected item
|
||||||
|
itemId: number;
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
import { SharePointType } from "./ISharePointFieldTypes";
|
||||||
|
|
||||||
|
export interface IListData {
|
||||||
|
SiteCollectionSource: string;
|
||||||
|
ListSourceField: string;
|
||||||
|
ListSourceFieldName: string; //Custom field to show list name in config dropdowns
|
||||||
|
ListView: string;
|
||||||
|
Query: string;
|
||||||
|
uniqueId: string;
|
||||||
|
sortIdx: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IBaseFieldData {
|
||||||
|
SiteCollectionSource: string;
|
||||||
|
ListSourceField: string;
|
||||||
|
SourceField: string;
|
||||||
|
TargetField: string;
|
||||||
|
SPFieldType: SharePointType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface IMappingFieldData extends IBaseFieldData {
|
||||||
|
ListSourceFieldName: string; //Custom field to show list name in config dropdowns
|
||||||
|
uniqueId: string;
|
||||||
|
Order: number;
|
||||||
|
sortIdx: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICompleteModalData extends IBaseFieldData {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IRedirectData {
|
||||||
|
SiteCollectionSource: string;
|
||||||
|
ListSourceField: string;
|
||||||
|
Url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ListField {
|
||||||
|
EntityPropertyName: string;
|
||||||
|
Title: string;
|
||||||
|
InternalName: string;
|
||||||
|
TypeAsString: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICustomOption {
|
||||||
|
Key: string;
|
||||||
|
Option: string;
|
||||||
|
CustomData: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SitesLists {
|
||||||
|
[siteName: string]: Array<SiteList>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SiteList {
|
||||||
|
Title: string;
|
||||||
|
Id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SitesFields {
|
||||||
|
[siteName: string]: Array<ListsFields>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ListsFields {
|
||||||
|
[listId: string]: Array<ListField>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class IDetailListFieldData {
|
||||||
|
|
||||||
|
constructor(IsSiteTitle: boolean, IsListTitle: boolean, IsFileIcon: boolean, ColumnTitle: string, MinColumnWidth: number, MaxColumnWidth: number, Searcheable: boolean) {
|
||||||
|
this.IsSiteTitle = IsSiteTitle;
|
||||||
|
this.IsListTitle = IsListTitle;
|
||||||
|
this.IsFileIcon = IsFileIcon;
|
||||||
|
this.ColumnTitle = ColumnTitle;
|
||||||
|
this.MinColumnWidth = MinColumnWidth;
|
||||||
|
this.MaxColumnWidth = MaxColumnWidth;
|
||||||
|
this.Searcheable = Searcheable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CreateListColumn(MinColumnWidth: number, MaxColumnWidth: number, Searcheable: boolean): IDetailListFieldData {
|
||||||
|
return new IDetailListFieldData(false, true, false, "ListName", MinColumnWidth, MaxColumnWidth, Searcheable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CreateSiteColumn(MinColumnWidth: number, MaxColumnWidth: number, Searcheable: boolean): IDetailListFieldData {
|
||||||
|
return new IDetailListFieldData(true, false, false, "Site", MinColumnWidth, MaxColumnWidth, Searcheable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CreateFileColumn(): IDetailListFieldData {
|
||||||
|
return new IDetailListFieldData(false, false, true, "FileIcon", 30, 30, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IsGeneralColumn(object: IDetailListFieldData): boolean {
|
||||||
|
return object.IsSiteTitle != false && object.IsListTitle != false && object.IsFileIcon != false; //undefined values are also general columns
|
||||||
|
}
|
||||||
|
|
||||||
|
public IsSiteTitle: boolean;
|
||||||
|
public IsListTitle: boolean;
|
||||||
|
public IsFileIcon: boolean;
|
||||||
|
public ColumnTitle: string;
|
||||||
|
public MinColumnWidth?: number;
|
||||||
|
public MaxColumnWidth?: number;
|
||||||
|
public Searcheable: boolean;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { SiteList } from "./IListConfigProps";
|
||||||
|
import { SharePointType } from "./ISharePointFieldTypes";
|
||||||
|
|
||||||
|
export interface IMapQuery {
|
||||||
|
[site: string]: Array<IMapQueryList>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMapQueryList {
|
||||||
|
[list: string]: Array<IListSearchListQuery>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IListSearchListQuery {
|
||||||
|
list: SiteList;
|
||||||
|
camlQuery?: string;
|
||||||
|
viewName?: string;
|
||||||
|
fields: Array<{ originalField: string, newField: string, fieldType: SharePointType }>;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
export enum IModalType{
|
||||||
|
Simple = "Simple",
|
||||||
|
Complete = "Complete",
|
||||||
|
Redirect = "Redirect",
|
||||||
|
DynamicData = "DynamicData",
|
||||||
|
DocumentIframePreview = "DocumentIframePreview",
|
||||||
|
DocumentNewTabPreview = "DocumentNewTabPreview"
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { SiteList } from "./IListConfigProps";
|
||||||
|
|
||||||
|
export default interface IResult {
|
||||||
|
FileExtension: string;
|
||||||
|
SiteUrl: string;
|
||||||
|
ListName: string; //Field to display list name in detail list
|
||||||
|
List: SiteList;
|
||||||
|
Id: number;
|
||||||
|
UniqueId: string;
|
||||||
|
ServerUrl: string;
|
||||||
|
FileLeafRef: string;
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface ISessionStorageElement
|
||||||
|
{
|
||||||
|
hasExpired:boolean;
|
||||||
|
elements: Array<any>;
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
export class SharePointFieldTypes {
|
||||||
|
|
||||||
|
public static GetSPFieldTypeByString(fieldTypeAsString: string): SharePointType {
|
||||||
|
let result: SharePointType = SharePointType.Text;
|
||||||
|
switch (fieldTypeAsString) {
|
||||||
|
case 'Text': {
|
||||||
|
result = SharePointType.Text;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Note': {
|
||||||
|
result = SharePointType.Note;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'NoteFullHtml': {
|
||||||
|
result = SharePointType.NoteFullHtml;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Choice': {
|
||||||
|
result = SharePointType.Choice;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'MultiChoice': {
|
||||||
|
result = SharePointType.ChoiceMulti;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Integer': {
|
||||||
|
result = SharePointType.Integer;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Number': {
|
||||||
|
result = SharePointType.Number;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Currency': {
|
||||||
|
result = SharePointType.Currency;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'DateTime': {
|
||||||
|
result = SharePointType.DateTime;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Lookup': {
|
||||||
|
result = SharePointType.Lookup;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'LookupMulti': {
|
||||||
|
result = SharePointType.LookupMulti;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Boolean': {
|
||||||
|
result = SharePointType.Boolean;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'User': {
|
||||||
|
result = SharePointType.User;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'UserMulti': {
|
||||||
|
result = SharePointType.UserMulti;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'URL': {
|
||||||
|
result = SharePointType.Url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Calculated': {
|
||||||
|
result = SharePointType.Computed;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Image': {
|
||||||
|
result = SharePointType.Image;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'TaxonomyFieldType': {
|
||||||
|
result = SharePointType.Taxonomy;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'TaxonomyFieldTypeMulti': {
|
||||||
|
result = SharePointType.TaxonomyMulti;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Attachments': {
|
||||||
|
result = SharePointType.Attachments;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Counter': {
|
||||||
|
result = SharePointType.Counter;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'ContentTypeId': {
|
||||||
|
result = SharePointType.ContentTypeId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'Guid': {
|
||||||
|
result = SharePointType.Guid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
result = SharePointType.Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GetSharePointTypesAsArray(): Array<string> {
|
||||||
|
return Object.keys(SharePointType).filter(element => element != 'FileIcon');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum SharePointType {
|
||||||
|
Text = "Text",
|
||||||
|
Note = "Note",
|
||||||
|
NoteFullHtml = "NoteFullHtml",
|
||||||
|
Choice = "Choice",
|
||||||
|
ChoiceMulti = "ChoiceMulti",
|
||||||
|
Integer = "Integer",
|
||||||
|
Number = "Number",
|
||||||
|
Currency = "Currency",
|
||||||
|
DateTime = "DateTime",
|
||||||
|
Date = "Date",
|
||||||
|
DateLongMonth = "DateLongMonth",
|
||||||
|
Lookup = "Lookup",
|
||||||
|
LookupMulti = "LookupMulti",
|
||||||
|
Boolean = "Boolean",
|
||||||
|
User = "User",
|
||||||
|
UserEmail = "User-Email",
|
||||||
|
UserName = "User-Name",
|
||||||
|
UserMulti = "UserMulti",
|
||||||
|
Url = "Url",
|
||||||
|
Image = "Image",
|
||||||
|
Taxonomy = "Taxonomy",
|
||||||
|
TaxonomyMulti = "TaxonomyMulti",
|
||||||
|
Computed = "Computed",
|
||||||
|
Attachments = "Attachments",
|
||||||
|
Counter = "Counter",
|
||||||
|
ContentTypeId = "ContentTypeId",
|
||||||
|
Guid = "Guid",
|
||||||
|
FileIcon = "FileIcon",
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export default interface IUrlField {
|
||||||
|
Url: string;
|
||||||
|
Description: string;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export default interface IUserField {
|
||||||
|
Name: string;
|
||||||
|
Email: string;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { ListField } from "../model/IListConfigProps";
|
||||||
|
import { IListSearchListQuery } from "../model/IMapQuery";
|
||||||
|
|
||||||
|
export default interface IListService {
|
||||||
|
getListItems(listQueryOptions: IListSearchListQuery, listPropertyName: string, sitePropertyName: string, sitePropertyValue: string, rowLimit: number): Promise<Array<any>>;
|
||||||
|
getListItemById(listQueryOptions: IListSearchListQuery, itemId: number): Promise<any>;
|
||||||
|
getSiteListsTitle(): Promise<Array<any>>;
|
||||||
|
getListFields(listTitle: string): Promise<Array<ListField>>;
|
||||||
|
}
|
|
@ -0,0 +1,323 @@
|
||||||
|
import { sp } from '@pnp/sp';
|
||||||
|
import '@pnp/sp/webs';
|
||||||
|
import "@pnp/sp/lists";
|
||||||
|
import "@pnp/sp/items";
|
||||||
|
import "@pnp/sp/views";
|
||||||
|
import "@pnp/sp/fields";
|
||||||
|
import IListService from "./IListService";
|
||||||
|
import { ICamlQuery } from "@pnp/sp/lists";
|
||||||
|
import { ICamlQueryXml } from '../model/ICamlQueryXml';
|
||||||
|
import XMLParser from 'react-xml-parser';
|
||||||
|
import { IWeb, Web } from '@pnp/sp/webs';
|
||||||
|
import { SharePointType } from '../model/ISharePointFieldTypes';
|
||||||
|
import IResult from '../model/IResult';
|
||||||
|
import { isEmpty } from '@microsoft/sp-lodash-subset';
|
||||||
|
import { ListField, SiteList } from '../model/IListConfigProps';
|
||||||
|
import { IListSearchListQuery } from '../model/IMapQuery';
|
||||||
|
|
||||||
|
|
||||||
|
export interface QueryHelperEntity {
|
||||||
|
viewFields: string[];
|
||||||
|
expandFields: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class ListService implements IListService {
|
||||||
|
private web: IWeb;
|
||||||
|
private baseUrl: string;
|
||||||
|
|
||||||
|
constructor(siteUrl: string, useCache: boolean, cacheTime?: number, cacheType?: "session" | "local") {
|
||||||
|
sp.setup({
|
||||||
|
defaultCachingStore: useCache ? cacheType : undefined,
|
||||||
|
defaultCachingTimeoutSeconds: useCache ? (cacheTime * 60) : undefined,
|
||||||
|
sp: {
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json;odata=nometadata'
|
||||||
|
},
|
||||||
|
baseUrl: siteUrl
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.web = Web(siteUrl);
|
||||||
|
this.baseUrl = siteUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GetViewFieldsWithId(listQueryOptions: IListSearchListQuery, isCamlQuery: boolean): QueryHelperEntity {
|
||||||
|
let result: QueryHelperEntity = { expandFields: [], viewFields: ['ServerUrl', 'FileLeafRef', 'Id', 'UniqueId'] };
|
||||||
|
let hasToAddFieldsAsText: boolean = false;
|
||||||
|
listQueryOptions.fields.map(field => {
|
||||||
|
switch (field.fieldType) {
|
||||||
|
case SharePointType.User:
|
||||||
|
case SharePointType.UserEmail:
|
||||||
|
case SharePointType.UserName:
|
||||||
|
case SharePointType.UserMulti:
|
||||||
|
if (isCamlQuery) {
|
||||||
|
hasToAddFieldsAsText = true;
|
||||||
|
result.viewFields.push(field.originalField);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.viewFields.push(`${field.originalField}/Title`);
|
||||||
|
result.viewFields.push(`${field.originalField}/Name`);
|
||||||
|
result.expandFields.push(`${field.originalField}`);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SharePointType.Lookup:
|
||||||
|
case SharePointType.LookupMulti:
|
||||||
|
if (isCamlQuery) {
|
||||||
|
hasToAddFieldsAsText = true;
|
||||||
|
result.viewFields.push(field.originalField);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.viewFields.push(`${field.originalField}/Title`);
|
||||||
|
result.expandFields.push(`${field.originalField}`);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SharePointType.Taxonomy:
|
||||||
|
if (isCamlQuery) {
|
||||||
|
hasToAddFieldsAsText = true;
|
||||||
|
result.viewFields.push(field.originalField);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!result.viewFields.find(e => e === "TaxCatchAll/Term")) {
|
||||||
|
result.viewFields.push("TaxCatchAll/Term");
|
||||||
|
}
|
||||||
|
if (!result.viewFields.find(e => e === "TaxCatchAll/ID")) {
|
||||||
|
result.viewFields.push("TaxCatchAll/ID");
|
||||||
|
}
|
||||||
|
result.viewFields.push(field.originalField);
|
||||||
|
result.expandFields.push("TaxCatchAll");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if (field.originalField != "ListName" && field.originalField != "SiteUrl") {
|
||||||
|
result.viewFields.push(field.originalField);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasToAddFieldsAsText) {
|
||||||
|
result.expandFields.push('FieldValuesAsText');
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GetItemValue(item: any, field: any, fromCamlQuery: boolean): any {
|
||||||
|
switch (field.fieldType) {
|
||||||
|
case SharePointType.Lookup:
|
||||||
|
case SharePointType.LookupMulti:
|
||||||
|
if (fromCamlQuery) {
|
||||||
|
item[field.newField] = item['FieldValuesAsText'][field.originalField];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item[field.newField] = item[field.originalField];
|
||||||
|
if (field.newField !== field.originalField) {
|
||||||
|
delete item[field.originalField];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SharePointType.User:
|
||||||
|
case SharePointType.UserEmail:
|
||||||
|
case SharePointType.UserName:
|
||||||
|
{
|
||||||
|
if (fromCamlQuery) {
|
||||||
|
item[field.newField] = item['FieldValuesAsText'][field.originalField];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item[field.newField] = item[field.originalField];
|
||||||
|
if (field.newField !== field.originalField) {
|
||||||
|
delete item[field.originalField];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SharePointType.UserMulti:
|
||||||
|
{
|
||||||
|
if (fromCamlQuery) {
|
||||||
|
item[field.newField] = item['FieldValuesAsText'][field.originalField];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item[field.newField] = item[field.originalField];
|
||||||
|
if (field.newField !== field.originalField) {
|
||||||
|
delete item[field.originalField];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SharePointType.Taxonomy:
|
||||||
|
{
|
||||||
|
if (fromCamlQuery) {
|
||||||
|
item[field.newField] = item['FieldValuesAsText'][field.originalField];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let taxonomyValues = item["TaxCatchAll"];
|
||||||
|
let taxonomyTerm = taxonomyValues.find(t => t.ID === item[field.originalField].WssId);
|
||||||
|
if (taxonomyTerm) {
|
||||||
|
item[field.newField] = taxonomyTerm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SharePointType.Boolean:
|
||||||
|
{
|
||||||
|
if (item[field.originalField] != undefined) {
|
||||||
|
item[field.newField] = item[field.originalField] ? "true" : "false";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item[field.newField] = item[field.originalField];
|
||||||
|
}
|
||||||
|
if (field.newField !== field.originalField) {
|
||||||
|
delete item[field.originalField];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
item[field.newField] = item[field.originalField];
|
||||||
|
if (field.newField !== field.originalField) {
|
||||||
|
delete item[field.originalField];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getListItems(listQueryOptions: IListSearchListQuery, listPropertyName: string, sitePropertyName: string, sitePropertyValue: string, rowLimit: number): Promise<Array<IResult>> {
|
||||||
|
try {
|
||||||
|
let camlQuery: boolean = false;
|
||||||
|
let items: any = undefined;
|
||||||
|
let queryConfig: QueryHelperEntity = this.GetViewFieldsWithId(listQueryOptions, !isEmpty(listQueryOptions.camlQuery) || !isEmpty(listQueryOptions.viewName));
|
||||||
|
if (listQueryOptions.camlQuery) {
|
||||||
|
let query = this.getCamlQueryWithViewFieldsAndRowLimit(listQueryOptions.camlQuery, queryConfig, rowLimit);
|
||||||
|
items = await this.getListItemsByCamlQuery(listQueryOptions.list.Id, query, queryConfig);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (listQueryOptions.viewName) {
|
||||||
|
let viewInfo: any = await this.web.lists.getById(listQueryOptions.list.Id).views.getByTitle(listQueryOptions.viewName).select("ViewQuery").get();
|
||||||
|
let query = this.getCamlQueryWithViewFieldsAndRowLimit(`<View><Query>${viewInfo.ViewQuery}</Query></View>`, queryConfig, rowLimit);
|
||||||
|
items = await this.getListItemsByCamlQuery(listQueryOptions.list.Id, query, queryConfig);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (rowLimit) {
|
||||||
|
if (queryConfig.expandFields && queryConfig.expandFields.length > 0) {
|
||||||
|
items = await this.web.lists.getById(listQueryOptions.list.Id).items.select(queryConfig.viewFields.join(',')).expand(queryConfig.expandFields.join(',')).usingCaching().get();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
items = await this.web.lists.getById(listQueryOptions.list.Id).items.top(rowLimit).select(queryConfig.viewFields.join(',')).usingCaching().get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (queryConfig.expandFields && queryConfig.expandFields.length > 0) {
|
||||||
|
items = await this.web.lists.getById(listQueryOptions.list.Id).items.select(queryConfig.viewFields.join(',')).expand(queryConfig.expandFields.join(',')).usingCaching().get();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
items = await this.web.lists.getById(listQueryOptions.list.Id).items.select(queryConfig.viewFields.join(',')).usingCaching().get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
let mappedItems = items.map((i: IResult) => {
|
||||||
|
i.FileExtension = this.GetFileExtension(i.FileLeafRef);
|
||||||
|
i.SiteUrl = this.baseUrl;
|
||||||
|
i.ListName = listQueryOptions.list.Title;
|
||||||
|
i.List = listQueryOptions.list;
|
||||||
|
|
||||||
|
listQueryOptions.fields.map(field => {
|
||||||
|
i = this.GetItemValue(i, field, camlQuery);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (listPropertyName) {
|
||||||
|
i[listPropertyName] = listQueryOptions.list.Title;
|
||||||
|
}
|
||||||
|
if (sitePropertyName) {
|
||||||
|
i[sitePropertyName] = sitePropertyValue;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
});
|
||||||
|
return mappedItems;
|
||||||
|
} catch (error) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getListItemById(listQueryOptions: IListSearchListQuery, itemId: number): Promise<any> {
|
||||||
|
try {
|
||||||
|
let queryConfig: QueryHelperEntity = this.GetViewFieldsWithId(listQueryOptions, false);
|
||||||
|
return this.web.lists.getById(listQueryOptions.list.Id).items.getById(itemId).select(queryConfig.viewFields.join(',')).expand(queryConfig.expandFields.join(',')).usingCaching().get();
|
||||||
|
} catch (error) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getSiteListsTitle(): Promise<Array<SiteList>> {
|
||||||
|
try {
|
||||||
|
return this.web.lists.filter('Hidden eq false').select('Title,Id').get();
|
||||||
|
} catch (error) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getListFields(listId: string): Promise<Array<ListField>> {
|
||||||
|
try {
|
||||||
|
return this.web.lists.getById(listId).fields.select('EntityPropertyName,Title,InternalName,TypeAsString').get();
|
||||||
|
} catch (error) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getListItemsByCamlQuery(listId: string, camlQuery: string, queryConfig: QueryHelperEntity): Promise<Array<any>> {
|
||||||
|
try {
|
||||||
|
const caml: ICamlQuery = {
|
||||||
|
ViewXml: camlQuery,
|
||||||
|
};
|
||||||
|
return this.web.lists.getById(listId).usingCaching().getItemsByCAMLQuery(caml, queryConfig.expandFields.join(','));
|
||||||
|
} catch (error) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getCamlQueryWithViewFieldsAndRowLimit(camlQuery: string, queryConfig: QueryHelperEntity, rowLimit: number): string {
|
||||||
|
try {
|
||||||
|
let XmlParser = new XMLParser();
|
||||||
|
let xml: ICamlQueryXml = XmlParser.parseFromString(camlQuery);
|
||||||
|
|
||||||
|
let rowLimitXml: ICamlQueryXml = { name: "RowLimit", value: rowLimit ? rowLimit.toString() : "0", attributes: undefined, children: [] };
|
||||||
|
|
||||||
|
let viewFieldsChildren: ICamlQueryXml[] = queryConfig.viewFields.map(viewField => {
|
||||||
|
return { name: "FieldRef", attributes: { Name: viewField }, value: "", children: [] };
|
||||||
|
});
|
||||||
|
let viewFieldsXml: ICamlQueryXml = { name: "ViewFields", value: "", children: viewFieldsChildren, attributes: undefined };
|
||||||
|
|
||||||
|
let queryXml: ICamlQueryXml;
|
||||||
|
xml.children.map(child => {
|
||||||
|
if (child.name == "Query") {
|
||||||
|
queryXml = child;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (child.name == "RowLimit") { //If the user set a camlquery with row limit or the view has row limit, it is not override
|
||||||
|
rowLimitXml = child;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (queryXml) {
|
||||||
|
xml.children = [viewFieldsXml, rowLimitXml, queryXml];
|
||||||
|
}
|
||||||
|
|
||||||
|
let result: string = XmlParser.toString(xml);
|
||||||
|
return result.replace("</RowLimit></RowLimit>", "</RowLimit>");
|
||||||
|
} catch (error) {
|
||||||
|
return `getCamlQueryWithViewFieldsAndRowLimit -> ${error.message}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private GetFileExtension(filename: string): string {
|
||||||
|
var re = /(?:\.([^.]+))?$/;
|
||||||
|
return re.exec(filename)[1] ? re.exec(filename)[1].toLowerCase() : undefined;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
export default class StringUtils {
|
||||||
|
|
||||||
|
public static GetUserInitials(text: string): string {
|
||||||
|
if (text) {
|
||||||
|
let initials = text.match(/\b\w/g) || [];
|
||||||
|
text = ((initials.shift() || '') + (initials.pop() || '')).toUpperCase();
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GetUserEmail(text: string): string {
|
||||||
|
let result: string = "";
|
||||||
|
if (text && text.indexOf('|') > 0) {
|
||||||
|
let splited = text.split('|');
|
||||||
|
if (splited && splited.length > 1) {
|
||||||
|
result = splited[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||||
|
"id": "306e0650-db3c-443a-a698-12be6e6de1ad",
|
||||||
|
"alias": "ListSearchConsumerWebPartWebPart",
|
||||||
|
"componentType": "WebPart",
|
||||||
|
|
||||||
|
// The "*" signifies that the version should be taken from the package.json
|
||||||
|
"version": "*",
|
||||||
|
"manifestVersion": 2,
|
||||||
|
|
||||||
|
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||||
|
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||||
|
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||||
|
"requiresCustomScript": false,
|
||||||
|
"supportedHosts": ["SharePointWebPart"],
|
||||||
|
|
||||||
|
"preconfiguredEntries": [{
|
||||||
|
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||||
|
"group": { "default": "Other" },
|
||||||
|
"title": { "default": "ListSearchConsumerWebPart" },
|
||||||
|
"description": { "default": "List Search consumer example" },
|
||||||
|
"officeFabricIconFontName": "Page",
|
||||||
|
"properties": {
|
||||||
|
"description": "ListSearchConsumerWebPart"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import * as ReactDom from 'react-dom';
|
||||||
|
import {
|
||||||
|
IPropertyPaneConfiguration,
|
||||||
|
DynamicDataSharedDepth,
|
||||||
|
PropertyPaneDynamicFieldSet,
|
||||||
|
PropertyPaneDynamicField
|
||||||
|
} from '@microsoft/sp-property-pane';
|
||||||
|
import {
|
||||||
|
BaseClientSideWebPart,
|
||||||
|
IWebPartPropertiesMetadata,
|
||||||
|
} from '@microsoft/sp-webpart-base';
|
||||||
|
|
||||||
|
import * as strings from 'ListSearchConsumerWebPartWebPartStrings';
|
||||||
|
import { DynamicProperty } from '@microsoft/sp-component-base';
|
||||||
|
import { IListSearchConsumerProps } from './components/IListSearchConsumerProps';
|
||||||
|
import ListSearchConsumer from './components/ListSearchConsumerWebPart';
|
||||||
|
|
||||||
|
|
||||||
|
export interface IListSearchConsumerWebPartProps {
|
||||||
|
webUrl: DynamicProperty<string>;
|
||||||
|
listId: DynamicProperty<string>;
|
||||||
|
itemId: DynamicProperty<number>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default class ListSearchConsumerWebPart extends BaseClientSideWebPart<IListSearchConsumerWebPartProps> {
|
||||||
|
|
||||||
|
public render(): void {
|
||||||
|
|
||||||
|
const element: React.ReactElement<IListSearchConsumerProps> = React.createElement(
|
||||||
|
ListSearchConsumer,
|
||||||
|
{
|
||||||
|
webUrl: this.properties.webUrl.tryGetValue(),
|
||||||
|
listId: this.properties.listId.tryGetValue(),
|
||||||
|
itemId: this.properties.itemId.tryGetValue(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ReactDom.render(element, this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onDispose(): void {
|
||||||
|
ReactDom.unmountComponentAtNode(this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get propertiesMetadata(): IWebPartPropertiesMetadata {
|
||||||
|
return {
|
||||||
|
// Specify the web part properties data type to allow the address
|
||||||
|
// information to be serialized by the SharePoint Framework.
|
||||||
|
'webUrl': {
|
||||||
|
dynamicPropertyType: 'string'
|
||||||
|
},
|
||||||
|
'listId': {
|
||||||
|
dynamicPropertyType: 'string'
|
||||||
|
},
|
||||||
|
'itemId': {
|
||||||
|
dynamicPropertyType: 'number'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||||
|
return {
|
||||||
|
pages: [
|
||||||
|
{
|
||||||
|
header: {
|
||||||
|
description: strings.PropertyPaneDescription
|
||||||
|
},
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
groupName: strings.BasicGroupName,
|
||||||
|
groupFields: [
|
||||||
|
PropertyPaneDynamicFieldSet({
|
||||||
|
label: 'Select web Url',
|
||||||
|
fields: [
|
||||||
|
PropertyPaneDynamicField('webUrl', {
|
||||||
|
label: 'Web Url'
|
||||||
|
}),
|
||||||
|
PropertyPaneDynamicField('listId', {
|
||||||
|
label: 'List Id'
|
||||||
|
}),
|
||||||
|
PropertyPaneDynamicField('itemId', {
|
||||||
|
label: 'Item Id'
|
||||||
|
})
|
||||||
|
],
|
||||||
|
sharedConfiguration: {
|
||||||
|
depth: DynamicDataSharedDepth.Property
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface IListSearchConsumerProps {
|
||||||
|
webUrl: string;
|
||||||
|
listId: string;
|
||||||
|
itemId: number;
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||||
|
|
||||||
|
.listSearchConsumerWebPart {
|
||||||
|
margin: 5px;
|
||||||
|
background-color: $ms-color-themePrimary;
|
||||||
|
color: $ms-color-white;
|
||||||
|
@include ms-Grid;
|
||||||
|
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
.row {
|
||||||
|
@include ms-Grid-row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.column {
|
||||||
|
@include ms-Grid-col;
|
||||||
|
@include ms-lg12;
|
||||||
|
@include ms-sm12;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
@include ms-font-xl;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subTitle {
|
||||||
|
@include ms-font-l;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
@include ms-font-l;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
@include ms-font-m;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import styles from './ListSearchConsumerWebPart.module.scss';
|
||||||
|
import { IListSearchConsumerProps } from './IListSearchConsumerProps';
|
||||||
|
|
||||||
|
export default class ListSearchConsumer extends React.Component<IListSearchConsumerProps, {}> {
|
||||||
|
public render(): React.ReactElement<IListSearchConsumerProps> {
|
||||||
|
return (
|
||||||
|
<div className={styles.listSearchConsumerWebPart}>
|
||||||
|
<div className={styles.row}>
|
||||||
|
<div className={styles.column}>
|
||||||
|
<span className={styles.title}>List search consumer webpart</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.column}>
|
||||||
|
<div className={styles.description}>WebUrl:
|
||||||
|
<p className={styles.value}>{this.props.webUrl}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.column}>
|
||||||
|
<div className={styles.description}>ListId:
|
||||||
|
<p className={styles.value}>{this.props.listId}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.column}>
|
||||||
|
<div className={styles.description}>ItemId:
|
||||||
|
<p className={styles.value}>{this.props.itemId}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div >
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
7
samples/react-list-search/src/webparts/listSearchConsumerWebPart/loc/en-us.js
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
define([], function() {
|
||||||
|
return {
|
||||||
|
"PropertyPaneDescription": "Description",
|
||||||
|
"BasicGroupName": "Group Name",
|
||||||
|
"DescriptionFieldLabel": "Description Field"
|
||||||
|
}
|
||||||
|
});
|
10
samples/react-list-search/src/webparts/listSearchConsumerWebPart/loc/mystrings.d.ts
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
declare interface IListSearchConsumerWebPartWebPartStrings {
|
||||||
|
PropertyPaneDescription: string;
|
||||||
|
BasicGroupName: string;
|
||||||
|
DescriptionFieldLabel: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'ListSearchConsumerWebPartWebPartStrings' {
|
||||||
|
const strings: IListSearchConsumerWebPartWebPartStrings;
|
||||||
|
export = strings;
|
||||||
|
}
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 383 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 383 B |
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es6",
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"jsx": "react",
|
||||||
|
"declaration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"outDir": "lib",
|
||||||
|
"inlineSources": false,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"noUnusedLocals": false,
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"./node_modules/@microsoft"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"es6-promise",
|
||||||
|
"webpack-env"
|
||||||
|
],
|
||||||
|
"lib": [
|
||||||
|
"es6",
|
||||||
|
"dom",
|
||||||
|
"es2015.collection"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts",
|
||||||
|
"src/**/*.tsx"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"lib"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
|
||||||
|
|
||||||
|
"rules": {
|
||||||
|
"class-name": false,
|
||||||
|
"export-name": false,
|
||||||
|
"forin": false,
|
||||||
|
"label-position": false,
|
||||||
|
"member-access": true,
|
||||||
|
"no-arg": false,
|
||||||
|
"no-console": false,
|
||||||
|
"no-construct": false,
|
||||||
|
"no-duplicate-variable": true,
|
||||||
|
"no-eval": false,
|
||||||
|
"no-function-expression": true,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"no-shadowed-variable": true,
|
||||||
|
"no-switch-case-fall-through": true,
|
||||||
|
"no-unnecessary-semicolons": true,
|
||||||
|
"no-unused-expression": true,
|
||||||
|
"no-use-before-declare": false,
|
||||||
|
"no-with-statement": true,
|
||||||
|
"semicolon": true,
|
||||||
|
"trailing-comma": false,
|
||||||
|
"typedef": false,
|
||||||
|
"typedef-whitespace": false,
|
||||||
|
"use-named-parameter": true,
|
||||||
|
"variable-name": false,
|
||||||
|
"whitespace": false
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,259 @@
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const webpack = require("webpack");
|
||||||
|
const resolve = require("path").resolve;
|
||||||
|
const CertStore = require("@microsoft/gulp-core-build-serve/lib/CertificateStore");
|
||||||
|
const CertificateStore = CertStore.CertificateStore || CertStore.default;
|
||||||
|
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
||||||
|
const del = require("del");
|
||||||
|
const port = 4321;
|
||||||
|
const host = "https://localhost:" + port;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Transforms define("<guid>", ...) to web part specific define("<web part id_version", ...)
|
||||||
|
// the same approach is used inside copyAssets SPFx build step
|
||||||
|
///
|
||||||
|
class DynamicLibraryPlugin {
|
||||||
|
constructor(options) {
|
||||||
|
this.opitons = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(compiler) {
|
||||||
|
compiler.hooks.emit.tap("DynamicLibraryPlugin", compilation => {
|
||||||
|
for (const assetId in this.opitons.modulesMap) {
|
||||||
|
const moduleMap = this.opitons.modulesMap[assetId];
|
||||||
|
|
||||||
|
if (compilation.assets[assetId]) {
|
||||||
|
const rawValue = compilation.assets[assetId].children[0]._value;
|
||||||
|
compilation.assets[assetId].children[0]._value = rawValue.replace(this.opitons.libraryName, moduleMap.id + "_" + moduleMap.version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
// Removes *.module.scss.ts on the first execution in order prevent conflicts with *.module.scss.d.ts
|
||||||
|
// generated by css-modules-typescript-loader
|
||||||
|
///
|
||||||
|
class ClearCssModuleDefinitionsPlugin {
|
||||||
|
constructor(options) {
|
||||||
|
this.options = options || {};
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(compiler) {
|
||||||
|
compiler.hooks.done.tap("FixStylesPlugin", stats => {
|
||||||
|
if (!this.options.deleted) {
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
del.sync(["src/**/*.module.scss.ts"]);
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
this.options.deleted = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let baseConfig = {
|
||||||
|
target: "web",
|
||||||
|
mode: "development",
|
||||||
|
devtool: "source-map",
|
||||||
|
resolve: {
|
||||||
|
extensions: [".ts", ".tsx", ".js"],
|
||||||
|
modules: ["node_modules"]
|
||||||
|
},
|
||||||
|
context: path.resolve(__dirname),
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
loader: "ts-loader",
|
||||||
|
options: {
|
||||||
|
transpileOnly: true,
|
||||||
|
compilerOptions: {
|
||||||
|
declarationMap: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
exclude: /node_modules/
|
||||||
|
},
|
||||||
|
{
|
||||||
|
use: [{
|
||||||
|
loader: "@microsoft/loader-cased-file",
|
||||||
|
options: {
|
||||||
|
name: "[name:lower]_[hash].[ext]"
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
test: /\.(jpe?g|png|woff|eot|ttf|svg|gif|dds)$/i
|
||||||
|
},
|
||||||
|
{
|
||||||
|
use: [{
|
||||||
|
loader: "html-loader"
|
||||||
|
}],
|
||||||
|
test: /\.html$/
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: "@microsoft/loader-load-themed-styles",
|
||||||
|
options: {
|
||||||
|
async: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: "css-loader"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: function (fileName) {
|
||||||
|
return fileName.endsWith(".module.scss"); // scss modules support
|
||||||
|
},
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: "@microsoft/loader-load-themed-styles",
|
||||||
|
options: {
|
||||||
|
async: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"css-modules-typescript-loader",
|
||||||
|
{
|
||||||
|
loader: "css-loader",
|
||||||
|
options: {
|
||||||
|
modules: {
|
||||||
|
localIdentName: "[local]_[hash:base64:8]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, // translates CSS into CommonJS
|
||||||
|
"sass-loader" // compiles Sass to CSS, using Node Sass by default
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: function (fileName) {
|
||||||
|
return !fileName.endsWith(".module.scss") && fileName.endsWith(".scss"); // just regular .scss
|
||||||
|
},
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: "@microsoft/loader-load-themed-styles",
|
||||||
|
options: {
|
||||||
|
async: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"css-loader", // translates CSS into CommonJS
|
||||||
|
"sass-loader" // compiles Sass to CSS, using Node Sass by default
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new ForkTsCheckerWebpackPlugin({
|
||||||
|
tslint: true
|
||||||
|
}),
|
||||||
|
new ClearCssModuleDefinitionsPlugin(),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
|
||||||
|
"process.env.DEBUG": JSON.stringify(true),
|
||||||
|
"DEBUG": JSON.stringify(true)
|
||||||
|
})],
|
||||||
|
devServer: {
|
||||||
|
hot: false,
|
||||||
|
contentBase: resolve(__dirname),
|
||||||
|
publicPath: host + "/dist/",
|
||||||
|
host: "localhost",
|
||||||
|
port: port,
|
||||||
|
disableHostCheck: true,
|
||||||
|
historyApiFallback: true,
|
||||||
|
open: true,
|
||||||
|
writeToDisk: false,
|
||||||
|
openPage: host + "/temp/workbench.html",
|
||||||
|
stats: {
|
||||||
|
preset: "errors-only",
|
||||||
|
colors: true,
|
||||||
|
chunks: false,
|
||||||
|
modules: false,
|
||||||
|
assets: false
|
||||||
|
},
|
||||||
|
proxy: { // url re-write for resources to be served directly from src folder
|
||||||
|
"/lib/**/loc/*.js": {
|
||||||
|
target: host,
|
||||||
|
pathRewrite: { "^/lib": "/src" },
|
||||||
|
secure: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
},
|
||||||
|
https: {
|
||||||
|
cert: CertificateStore.instance.certificateData,
|
||||||
|
key: CertificateStore.instance.keyData
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const createConfig = function () {
|
||||||
|
// remove old css module TypeScript definitions
|
||||||
|
del.sync(["dist/*.js", "dist/*.map"]);
|
||||||
|
|
||||||
|
// we need only "externals", "output" and "entry" from the original webpack config
|
||||||
|
let originalWebpackConfig = require("./temp/_webpack_config.json");
|
||||||
|
baseConfig.externals = originalWebpackConfig.externals;
|
||||||
|
baseConfig.output = originalWebpackConfig.output;
|
||||||
|
|
||||||
|
baseConfig.entry = getEntryPoints(originalWebpackConfig.entry);
|
||||||
|
|
||||||
|
baseConfig.output.publicPath = host + "/dist/";
|
||||||
|
|
||||||
|
const manifest = require("./temp/manifests.json");
|
||||||
|
const modulesMap = {};
|
||||||
|
const originalEntries = Object.keys(originalWebpackConfig.entry);
|
||||||
|
|
||||||
|
for (const jsModule of manifest) {
|
||||||
|
if (jsModule.loaderConfig
|
||||||
|
&& jsModule.loaderConfig.entryModuleId
|
||||||
|
&& originalEntries.indexOf(jsModule.loaderConfig.entryModuleId) !== -1) {
|
||||||
|
modulesMap[jsModule.loaderConfig.entryModuleId + ".js"] = {
|
||||||
|
id: jsModule.id,
|
||||||
|
version: jsModule.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
baseConfig.plugins.push(new DynamicLibraryPlugin({
|
||||||
|
modulesMap: modulesMap,
|
||||||
|
libraryName: originalWebpackConfig.output.library
|
||||||
|
}));
|
||||||
|
|
||||||
|
return baseConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEntryPoints(entry) {
|
||||||
|
// fix: ".js" entry needs to be ".ts"
|
||||||
|
// also replaces the path form /lib/* to /src/*
|
||||||
|
let newEntry = {};
|
||||||
|
let libSearchRegexp;
|
||||||
|
if (path.sep === "/") {
|
||||||
|
libSearchRegexp = /\/lib\//gi;
|
||||||
|
} else {
|
||||||
|
libSearchRegexp = /\\lib\\/gi;
|
||||||
|
}
|
||||||
|
|
||||||
|
const srcPathToReplace = path.sep + "src" + path.sep;
|
||||||
|
|
||||||
|
for (const key in entry) {
|
||||||
|
let entryPath = entry[key];
|
||||||
|
if (entryPath.indexOf("bundle-entries") === -1) {
|
||||||
|
entryPath = entryPath.replace(libSearchRegexp, srcPathToReplace).slice(0, -3) + ".ts";
|
||||||
|
} else {
|
||||||
|
// replace paths and extensions in bundle file
|
||||||
|
let bundleContent = fs.readFileSync(entryPath).toString();
|
||||||
|
bundleContent = bundleContent.replace(libSearchRegexp, srcPathToReplace).replace(/\.js/gi, ".ts");
|
||||||
|
fs.writeFileSync(entryPath, bundleContent);
|
||||||
|
}
|
||||||
|
newEntry[key] = entryPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = createConfig();
|