Merge pull request #1858 from joaojmendes/main
|
@ -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,27 @@
|
||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2020,
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"react": {
|
||||||
|
"version": "detect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignorePatterns": ["*.js"],
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:react-hooks/recommended",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:react/recommended"
|
||||||
|
]
|
||||||
|
}
|
|
@ -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,34 @@
|
||||||
|
{
|
||||||
|
"@pnp/generator-spfx": {
|
||||||
|
"framework": "react",
|
||||||
|
"pnpFramework": "reactjs.plus",
|
||||||
|
"pnp-libraries": [
|
||||||
|
"jquery@3",
|
||||||
|
"msgraph",
|
||||||
|
"@pnp/pnpjs",
|
||||||
|
"@pnp/spfx-property-controls",
|
||||||
|
"spfx-uifabric-themes",
|
||||||
|
"lodash",
|
||||||
|
"@pnp/spfx-controls-react",
|
||||||
|
"ouifr@7",
|
||||||
|
"rush@3.7"
|
||||||
|
],
|
||||||
|
"pnp-ci": "azure-preview",
|
||||||
|
"pnp-vetting": [],
|
||||||
|
"spfxenv": "spo",
|
||||||
|
"pnp-testing": [
|
||||||
|
"jest"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"@microsoft/generator-sharepoint": {
|
||||||
|
"environment": "spo",
|
||||||
|
"framework": "react",
|
||||||
|
"isCreatingSolution": true,
|
||||||
|
"version": "1.11.0",
|
||||||
|
"libraryName": "react-list-items-menu",
|
||||||
|
"libraryId": "8b4a758d-a968-4e7c-a949-b42e7dd5ad14",
|
||||||
|
"packageManager": "npm",
|
||||||
|
"isDomainIsolated": false,
|
||||||
|
"componentType": "webpart"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
# List Items Menu (SP2019 Version)
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This web part allows user create a navigation menu , grouped by any column of document library.
|
||||||
|
When the user clicks on the header it dynamically load documents.
|
||||||
|
|
||||||
|
![ListItemsMenu](./assets/react-list-item-menu.gif)
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
![ListItemsMenusp2019](./assets/react-list-item-menu.png)
|
||||||
|
|
||||||
|
![ListItemsMenusp2019](./assets/react-list-item-menu2.png)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
![SPFx 1.4.1](https://img.shields.io/badge/SPFx-1.4.1-green.svg)
|
||||||
|
![Node.js LTS 6.x | LTS 8.x](https://img.shields.io/badge/Node.js-LTS%206.x%20%7C%20LTS%208.x-green.svg)
|
||||||
|
![SharePoint 2019 | Online](https://img.shields.io/badge/SharePoint-2019%20%7C%20Online-yellow.svg)
|
||||||
|
![Teams No: Not designed for Microsoft Teams](https://img.shields.io/badge/Teams-No-red.svg "Not designed for Microsoft Teams")
|
||||||
|
![Workbench Hosted: Does not work with local workbench](https://img.shields.io/badge/Workbench-Hosted-yellow.svg "Does not work with local workbench")
|
||||||
|
|
||||||
|
|
||||||
|
## Applies to
|
||||||
|
|
||||||
|
[SharePoint Framework](https://aka.ms/spfx)
|
||||||
|
|
||||||
|
|
||||||
|
## WebPart Properties
|
||||||
|
|
||||||
|
Property |Type|Required| comments
|
||||||
|
--------------------|----|--------|----------
|
||||||
|
WebPart Title| Text| no|
|
||||||
|
Select Document Library| dropdown|yes
|
||||||
|
Select Field to Group By | dropdown|yes
|
||||||
|
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
The Web Part Use PnPjs library, Fluent-Ui-react components
|
||||||
|
|
||||||
|
Solution|Author(s)
|
||||||
|
--------|---------
|
||||||
|
React List Items Menu |[João Mendes](https://github.com/joaojmendes) ([@joaojmendes](https://twitter.com/joaojmendes))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
Version|Date|Comments
|
||||||
|
-------|----|--------
|
||||||
|
1.0.0|May 7, 2021|Initial release
|
||||||
|
|
||||||
|
## Minimal Path to Awesome
|
||||||
|
|
||||||
|
- Clone this repository
|
||||||
|
- Move to sample folder
|
||||||
|
- in the command line run:
|
||||||
|
- `npm install`
|
||||||
|
- `gulp build`
|
||||||
|
- `gulp bundle --ship`
|
||||||
|
- `gulp package-solution --ship`
|
||||||
|
- Add to AppCatalog and deploy
|
||||||
|
|
||||||
|
## 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.**
|
||||||
|
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
We do not support samples, but we do use GitHub to track issues and constantly want to improve these samples.
|
||||||
|
|
||||||
|
If you encounter any issues while using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=react-list-items-menu-sp2019&authors=@joaojmendes&title=react-list-items-menu-sp2019%20-%20).
|
||||||
|
|
||||||
|
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=react-list-items-menu-sp2019&authors=@joaojmendes&title=react-list-items-menu-sp2019%20-%20).
|
||||||
|
|
||||||
|
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=react-list-items-menu-sp2019&authors=@joaojmendes&title=react-list-items-menu-sp2019%20-%20).
|
||||||
|
|
||||||
|
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-list-items-menu-SP2019" />
|
After Width: | Height: | Size: 5.5 MiB |
After Width: | Height: | Size: 262 KiB |
After Width: | Height: | Size: 238 KiB |
|
@ -0,0 +1,64 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "pnp-sp-dev-spfx-web-parts-react-list-items-menu-sp2019",
|
||||||
|
"source": "pnp",
|
||||||
|
"title": "List Items Menu (SP2019 Version)",
|
||||||
|
"shortDescription": "Allows user create a navigation menu , grouped by any column of document library. When the user clicks on the header it dynamically load documents.",
|
||||||
|
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-list-items-menu-sp2019",
|
||||||
|
"longDescription": [
|
||||||
|
"Allows user create a navigation menu , grouped by any column of document library. When the user clicks on the header it dynamically load documents."
|
||||||
|
],
|
||||||
|
"creationDateTime": "2021-05-06",
|
||||||
|
"updateDateTime": "2021-05-06",
|
||||||
|
"products": [
|
||||||
|
"SharePoint",
|
||||||
|
"Office"
|
||||||
|
],
|
||||||
|
"metadata": [
|
||||||
|
{
|
||||||
|
"key": "CLIENT-SIDE-DEV",
|
||||||
|
"value": "React"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "SPFX-VERSION",
|
||||||
|
"value": "1.4.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thumbnails": [
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"order": 100,
|
||||||
|
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-list-items-menu-sp2019/assets/react-list-item-menu.gif",
|
||||||
|
"alt": "List Items Menu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"order": 101,
|
||||||
|
"url": "https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-list-items-menu-sp2019/assets/react-list-item-menu.png?raw=true",
|
||||||
|
"alt": "List Items Menu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"order": 102,
|
||||||
|
"url": "https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-list-items-menu-sp2019/assets/react-list-item-menu2.png?raw=true",
|
||||||
|
"alt": "List Items Menu"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"gitHubAccount": "joaojmendes",
|
||||||
|
"company": "Storm Technology Ltd",
|
||||||
|
"pictureUrl": "https://github.com/joaojmendes.png",
|
||||||
|
"name": "Jo\u00E3o Mendes",
|
||||||
|
"twitter": "joaojmendes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"name": "Build your first SharePoint client-side web part",
|
||||||
|
"description": "Client-side web parts are client-side components that run in the context of a SharePoint page. Client-side web parts can be deployed to SharePoint environments that support the SharePoint Framework. You can also use modern JavaScript web frameworks, tools, and libraries to build them.",
|
||||||
|
"url": "https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,67 @@
|
||||||
|
parameters:
|
||||||
|
name: ''
|
||||||
|
jobs:
|
||||||
|
- job: ${{ parameters.name }}
|
||||||
|
pool:
|
||||||
|
vmImage: 'ubuntu-latest'
|
||||||
|
demands:
|
||||||
|
- npm
|
||||||
|
- node.js
|
||||||
|
- java
|
||||||
|
variables:
|
||||||
|
npm_config_cache: $(Pipeline.Workspace)/.npm
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- checkout: self
|
||||||
|
|
||||||
|
- task: NodeTool@0
|
||||||
|
displayName: 'Use Node 10.x'
|
||||||
|
inputs:
|
||||||
|
versionSpec: 10.x
|
||||||
|
checkLatest: true
|
||||||
|
|
||||||
|
- task: CacheBeta@1
|
||||||
|
inputs:
|
||||||
|
key: npm | $(Agent.OS) | package-lock.json
|
||||||
|
path: $(npm_config_cache)
|
||||||
|
cacheHitVar: CACHE_RESTORED
|
||||||
|
- script: npm ci
|
||||||
|
displayName: 'npm ci'
|
||||||
|
|
||||||
|
- task: Gulp@0
|
||||||
|
displayName: 'Bundle project'
|
||||||
|
inputs:
|
||||||
|
targets: bundle
|
||||||
|
arguments: '--ship'
|
||||||
|
|
||||||
|
- script: npm test
|
||||||
|
displayName: 'npm test'
|
||||||
|
|
||||||
|
- task: PublishTestResults@2
|
||||||
|
displayName: Publish test results
|
||||||
|
inputs:
|
||||||
|
testResultsFormat: JUnit
|
||||||
|
testResultsFiles: '**/junit.xml'
|
||||||
|
#failTaskOnFailedTests: true #if we want to fail the build on failed unit tests
|
||||||
|
|
||||||
|
- task: PublishCodeCoverageResults@1
|
||||||
|
displayName: 'Publish code coverage results'
|
||||||
|
inputs:
|
||||||
|
codeCoverageTool: Cobertura
|
||||||
|
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
|
||||||
|
|
||||||
|
- task: Gulp@0
|
||||||
|
displayName: 'Package Solution'
|
||||||
|
inputs:
|
||||||
|
targets: 'package-solution'
|
||||||
|
arguments: '--ship'
|
||||||
|
|
||||||
|
- task: CopyFiles@2
|
||||||
|
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
|
||||||
|
inputs:
|
||||||
|
Contents: |
|
||||||
|
sharepoint/**/*.sppkg
|
||||||
|
TargetFolder: '$(Build.ArtifactStagingDirectory)'
|
||||||
|
|
||||||
|
- task: PublishBuildArtifacts@1
|
||||||
|
displayName: 'Publish Artifact: drop'
|
|
@ -0,0 +1,39 @@
|
||||||
|
parameters:
|
||||||
|
# unique name of the job
|
||||||
|
job_name: deploy_sppkg
|
||||||
|
# friendly name of the job
|
||||||
|
display_name: Upload & deploy *.sppkg to SharePoint app catalog
|
||||||
|
# name of target enviroment deploying to
|
||||||
|
target_environment: ''
|
||||||
|
# app catalog scope (tenant|sitecollection)
|
||||||
|
o365cli_app_catalog_scope: 'tenant'
|
||||||
|
variable_group_name: ''
|
||||||
|
jobs:
|
||||||
|
- deployment: ${{ parameters.job_name }}
|
||||||
|
displayName: ${{ parameters.display_name }}
|
||||||
|
pool:
|
||||||
|
vmImage: 'ubuntu-latest'
|
||||||
|
environment: ${{ parameters.target_environment }}
|
||||||
|
variables:
|
||||||
|
- group: ${{parameters.variable_group_name}} #o365_user_login, o365_user_password, o365_app_catalog_site_url
|
||||||
|
strategy:
|
||||||
|
runOnce:
|
||||||
|
deploy:
|
||||||
|
steps:
|
||||||
|
- checkout: none
|
||||||
|
- download: current
|
||||||
|
artifact: drop
|
||||||
|
patterns: '**/*.sppkg'
|
||||||
|
- script: sudo npm install --global @pnp/office365-cli
|
||||||
|
displayName: Install Office365 CLI
|
||||||
|
- script: o365 login $(o365_app_catalog_site_url) --authType password --userName $(o365_user_login) --password $(o365_user_password)
|
||||||
|
displayName: Login to Office365
|
||||||
|
- script: |
|
||||||
|
CMD_GET_SPPKG_NAME=$(find $(Pipeline.Workspace)/drop -name '*.sppkg' -exec basename {} \;)
|
||||||
|
echo "##vso[task.setvariable variable=SpPkgFileName;isOutput=true]${CMD_GET_SPPKG_NAME}"
|
||||||
|
displayName: Get generated *.sppkg filename
|
||||||
|
name: GetSharePointPackage
|
||||||
|
- script: o365 spo app add --filePath "$(Pipeline.Workspace)/drop/sharepoint/solution/$(GetSharePointPackage.SpPkgFileName)" --appCatalogUrl $(o365_app_catalog_site_url) --scope ${{ parameters.o365cli_app_catalog_scope }} --overwrite
|
||||||
|
displayName: Upload SharePoint package to Site Collection App Catalog
|
||||||
|
- script: o365 spo app deploy --name $(GetSharePointPackage.SpPkgFileName) --appCatalogUrl $(o365_app_catalog_site_url) --scope ${{ parameters.o365cli_app_catalog_scope }}
|
||||||
|
displayName: Deploy SharePoint package
|
|
@ -0,0 +1,26 @@
|
||||||
|
name: $(TeamProject)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
|
||||||
|
resources:
|
||||||
|
- repo: self
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- stage: build
|
||||||
|
displayName: build
|
||||||
|
jobs:
|
||||||
|
- template: ./azure-pipelines-build-template.yml
|
||||||
|
parameters:
|
||||||
|
name: 'buildsolution'
|
||||||
|
- stage: 'deployqa'
|
||||||
|
# uncomment if you want deployments to occur only for a specific branch
|
||||||
|
#condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))
|
||||||
|
jobs:
|
||||||
|
- template: ./azure-pipelines-deploy-template.yml
|
||||||
|
parameters:
|
||||||
|
job_name: deploy_solution
|
||||||
|
target_environment: 'qa'
|
||||||
|
variable_group_name: qa_configuration
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||||
|
"version": "2.0",
|
||||||
|
"bundles": {
|
||||||
|
"list-items-menu-web-part": {
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"entrypoint": "./lib/webparts/listItemsMenu/ListItemsMenuWebPart.js",
|
||||||
|
"manifest": "./src/webparts/listItemsMenu/ListItemsMenuWebPart.manifest.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"externals": {},
|
||||||
|
"localizedResources": {
|
||||||
|
"ListItemsMenuWebPartStrings": "lib/webparts/listItemsMenu/loc/{locale}.js",
|
||||||
|
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js",
|
||||||
|
"PropertyControlStrings": "node_modules/@pnp/spfx-property-controls/lib/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": "react-list-items-menu",
|
||||||
|
"accessKey": "<!-- ACCESS KEY -->"
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
{"preset":"@voitanos/jest-preset-spfx-react16","rootDir":"../src","collectCoverageFrom":["<rootDir>/**/*.{ts,tsx}","!<rootDir>/**/*.scss.*","!<rootDir>/loc/**/*.*"],"coverageReporters":["text","json","lcov","text-summary","cobertura"],"reporters":["default",["jest-junit",{"suiteName":"jest tests","outputDirectory":"temp/test/junit","outputName":"junit.xml"}]]}
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||||
|
"solution": {
|
||||||
|
"name": "react-list-items-menu-client-side-solution",
|
||||||
|
"id": "8b4a758d-a968-4e7c-a949-b42e7dd5ad14",
|
||||||
|
"version": "1.0.0.0",
|
||||||
|
"includeClientSideAssets": true,
|
||||||
|
"skipFeatureDeployment": true
|
||||||
|
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"zippedPackage": "solution/react-list-items-menu.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,57 @@
|
||||||
|
// gulpfile.js
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const gulp = require('gulp');
|
||||||
|
const build = require('@microsoft/sp-build-web');
|
||||||
|
const merge = require('webpack-merge');
|
||||||
|
const TerserPlugin = require('terser-webpack-plugin-legacy');
|
||||||
|
build.addSuppression(/Warning - \[sass\] The local CSS class .* is not camelCase and will not be type-safe./gi);
|
||||||
|
|
||||||
|
// force use of projects specified typescript version
|
||||||
|
const typeScriptConfig = require('@microsoft/gulp-core-build-typescript/lib/TypeScriptConfiguration');
|
||||||
|
typeScriptConfig.TypeScriptConfiguration.setTypescriptCompiler(require('typescript'));
|
||||||
|
|
||||||
|
// disable tslint
|
||||||
|
build.tslint.enabled = false;
|
||||||
|
|
||||||
|
const eslint = require('gulp-eslint');
|
||||||
|
|
||||||
|
const eslintSubTask = build.subTask('eslint', function (gulp, buildOptions, done) {
|
||||||
|
return gulp.src(['src/**/*.{ts,tsx}'])
|
||||||
|
// eslint() attaches the lint output to the "eslint" property
|
||||||
|
// of the file object so it can be used by other modules.
|
||||||
|
.pipe(eslint())
|
||||||
|
// eslint.format() outputs the lint results to the console.
|
||||||
|
// Alternatively use eslint.formatEach() (see Docs).
|
||||||
|
.pipe(eslint.format())
|
||||||
|
// To have the process exit with an error code (1) on
|
||||||
|
// lint error, return the stream and pipe to failAfterError last.
|
||||||
|
.pipe(eslint.failAfterError());
|
||||||
|
});
|
||||||
|
|
||||||
|
build.rig.addPreBuildTask(build.task('eslint-task', eslintSubTask));
|
||||||
|
// force use of projects specified react version
|
||||||
|
build.configureWebpack.mergeConfig({
|
||||||
|
|
||||||
|
additionalConfiguration: (generatedConfiguration) => {
|
||||||
|
// force use of projects specified react version
|
||||||
|
generatedConfiguration.externals = generatedConfiguration.externals
|
||||||
|
.filter(name => !(["react", "react-dom"].includes(name)));
|
||||||
|
// force use TerserPlugIn (remove UglifyJs)
|
||||||
|
generatedConfiguration.plugins.forEach((plugin, i) => {
|
||||||
|
if (plugin.options && plugin.options.mangle) {
|
||||||
|
generatedConfiguration.plugins.splice(i, 1);
|
||||||
|
generatedConfiguration = merge(generatedConfiguration, {
|
||||||
|
plugins: [
|
||||||
|
new TerserPlugin()
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
return generatedConfiguration;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
build.initialize(gulp);
|
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
"name": "react-news-banner",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "gulp bundle",
|
||||||
|
"clean": "gulp clean",
|
||||||
|
"test": "gulp test"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fluentui/theme": "^2.1.0",
|
||||||
|
"@microsoft/office-ui-fabric-react-bundle": "^1.11.0",
|
||||||
|
"@microsoft/sp-core-library": "~1.4.1",
|
||||||
|
"@microsoft/sp-lodash-subset": "~1.4.1",
|
||||||
|
"@microsoft/sp-office-ui-fabric-core": "^1.11.0",
|
||||||
|
"@microsoft/sp-tslint-rules": "^1.11.0",
|
||||||
|
"@microsoft/sp-webpart-base": "~1.4.1",
|
||||||
|
"@pnp/common": "^1.3.11",
|
||||||
|
"@pnp/logging": "^1.3.11",
|
||||||
|
"@pnp/odata": "^1.3.11",
|
||||||
|
"@pnp/sp": "^1.3.11",
|
||||||
|
"@pnp/spfx-controls-react": "^1.21.1",
|
||||||
|
"@pnp/spfx-property-controls": "^1.3.0",
|
||||||
|
"@uifabric/file-type-icons": "^7.6.30",
|
||||||
|
"@uifabric/merge-styles": "^7.19.2",
|
||||||
|
"date-fns": "^2.21.2",
|
||||||
|
"enhanced-resolve": "^5.8.0",
|
||||||
|
"idb-keyval": "^5.0.5",
|
||||||
|
"office-ui-fabric-react": "^6.214.1",
|
||||||
|
"react": "^17.0.2",
|
||||||
|
"react-dom": "^17.0.2",
|
||||||
|
"spfx-uifabric-themes": "^0.8.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@microsoft/sp-build-web": "1.4.1",
|
||||||
|
"@microsoft/sp-module-interfaces": "1.4.1",
|
||||||
|
"@microsoft/sp-webpart-workbench": "1.4.1",
|
||||||
|
"@types/chai": "3.4.34",
|
||||||
|
"@types/es6-promise": "0.0.33",
|
||||||
|
"@types/mocha": "2.2.38",
|
||||||
|
"@types/react": "^16.9.19",
|
||||||
|
"@types/react-dom": "^16.9.0",
|
||||||
|
"@types/webpack-env": "1.13.1",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
||||||
|
"@typescript-eslint/parser": "^4.22.0",
|
||||||
|
"ajv": "~5.2.2",
|
||||||
|
"eslint": "^7.25.0",
|
||||||
|
"eslint-plugin-react": "^7.23.2",
|
||||||
|
"eslint-plugin-react-hooks": "^4.2.0",
|
||||||
|
"gulp": "~3.9.1",
|
||||||
|
"gulp-eslint": "^6.0.0",
|
||||||
|
"terser-webpack-plugin-legacy": "^1.2.3",
|
||||||
|
"typescript": "3.9.7",
|
||||||
|
"webpack-merge": "^4.2.1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { INavLinkGroup } from 'office-ui-fabric-react/lib/Nav';
|
||||||
|
export interface IListItemsMenuState {
|
||||||
|
navLinkGroups: INavLinkGroup[];
|
||||||
|
isLoading: boolean;
|
||||||
|
hasError:boolean;
|
||||||
|
errorMessage:string;
|
||||||
|
listName:string;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
import { DisplayMode } from "@microsoft/sp-core-library";
|
||||||
|
import { Theme} from 'spfx-uifabric-themes';
|
||||||
|
|
||||||
|
export interface IListItemsMenuProps {
|
||||||
|
title: string;
|
||||||
|
listId:string;
|
||||||
|
listBaseTemplate:number;
|
||||||
|
fieldName:string;
|
||||||
|
locale:string;
|
||||||
|
themeVariant: Theme | undefined;
|
||||||
|
onConfigure: () => void;
|
||||||
|
displayMode: DisplayMode;
|
||||||
|
updateProperty: (value: string) => void;
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
@import '~office-ui-fabric-react/dist/sass/References.scss';
|
||||||
|
|
||||||
|
.listItemsMenu {
|
||||||
|
.container {
|
||||||
|
max-width: 700px;
|
||||||
|
margin: 0px auto;
|
||||||
|
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;
|
||||||
|
@include ms-fontColor-white;
|
||||||
|
background-color: $ms-color-themeDark;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.column {
|
||||||
|
@include ms-Grid-col;
|
||||||
|
@include ms-lg10;
|
||||||
|
@include ms-xl8;
|
||||||
|
@include ms-xlPush2;
|
||||||
|
@include ms-lgPush1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
@include ms-font-xl;
|
||||||
|
@include ms-fontColor-white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subTitle {
|
||||||
|
@include ms-font-l;
|
||||||
|
@include ms-fontColor-white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
@include ms-font-l;
|
||||||
|
@include ms-fontColor-white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
// Our button
|
||||||
|
text-decoration: none;
|
||||||
|
height: 32px;
|
||||||
|
|
||||||
|
// Primary Button
|
||||||
|
min-width: 80px;
|
||||||
|
background-color: $ms-color-themePrimary;
|
||||||
|
border-color: $ms-color-themePrimary;
|
||||||
|
color: $ms-color-white;
|
||||||
|
|
||||||
|
// Basic Button
|
||||||
|
outline: transparent;
|
||||||
|
position: relative;
|
||||||
|
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
font-weight: $ms-font-weight-regular;
|
||||||
|
border-width: 0;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 16px;
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-weight: $ms-font-weight-semibold;
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
margin: 0 4px;
|
||||||
|
vertical-align: top;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,251 @@
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
import * as React from "react";
|
||||||
|
import * as strings from "ListItemsMenuWebPartStrings";
|
||||||
|
import { filter, findIndex } from "lodash";
|
||||||
|
import {
|
||||||
|
INavLink,
|
||||||
|
INavLinkGroup,
|
||||||
|
INavStyles,
|
||||||
|
Label,
|
||||||
|
Link,
|
||||||
|
mergeStyleSets,
|
||||||
|
MessageBar,
|
||||||
|
MessageBarType,
|
||||||
|
Nav,
|
||||||
|
Spinner,
|
||||||
|
SpinnerSize,
|
||||||
|
Stack,
|
||||||
|
} from "office-ui-fabric-react";
|
||||||
|
|
||||||
|
import {
|
||||||
|
getFileTypeIconProps,
|
||||||
|
initializeFileTypeIcons,
|
||||||
|
} from "@uifabric/file-type-icons";
|
||||||
|
import { useList } from "../hooks/useList";
|
||||||
|
import { IListItemsMenuState } from "./IListItemMenuState";
|
||||||
|
import { IListItemsMenuProps } from "./IListItemsMenuProps";
|
||||||
|
initializeFileTypeIcons();
|
||||||
|
|
||||||
|
export const ListItemsMenu: React.FunctionComponent<IListItemsMenuProps> = (
|
||||||
|
props: IListItemsMenuProps
|
||||||
|
) => {
|
||||||
|
const { getGroupItems, getGroupHeaders, getField } = useList();
|
||||||
|
const [state, setState] = React.useState<IListItemsMenuState>({
|
||||||
|
navLinkGroups: [],
|
||||||
|
isLoading: false,
|
||||||
|
hasError: false,
|
||||||
|
errorMessage: "",
|
||||||
|
listName: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const navStyles: Partial<INavStyles> = React.useMemo(() => {
|
||||||
|
return {
|
||||||
|
group: {
|
||||||
|
fontWeight: 700,
|
||||||
|
},
|
||||||
|
groupContent: {
|
||||||
|
maxHeight: 450,
|
||||||
|
overflow: "auto",
|
||||||
|
"&::-webkit-scrollbar-thumb": {
|
||||||
|
backgroundColor: props.themeVariant?.neutralLighter,
|
||||||
|
},
|
||||||
|
"&::-webkit-scrollbar": {
|
||||||
|
width: 10,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}, [props.themeVariant]);
|
||||||
|
|
||||||
|
const classComponent = React.useMemo(() => {
|
||||||
|
return mergeStyleSets({
|
||||||
|
webPartTitle: {
|
||||||
|
fontWeight: 500,
|
||||||
|
overflowX: "hidden",
|
||||||
|
textOverflow: "Ellipsis",
|
||||||
|
fontSize: props.themeVariant?.["ms-font-large-fontSize"],
|
||||||
|
marginBottom: 10,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, [props.themeVariant]);
|
||||||
|
|
||||||
|
// On Header click get Items for the header
|
||||||
|
const _onGroupHeaderClick = React.useCallback(
|
||||||
|
async (ev: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
||||||
|
try {
|
||||||
|
const _groupName = ev.currentTarget.innerText.split("\n")[1]; // the first Line has icon , text is on 2 line
|
||||||
|
console.log(_groupName);
|
||||||
|
const { navLinkGroups } = stateRef.current;
|
||||||
|
|
||||||
|
const _navGroup = filter(navLinkGroups, { name: _groupName });
|
||||||
|
if (_navGroup?.length && _navGroup[0]?.links?.length === 0) {
|
||||||
|
const _navlinks: INavLink[] = [];
|
||||||
|
const _groupHeaderItems: any[] = await getGroupItems(
|
||||||
|
props.listId,
|
||||||
|
props.fieldName,
|
||||||
|
_groupName
|
||||||
|
);
|
||||||
|
if (_groupHeaderItems?.length) {
|
||||||
|
for (const _groupHeaderItem of _groupHeaderItems) {
|
||||||
|
if (props.listBaseTemplate === 0) {
|
||||||
|
// List
|
||||||
|
_navlinks.push({
|
||||||
|
name: _groupHeaderItem.Title,
|
||||||
|
url: `${_groupHeaderItem.FileDirRef}/dispform.aspx?ID=${_groupHeaderItem.Id}`,
|
||||||
|
iconProps: {
|
||||||
|
iconName: "TaskManager",
|
||||||
|
},
|
||||||
|
key: _groupHeaderItem.Id,
|
||||||
|
target: "_blank",
|
||||||
|
isExpanded: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (props.listBaseTemplate === 1) {
|
||||||
|
// Document Library
|
||||||
|
const _icon: { iconName: string } = getFileTypeIconProps({
|
||||||
|
extension: _groupHeaderItem.DocIcon,
|
||||||
|
size: 16,
|
||||||
|
imageFileType: "png",
|
||||||
|
});
|
||||||
|
|
||||||
|
_navlinks.push({
|
||||||
|
name: _groupHeaderItem.FileLeafRef,
|
||||||
|
url: _groupHeaderItem.FileRef,
|
||||||
|
icon: _icon.iconName,
|
||||||
|
key: _groupHeaderItem.title,
|
||||||
|
target: "_blank",
|
||||||
|
isExpanded: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Update Navigation with Items of Group
|
||||||
|
_navGroup[0].links = _navlinks;
|
||||||
|
}
|
||||||
|
|
||||||
|
const _index = findIndex(navLinkGroups, { name: _groupName });
|
||||||
|
_navGroup[0].collapseByDefault = true;
|
||||||
|
navLinkGroups[_index] = _navGroup[0];
|
||||||
|
stateRef.current = {
|
||||||
|
...stateRef.current,
|
||||||
|
navLinkGroups: navLinkGroups,
|
||||||
|
};
|
||||||
|
setState(stateRef.current);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
[props.fieldName, props.listBaseTemplate, props.listId]
|
||||||
|
);
|
||||||
|
const stateRef = React.useRef(state); // Use to access state on eventListenners
|
||||||
|
// On component did mount only if listId or Field Change
|
||||||
|
React.useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
if (!props.listId || !props.fieldName) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const _navLinksGroups: INavLinkGroup[] = [];
|
||||||
|
stateRef.current = {
|
||||||
|
...stateRef.current,
|
||||||
|
isLoading: true,
|
||||||
|
navLinkGroups: _navLinksGroups,
|
||||||
|
};
|
||||||
|
setState(stateRef.current);
|
||||||
|
|
||||||
|
const _groupHeaders = await getGroupHeaders(
|
||||||
|
props.listId,
|
||||||
|
props.fieldName
|
||||||
|
);
|
||||||
|
const _field: any = await getField(props.listId, props.fieldName);
|
||||||
|
for (const groupHeader of _groupHeaders) {
|
||||||
|
let _name: any;
|
||||||
|
if (_field.fieldType === "TaxonomyFieldType") {
|
||||||
|
_name = groupHeader.Metadata.Label ?? "Unassigned";
|
||||||
|
}
|
||||||
|
if (_field.fieldType === "TaxonomyFieldTypeMulti") {
|
||||||
|
_name = groupHeader.Metadata[0]?.Label ?? "Unassigned";
|
||||||
|
} else {
|
||||||
|
_name = groupHeader[props.fieldName] ?? "Unassigned";
|
||||||
|
|
||||||
|
if (_name != "Unassigned" && _field.fieldType === "User") {
|
||||||
|
_name = _name[0]?.title;
|
||||||
|
}
|
||||||
|
if (_name != "Unassigned" && _field.fieldType === "Lookup") {
|
||||||
|
_name = _name[0]?.lookupValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_navLinksGroups.push({
|
||||||
|
name: _name,
|
||||||
|
collapseByDefault: true,
|
||||||
|
onHeaderClick: _onGroupHeaderClick,
|
||||||
|
links: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
stateRef.current = {
|
||||||
|
...stateRef.current,
|
||||||
|
hasError: false,
|
||||||
|
errorMessage: "",
|
||||||
|
isLoading: false,
|
||||||
|
listName: _field.fieldScope,
|
||||||
|
navLinkGroups: _navLinksGroups,
|
||||||
|
};
|
||||||
|
setState(stateRef.current);
|
||||||
|
} catch (error) {
|
||||||
|
stateRef.current = {
|
||||||
|
...stateRef.current,
|
||||||
|
hasError: true,
|
||||||
|
errorMessage: error.message,
|
||||||
|
};
|
||||||
|
setState(stateRef.current);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [props.listId, props.fieldName, props.listBaseTemplate]);
|
||||||
|
|
||||||
|
// Show Error if Exists
|
||||||
|
if (state.hasError) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<MessageBar messageBarType={MessageBarType.error} isMultiline>
|
||||||
|
{state.errorMessage}
|
||||||
|
</MessageBar>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// render component
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{state.isLoading ? (
|
||||||
|
<Stack horizontal horizontalAlign="center">
|
||||||
|
<Spinner size={SpinnerSize.medium}></Spinner>
|
||||||
|
</Stack>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Stack
|
||||||
|
horizontalAlign="space-between"
|
||||||
|
horizontal
|
||||||
|
tokens={{ childrenGap: 10 }}
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
>
|
||||||
|
<div className={classComponent.webPartTitle}>{props.title}</div>
|
||||||
|
<Link href={state.listName}>View All</Link>
|
||||||
|
</Stack>
|
||||||
|
{state.navLinkGroups?.length === 0 ? (
|
||||||
|
<Label
|
||||||
|
style={{
|
||||||
|
fontWeight: 400,
|
||||||
|
fontSize: props.themeVariant?.["ms-font-small-fontSize"],
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{strings.NodocumentsLabel}
|
||||||
|
</Label>
|
||||||
|
) : (
|
||||||
|
<Nav styles={navStyles} groups={state.navLinkGroups}></Nav>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,80 @@
|
||||||
|
export interface IFieldInfo {
|
||||||
|
DefaultFormula: string | null;
|
||||||
|
DefaultValue: string | null;
|
||||||
|
Description: string;
|
||||||
|
Direction: string;
|
||||||
|
EnforceUniqueValues: boolean;
|
||||||
|
EntityPropertyName: string;
|
||||||
|
FieldTypeKind: FieldTypes;
|
||||||
|
Filterable: boolean;
|
||||||
|
FromBaseType: boolean;
|
||||||
|
Group: string;
|
||||||
|
Hidden: boolean;
|
||||||
|
Id: string;
|
||||||
|
Indexed: boolean;
|
||||||
|
IndexStatus: number;
|
||||||
|
InternalName: string;
|
||||||
|
JSLink: string;
|
||||||
|
PinnedToFiltersPane: boolean;
|
||||||
|
ReadOnlyField: boolean;
|
||||||
|
Required: boolean;
|
||||||
|
SchemaXml: string;
|
||||||
|
Scope: string;
|
||||||
|
Sealed: boolean;
|
||||||
|
ShowInFiltersPane: number;
|
||||||
|
Sortable: boolean;
|
||||||
|
StaticName: string;
|
||||||
|
Title: string;
|
||||||
|
TypeAsString: string;
|
||||||
|
TypeDisplayName: string;
|
||||||
|
TypeShortDescription: string;
|
||||||
|
ValidationFormula: string | null;
|
||||||
|
ValidationMessage: string | null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Specifies the type of the field.
|
||||||
|
*/
|
||||||
|
export enum FieldTypes {
|
||||||
|
Invalid = 0,
|
||||||
|
Integer = 1,
|
||||||
|
Text = 2,
|
||||||
|
Note = 3,
|
||||||
|
DateTime = 4,
|
||||||
|
Counter = 5,
|
||||||
|
Choice = 6,
|
||||||
|
Lookup = 7,
|
||||||
|
Boolean = 8,
|
||||||
|
Number = 9,
|
||||||
|
Currency = 10,
|
||||||
|
URL = 11,
|
||||||
|
Computed = 12,
|
||||||
|
Threading = 13,
|
||||||
|
Guid = 14,
|
||||||
|
MultiChoice = 15,
|
||||||
|
GridChoice = 16,
|
||||||
|
Calculated = 17,
|
||||||
|
File = 18,
|
||||||
|
Attachments = 19,
|
||||||
|
User = 20,
|
||||||
|
Recurrence = 21,
|
||||||
|
CrossProjectLink = 22,
|
||||||
|
ModStat = 23,
|
||||||
|
Error = 24,
|
||||||
|
ContentTypeId = 25,
|
||||||
|
PageSeparator = 26,
|
||||||
|
ThreadIndex = 27,
|
||||||
|
WorkflowStatus = 28,
|
||||||
|
AllDayEvent = 29,
|
||||||
|
WorkflowEventType = 30,
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum DateTimeFieldFormatType {
|
||||||
|
DateOnly = 0,
|
||||||
|
DateTime = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum DateTimeFieldFriendlyFormatType {
|
||||||
|
Unspecified = 0,
|
||||||
|
Disabled = 1,
|
||||||
|
Relative = 2,
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
import { IFieldInfo } from ".";
|
||||||
|
|
||||||
|
export interface IListInfo {
|
||||||
|
AllowContentTypes: boolean;
|
||||||
|
AllowDeletion: boolean;
|
||||||
|
BaseTemplate: number;
|
||||||
|
BaseType: any;
|
||||||
|
BrowserFileHandling: any;
|
||||||
|
ContentTypes: any[];
|
||||||
|
ContentTypesEnabled: boolean;
|
||||||
|
CrawlNonDefaultViews: boolean;
|
||||||
|
CreatablesInfo: any;
|
||||||
|
Created: string;
|
||||||
|
CurrentChangeToken: any;
|
||||||
|
CustomActionElements: any[];
|
||||||
|
DataSource: any;
|
||||||
|
DefaultContentApprovalWorkflowId: string;
|
||||||
|
DefaultDisplayFormUrl: string;
|
||||||
|
DefaultEditFormUrl: string;
|
||||||
|
DefaultNewFormUrl: string;
|
||||||
|
DefaultView: any;
|
||||||
|
DefaultViewPath: any;
|
||||||
|
DefaultViewUrl: string;
|
||||||
|
Description: string;
|
||||||
|
DescriptionResource: any;
|
||||||
|
Direction: string;
|
||||||
|
DocumentTemplateUrl: string;
|
||||||
|
DraftVersionVisibility: any;
|
||||||
|
EffectiveBasePermissions: any;
|
||||||
|
EffectiveBasePermissionsForUI: any;
|
||||||
|
EnableAssignToEmail: boolean;
|
||||||
|
EnableAttachments: boolean;
|
||||||
|
EnableFolderCreation: boolean;
|
||||||
|
EnableMinorVersions: boolean;
|
||||||
|
EnableModeration: boolean;
|
||||||
|
EnableRequestSignOff: boolean;
|
||||||
|
EnableVersioning: boolean;
|
||||||
|
EntityTypeName: string;
|
||||||
|
EventReceivers: any[];
|
||||||
|
ExcludeFromOfflineClient: boolean;
|
||||||
|
ExemptFromBlockDownloadOfNonViewableFiles: boolean;
|
||||||
|
Fields: Partial<IFieldInfo>[];
|
||||||
|
FileSavePostProcessingEnabled: boolean;
|
||||||
|
ForceCheckout: boolean;
|
||||||
|
Forms: any[];
|
||||||
|
HasExternalDataSource: boolean;
|
||||||
|
Hidden: boolean;
|
||||||
|
Id: string;
|
||||||
|
ImagePath: { DecodedUrl: string };
|
||||||
|
ImageUrl: string;
|
||||||
|
InformationRightsManagementSettings: any[];
|
||||||
|
IrmEnabled: boolean;
|
||||||
|
IrmExpire: boolean;
|
||||||
|
IrmReject: boolean;
|
||||||
|
IsApplicationList: boolean;
|
||||||
|
IsCatalog: boolean;
|
||||||
|
IsPrivate: boolean;
|
||||||
|
IsSiteAssetsLibrary: boolean;
|
||||||
|
IsSystemList: boolean;
|
||||||
|
ItemCount: number;
|
||||||
|
LastItemDeletedDate: string;
|
||||||
|
LastItemModifiedDate: string;
|
||||||
|
LastItemUserModifiedDate: string;
|
||||||
|
ListExperienceOptions: number;
|
||||||
|
ListItemEntityTypeFullName: string;
|
||||||
|
MajorVersionLimit: number;
|
||||||
|
MajorWithMinorVersionsLimit: number;
|
||||||
|
MultipleDataList: boolean;
|
||||||
|
NoCrawl: boolean;
|
||||||
|
OnQuickLaunch: boolean;
|
||||||
|
ParentWebPath: { DecodedUrl: string };
|
||||||
|
ParentWebUrl: string;
|
||||||
|
ParserDisabled: boolean;
|
||||||
|
ReadSecurity: number;
|
||||||
|
RootFolder: any;
|
||||||
|
SchemaXml: string;
|
||||||
|
ServerTemplateCanCreateFolders: boolean;
|
||||||
|
TemplateFeatureId: string;
|
||||||
|
Title: string;
|
||||||
|
UserCustomActions: any[];
|
||||||
|
ValidationFormula: string;
|
||||||
|
ValidationMessage: string;
|
||||||
|
Views: any[];
|
||||||
|
WorkflowAssociations: any[];
|
||||||
|
WriteSecurity: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IRenderListDataAsStreamResult {
|
||||||
|
CurrentFolderSpItemUrl: string;
|
||||||
|
FilterLink: string;
|
||||||
|
FirstRow: number;
|
||||||
|
FolderPermissions: string;
|
||||||
|
ForceNoHierarchy: string;
|
||||||
|
HierarchyHasIndention: string;
|
||||||
|
LastRow: number;
|
||||||
|
NextHref?: string;
|
||||||
|
Row: any[];
|
||||||
|
RowLimit: number;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
export interface IListItemsMenu {
|
||||||
|
groupBy:string;
|
||||||
|
id:string;
|
||||||
|
title:string;
|
||||||
|
url:string;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export * from './IFieldInfo';
|
||||||
|
export * from './IListInfo';
|
||||||
|
export * from './IListItemsMenu';
|
||||||
|
|
|
@ -0,0 +1,150 @@
|
||||||
|
import {
|
||||||
|
sortBy,
|
||||||
|
uniqBy
|
||||||
|
} from "lodash";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
|
import { sp, } from "@pnp/sp";
|
||||||
|
import { IFieldInfo } from "../entities";
|
||||||
|
import { IListInfo } from "../entities";
|
||||||
|
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
|
export const useList = () => {
|
||||||
|
// Run on useList hook
|
||||||
|
|
||||||
|
// Get List Columns
|
||||||
|
const getListColumns = async (listId: string): Promise<IFieldInfo[]> => {
|
||||||
|
const _listColumnsResults: IFieldInfo[] = await sp.web.lists
|
||||||
|
.getById(listId)
|
||||||
|
.fields.filter("Hidden eq false")
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const _wColumns: IFieldInfo[] = uniqBy(
|
||||||
|
sortBy(_listColumnsResults, "Title"),
|
||||||
|
"Title"
|
||||||
|
);
|
||||||
|
return _wColumns;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getField = async (listId: string, field: string): Promise<any> => {
|
||||||
|
const _field: IFieldInfo = await sp.web.lists
|
||||||
|
.getById(listId)
|
||||||
|
.fields.getByInternalNameOrTitle(field)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const fieldType = _field.TypeAsString;
|
||||||
|
const fieldScope = _field.Scope;
|
||||||
|
return { fieldType, fieldScope };
|
||||||
|
}
|
||||||
|
|
||||||
|
const getGroupHeaders = async (
|
||||||
|
listId: string,
|
||||||
|
groupByField: string ): Promise<any[]> => {
|
||||||
|
const _viewXml = `<View Scope='Recursive'>
|
||||||
|
<Query>
|
||||||
|
<GroupBy Collapse="TRUE">
|
||||||
|
<FieldRef Name="${groupByField}"/>
|
||||||
|
</GroupBy>
|
||||||
|
</Query>
|
||||||
|
<RowLimit>1000</RowLimit>
|
||||||
|
</View>`;
|
||||||
|
|
||||||
|
const _groupHeadersResults = await sp.web.lists
|
||||||
|
.getById(listId)
|
||||||
|
.renderListDataAsStream({ ViewXml: _viewXml });
|
||||||
|
|
||||||
|
//console.log("groups", _groupHeadersResults.Row);
|
||||||
|
return uniqBy(_groupHeadersResults.Row, groupByField);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getGroupItems = async (
|
||||||
|
listId: string,
|
||||||
|
groupByField: string,
|
||||||
|
groupFieldValue: string ): Promise<any[]> => {
|
||||||
|
const _field: any = await getField(listId, groupByField);
|
||||||
|
|
||||||
|
switch (_field.fieldType) {
|
||||||
|
case "DateTime":
|
||||||
|
groupFieldValue =
|
||||||
|
groupFieldValue != "Unassigned"
|
||||||
|
? moment(groupFieldValue).format("YYYY-MM-DD")
|
||||||
|
: "Unassigned";
|
||||||
|
break;
|
||||||
|
case "AllDayEvent":
|
||||||
|
groupFieldValue = groupFieldValue === "No" ? "0" : "1";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let _viewXml = `<View Scope='Recursive'>
|
||||||
|
<Query>
|
||||||
|
<OrderBy>
|
||||||
|
<FieldRef Name="${groupByField}" Ascending="FALSE"></FieldRef>
|
||||||
|
</OrderBy>
|
||||||
|
</Query>
|
||||||
|
</View>`;
|
||||||
|
|
||||||
|
if (groupFieldValue != "Unassigned") {
|
||||||
|
_viewXml = `<View Scope='Recursive'>
|
||||||
|
<Query>
|
||||||
|
<OrderBy>
|
||||||
|
<FieldRef Name="${groupByField}" Ascending="FALSE"></FieldRef>
|
||||||
|
</OrderBy>
|
||||||
|
<Where>
|
||||||
|
<Eq>
|
||||||
|
<FieldRef Name="${groupByField}"></FieldRef>
|
||||||
|
<Value Type="${_field.fieldType}" IncludeTimeValue="FALSE">${groupFieldValue}</Value>
|
||||||
|
</Eq>
|
||||||
|
</Where>
|
||||||
|
</Query>
|
||||||
|
</View>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupFieldValue === "Unassigned") {
|
||||||
|
_viewXml = `<View Scope='Recursive'>
|
||||||
|
<Query>
|
||||||
|
<OrderBy>
|
||||||
|
<FieldRef Name="${groupByField}" Ascending="FALSE"></FieldRef>
|
||||||
|
</OrderBy>
|
||||||
|
<Where>
|
||||||
|
<IsNull>
|
||||||
|
<FieldRef Name="${groupByField}"></FieldRef>
|
||||||
|
</IsNull>
|
||||||
|
</Where>
|
||||||
|
</Query>
|
||||||
|
</View>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const _groupItemsResults = await sp.web.lists
|
||||||
|
.getById(listId)
|
||||||
|
.renderListDataAsStream({ ViewXml: _viewXml });
|
||||||
|
|
||||||
|
console.log("items", _groupItemsResults.Row);
|
||||||
|
return _groupItemsResults.Row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Lists
|
||||||
|
const getLists = async (baseTemplate: number): Promise<IListInfo[]> => {
|
||||||
|
let _filter = "Hidden eq false and ";
|
||||||
|
if (baseTemplate === 0) {
|
||||||
|
_filter = _filter + " BaseType ne 1";
|
||||||
|
} else {
|
||||||
|
_filter = _filter + " BaseType eq 1";
|
||||||
|
}
|
||||||
|
const _lists: IListInfo[] = await sp.web.lists.filter(_filter).get();
|
||||||
|
|
||||||
|
console.log("lists", _lists);
|
||||||
|
return _lists;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return functions
|
||||||
|
return {
|
||||||
|
getListColumns,
|
||||||
|
getLists,
|
||||||
|
getGroupItems,
|
||||||
|
getGroupHeaders,
|
||||||
|
getField,
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1 @@
|
||||||
|
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||||
|
"id": "64e3a357-6678-4553-ab7c-f37422308b22",
|
||||||
|
"alias": "ListItemsMenuWebPart",
|
||||||
|
"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,
|
||||||
|
|
||||||
|
|
||||||
|
"preconfiguredEntries": [{
|
||||||
|
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||||
|
"group": { "default": "SPFx Custom Web Parts" },
|
||||||
|
"title": { "default": "List menu documents " },
|
||||||
|
"description": { "default": "Documents" },
|
||||||
|
"officeFabricIconFontName": "GroupedList",
|
||||||
|
"properties": {
|
||||||
|
"title": "Documents",
|
||||||
|
"listId": "",
|
||||||
|
"fieldName": "Title",
|
||||||
|
"listBasetemplate": 1
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
|
@ -0,0 +1,240 @@
|
||||||
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
import * as React from "react";
|
||||||
|
import * as ReactDom from "react-dom";
|
||||||
|
import { Theme } from "spfx-uifabric-themes"
|
||||||
|
import * as strings from "ListItemsMenuWebPartStrings";
|
||||||
|
import {
|
||||||
|
MessageBarType,
|
||||||
|
SpinnerSize
|
||||||
|
} from "office-ui-fabric-react";
|
||||||
|
|
||||||
|
|
||||||
|
import {
|
||||||
|
IPropertyPaneConfiguration,
|
||||||
|
IPropertyPaneDropdownOption,
|
||||||
|
IPropertyPaneField,
|
||||||
|
IPropertyPaneGroup,
|
||||||
|
IPropertyPanePage,
|
||||||
|
PropertyPaneDropdown,
|
||||||
|
PropertyPaneTextField
|
||||||
|
} from "@microsoft/sp-webpart-base";
|
||||||
|
import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base";
|
||||||
|
import { sp } from "@pnp/sp";
|
||||||
|
import {
|
||||||
|
PropertyFieldListPicker,
|
||||||
|
PropertyFieldListPickerOrderBy
|
||||||
|
} from "@pnp/spfx-property-controls/lib/PropertyFieldListPicker";
|
||||||
|
import {
|
||||||
|
PropertyFieldMessage
|
||||||
|
} from "@pnp/spfx-property-controls/lib/PropertyFieldMessage";
|
||||||
|
import {
|
||||||
|
PropertyFieldSpinner
|
||||||
|
} from "@pnp/spfx-property-controls/lib/PropertyFieldSpinner";
|
||||||
|
|
||||||
|
import { IListItemsMenuProps } from "../../components/IListItemsMenuProps";
|
||||||
|
import { ListItemsMenu } from "../../components/ListItemsMenu";
|
||||||
|
import { useList } from "../../hooks/useList";
|
||||||
|
|
||||||
|
export interface IListItemsMenuWebPartProps {
|
||||||
|
title: string;
|
||||||
|
listId: string;
|
||||||
|
fieldName: string;
|
||||||
|
listBasetemplate: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const theme = window.__themeState__.theme;
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
|
const { getListColumns, getLists } = useList() ;
|
||||||
|
|
||||||
|
export default class ListItemsMenuWebPart extends BaseClientSideWebPart<
|
||||||
|
IListItemsMenuWebPartProps
|
||||||
|
> {
|
||||||
|
private columns: IPropertyPaneDropdownOption[] = [];
|
||||||
|
private lists: IPropertyPaneDropdownOption[] = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private _messageError: string = undefined;
|
||||||
|
private _hasError: any;
|
||||||
|
|
||||||
|
|
||||||
|
protected async onInit(): Promise<void> {
|
||||||
|
|
||||||
|
sp.setup({
|
||||||
|
spfxContext: this.context,
|
||||||
|
});
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public render(): void {
|
||||||
|
|
||||||
|
const element: React.ReactElement<IListItemsMenuProps> = React.createElement(
|
||||||
|
ListItemsMenu,
|
||||||
|
{
|
||||||
|
title: this.properties.title,
|
||||||
|
listId: this.properties.listId,
|
||||||
|
fieldName: this.properties.fieldName,
|
||||||
|
themeVariant: theme,
|
||||||
|
locale: this.context.pageContext.cultureInfo.currentUICultureName,
|
||||||
|
listBaseTemplate: this.properties.listBasetemplate,
|
||||||
|
onConfigure: () =>{ this.context.propertyPane.open(); },
|
||||||
|
displayMode: this.displayMode,
|
||||||
|
updateProperty: (value: string) => {
|
||||||
|
this.properties.title = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ReactDom.render(element, this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onDispose(): void {
|
||||||
|
ReactDom.unmountComponentAtNode(this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get disableReactivePropertyChanges():boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async onPropertyPaneConfigurationStart() {
|
||||||
|
if (
|
||||||
|
this.properties.fieldName &&
|
||||||
|
this.properties.listId &&
|
||||||
|
this.columns.length === 0
|
||||||
|
) {
|
||||||
|
await this.addListColumns(this.properties.listId);
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( this.properties.listId && this.lists.length === 0){
|
||||||
|
await this.addLists('1');
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async onPropertyPaneFieldChanged(
|
||||||
|
propertyPath: string,
|
||||||
|
oldValue: any,
|
||||||
|
|
||||||
|
newValue: any
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (propertyPath === "listId" && newValue != oldValue) {
|
||||||
|
this.columns = [];
|
||||||
|
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
await this.addListColumns(newValue);
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async addLists(newValue: any) {
|
||||||
|
try {
|
||||||
|
this.lists = [];
|
||||||
|
const _lists = await getLists(newValue);
|
||||||
|
console.log(_lists);
|
||||||
|
for (const _list of _lists) {
|
||||||
|
this.lists.push({ key: _list.Id, text: _list.Title });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this._hasError = true;
|
||||||
|
this._messageError =error.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async addListColumns(newValue: any) {
|
||||||
|
try {
|
||||||
|
this.columns = [];
|
||||||
|
const _listColumns = await getListColumns(newValue);
|
||||||
|
console.log(_listColumns);
|
||||||
|
for (const _column of _listColumns) {
|
||||||
|
this.columns.push({ key: _column.InternalName, text: _column.Title });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this._hasError = true;
|
||||||
|
this._messageError = error.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||||
|
const _pages: IPropertyPanePage[] = [
|
||||||
|
{
|
||||||
|
header: {
|
||||||
|
description: strings.PropertyPaneDescription,
|
||||||
|
},
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
groupName: strings.BasicGroupName,
|
||||||
|
groupFields: [
|
||||||
|
PropertyPaneTextField("title", {
|
||||||
|
label: strings.DescriptionFieldLabel,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const groups: IPropertyPaneGroup = _pages[0].groups[0] as IPropertyPaneGroup;
|
||||||
|
const groupFields: IPropertyPaneField<any>[] = groups.groupFields;
|
||||||
|
groupFields.push(
|
||||||
|
PropertyFieldListPicker("listId", {
|
||||||
|
label: "Select Document Library",
|
||||||
|
selectedList: this.properties.listId ,
|
||||||
|
includeHidden: false,
|
||||||
|
baseTemplate: 101,
|
||||||
|
orderBy: PropertyFieldListPickerOrderBy.Title,
|
||||||
|
disabled: false,
|
||||||
|
onPropertyChange: this.onPropertyPaneFieldChanged.bind(this),
|
||||||
|
properties: this.properties,
|
||||||
|
context: this.context,
|
||||||
|
onGetErrorMessage: null,
|
||||||
|
deferredValidationTime: 0,
|
||||||
|
key: "listPickerFieldId",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (this.properties.listId) {
|
||||||
|
groupFields.push(
|
||||||
|
PropertyFieldSpinner("", {
|
||||||
|
key: "sp1",
|
||||||
|
size: SpinnerSize.medium,
|
||||||
|
isVisible: (this.columns.length || this._hasError) ? false : true,
|
||||||
|
label: "Loading ...",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show Columns
|
||||||
|
if (this.columns.length > 0) {
|
||||||
|
groupFields.push(
|
||||||
|
PropertyPaneDropdown("fieldName", {
|
||||||
|
label: "Select field to group by documents",
|
||||||
|
options: this.columns,
|
||||||
|
selectedKey: this.properties.fieldName,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show Error
|
||||||
|
if (this._hasError) {
|
||||||
|
groupFields.push(
|
||||||
|
PropertyFieldMessage("", {
|
||||||
|
key: "msgError",
|
||||||
|
messageType: MessageBarType.error,
|
||||||
|
multiline: true,
|
||||||
|
text: this._messageError,
|
||||||
|
isVisible: this._hasError,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const _panelConfiguration: IPropertyPaneConfiguration = { pages: _pages };
|
||||||
|
return _panelConfiguration;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
define([], function() {
|
||||||
|
return {
|
||||||
|
"PropertyPaneDescription": "Show documents grouped by field",
|
||||||
|
"BasicGroupName": "Properties",
|
||||||
|
"DescriptionFieldLabel": "Title",
|
||||||
|
"NodocumentsLabel":"No documents found in library"
|
||||||
|
}
|
||||||
|
});
|
11
samples/react-list-items-menu-sp2019/src/webparts/listItemsMenu/loc/mystrings.d.ts
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
declare interface IListItemsMenuWebPartStrings {
|
||||||
|
PropertyPaneDescription: string;
|
||||||
|
BasicGroupName: string;
|
||||||
|
DescriptionFieldLabel: string;
|
||||||
|
NodocumentsLabel:string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'ListItemsMenuWebPartStrings' {
|
||||||
|
const strings: IListItemsMenuWebPartStrings;
|
||||||
|
export = strings;
|
||||||
|
}
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 383 B |
|
@ -0,0 +1,64 @@
|
||||||
|
/**
|
||||||
|
* This script updates the package-solution version analogue to the
|
||||||
|
* the package.json file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (process.env.npm_package_version === undefined) {
|
||||||
|
|
||||||
|
throw 'Package version cannot be evaluated';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// define path to package-solution file
|
||||||
|
const solution = './config/package-solution.json',
|
||||||
|
teams = './teams/manifest.json';
|
||||||
|
|
||||||
|
// require filesystem instance
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// get next automated package version from process variable
|
||||||
|
const nextPkgVersion = process.env.npm_package_version;
|
||||||
|
|
||||||
|
// make sure next build version match
|
||||||
|
const nextVersion = nextPkgVersion.indexOf('-') === -1 ?
|
||||||
|
nextPkgVersion : nextPkgVersion.split('-')[0];
|
||||||
|
|
||||||
|
// Update version in SPFx package-solution if exists
|
||||||
|
if (fs.existsSync(solution)) {
|
||||||
|
|
||||||
|
// read package-solution file
|
||||||
|
const solutionFileContent = fs.readFileSync(solution, 'UTF-8');
|
||||||
|
// parse file as json
|
||||||
|
const solutionContents = JSON.parse(solutionFileContent);
|
||||||
|
|
||||||
|
// set property of version to next version
|
||||||
|
solutionContents.solution.version = nextVersion + '.0';
|
||||||
|
|
||||||
|
// save file
|
||||||
|
fs.writeFileSync(
|
||||||
|
solution,
|
||||||
|
// convert file back to proper json
|
||||||
|
JSON.stringify(solutionContents, null, 2),
|
||||||
|
'UTF-8');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update version in teams manifest if exists
|
||||||
|
if (fs.existsSync(teams)) {
|
||||||
|
|
||||||
|
// read package-solution file
|
||||||
|
const teamsManifestContent = fs.readFileSync(teams, 'UTF-8');
|
||||||
|
// parse file as json
|
||||||
|
const teamsContent = JSON.parse(teamsManifestContent);
|
||||||
|
|
||||||
|
// set property of version to next version
|
||||||
|
teamsContent.version = nextVersion;
|
||||||
|
|
||||||
|
// save file
|
||||||
|
fs.writeFileSync(
|
||||||
|
teams,
|
||||||
|
// convert file back to proper json
|
||||||
|
JSON.stringify(teamsContent, null, 2),
|
||||||
|
'UTF-8');
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.7/includes/tsconfig-web.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"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": [
|
||||||
|
"es5",
|
||||||
|
"dom",
|
||||||
|
"es2015.collection"
|
||||||
|
],
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"esModuleInterop": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts",
|
||||||
|
"src/**/*.tsx"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"lib"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"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-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();
|
|
@ -56,12 +56,6 @@ Version|Date|Comments
|
||||||
1.0.1|February 18, 2021|Added support for metadata columns
|
1.0.1|February 18, 2021|Added support for metadata columns
|
||||||
1.0.2|February 21, 2021|Fixed `gulp build` issues
|
1.0.2|February 21, 2021|Fixed `gulp build` issues
|
||||||
|
|
||||||
## 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
|
## Minimal Path to Awesome
|
||||||
|
|
||||||
- Clone this repository
|
- Clone this repository
|
||||||
|
@ -74,5 +68,21 @@ Version|Date|Comments
|
||||||
- Add to AppCatalog and deploy
|
- Add to AppCatalog and deploy
|
||||||
- go to SharePoint Admin Center and Approve required API Permissions
|
- go to SharePoint Admin Center and Approve required API Permissions
|
||||||
|
|
||||||
|
## 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.**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
We do not support samples, but we do use GitHub to track issues and constantly want to improve these samples.
|
||||||
|
|
||||||
|
If you encounter any issues while using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=react-list-items-menu&authors=@joaojmendes%20@Ravikadri&title=react-list-items-menu%20-%20).
|
||||||
|
|
||||||
|
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=react-list-items-menu&authors=@joaojmendes%20@Ravikadri&title=react-list-items-menu%20-%20).
|
||||||
|
|
||||||
|
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=react-list-items-menu&authors=@joaojmendes%20@Ravikadri&title=react-list-items-menu%20-%20).
|
||||||
|
|
||||||
|
|
||||||
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-list-items-menu" />
|
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-list-items-menu" />
|
||||||
|
|
|
@ -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,27 @@
|
||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2020,
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"react": {
|
||||||
|
"version": "detect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignorePatterns": ["*.js"],
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:react-hooks/recommended",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:react/recommended"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
# 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
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"@pnp/generator-spfx": {
|
||||||
|
"framework": "react",
|
||||||
|
"pnpFramework": "reactjs.plus",
|
||||||
|
"pnp-libraries": [
|
||||||
|
"@pnp/pnpjs",
|
||||||
|
"@pnp/spfx-property-controls",
|
||||||
|
"spfx-uifabric-themes",
|
||||||
|
"lodash",
|
||||||
|
"@pnp/spfx-controls-react",
|
||||||
|
"ouifr@7"
|
||||||
|
],
|
||||||
|
"pnp-ci": "no-devops",
|
||||||
|
"pnp-vetting": [],
|
||||||
|
"spfxenv": "onprem19",
|
||||||
|
"pnp-testing": []
|
||||||
|
},
|
||||||
|
"@microsoft/generator-sharepoint": {
|
||||||
|
"environment": "onprem19",
|
||||||
|
"framework": "react",
|
||||||
|
"isCreatingSolution": true,
|
||||||
|
"version": "1.11.0",
|
||||||
|
"libraryName": "react-banner",
|
||||||
|
"libraryId": "e8b4422e-9b4e-431d-81d6-ebe6bae3c8a1",
|
||||||
|
"packageManager": "npm",
|
||||||
|
"componentType": "webpart"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
# News Banner
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
This web part shows news information as a Banner, this information come from a list defined in any site, this web part can be installed on 2019, and SharePoint Online.
|
||||||
|
|
||||||
|
![NewsBanner](./assets/NewsBanner.png)
|
||||||
|
![NewsBanner](./assets/NewsBanner.gif)
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
![SPFx 1.4.1](https://img.shields.io/badge/SPFx-1.4.1-green.svg)
|
||||||
|
![Node.js LTS 6.x | LTS 8.x](https://img.shields.io/badge/Node.js-LTS%206.x%20%7C%20LTS%208.x-green.svg)
|
||||||
|
![SharePoint 2019 | Online](https://img.shields.io/badge/SharePoint-2019%20%7C%20Online-yellow.svg)
|
||||||
|
![Teams No: Not designed for Microsoft Teams](https://img.shields.io/badge/Teams-No-red.svg "Not designed for Microsoft Teams")
|
||||||
|
![Workbench Hosted: Does not work with local workbench](https://img.shields.io/badge/Workbench-Hosted-yellow.svg "Does not work with local workbench")
|
||||||
|
|
||||||
|
## Applies to
|
||||||
|
|
||||||
|
- [SharePoint Framework](https://aka.ms/spfx)
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
Solution|Author(s)
|
||||||
|
--------|---------
|
||||||
|
react-news-banner |[João Mendes](https://github.com/joaojmendes), Storm Technology, ([@joaojmendes](https://twitter.com/joaojmendes))
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
Version|Date|Comments
|
||||||
|
-------|----|--------
|
||||||
|
1.0|May, 2021|Initial release
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
No pre-requisites
|
||||||
|
|
||||||
|
## Minimal Path to Awesome
|
||||||
|
|
||||||
|
- Clone this repository
|
||||||
|
- Ensure that you are at the solution folder
|
||||||
|
- in the command-line run:
|
||||||
|
- `npm install`
|
||||||
|
- `gulp serve`
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
This web part shows how to use PnPjs, Office-ui-fabric-react, @pnp/spfx-controls-react, @pnp/spfx-property-controls to create an News Banner
|
||||||
|
|
||||||
|
|
||||||
|
## 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.**
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
We do not support samples, but we do use GitHub to track issues and constantly want to improve these samples.
|
||||||
|
|
||||||
|
If you encounter any issues while using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=react-news-banner&authors=@joaojmendes&title=react-news-banner%20-%20).
|
||||||
|
|
||||||
|
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=react-news-banner&authors=@joaojmendes&title=react-news-banner%20-%20).
|
||||||
|
|
||||||
|
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=react-news-banner&authors=@joaojmendes&title=react-news-banner%20-%20).
|
||||||
|
|
||||||
|
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-news-banner" />
|
After Width: | Height: | Size: 13 MiB |
After Width: | Height: | Size: 2.9 MiB |
|
@ -0,0 +1,58 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "pnp-sp-dev-spfx-web-parts-react-news-banner",
|
||||||
|
"source": "pnp",
|
||||||
|
"title": "News Banner",
|
||||||
|
"shortDescription": "Shows news information as a Banner, this information come from a list defined in any site.",
|
||||||
|
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-news-banner",
|
||||||
|
"longDescription": [
|
||||||
|
"This web part shows news information as a Banner, this information come from a list defined in any site, this web part can be installed on 2019, and SharePoint Online."
|
||||||
|
],
|
||||||
|
"creationDateTime": "2021-05-06",
|
||||||
|
"updateDateTime": "2021-05-06",
|
||||||
|
"products": [
|
||||||
|
"SharePoint",
|
||||||
|
"Office"
|
||||||
|
],
|
||||||
|
"metadata": [
|
||||||
|
{
|
||||||
|
"key": "CLIENT-SIDE-DEV",
|
||||||
|
"value": "React"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "SPFX-VERSION",
|
||||||
|
"value": "1.4.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thumbnails": [
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"order": 100,
|
||||||
|
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-news-banner/assets/NewsBanner.gif",
|
||||||
|
"alt": "Web Part Preview"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"order": 101,
|
||||||
|
"url": "https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-news-banner/assets/NewsBanner.png?raw=true",
|
||||||
|
"alt": "List Items Menu"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"gitHubAccount": "joaojmendes",
|
||||||
|
"company": "Storm Technology Ltd",
|
||||||
|
"pictureUrl": "https://github.com/joaojmendes.png",
|
||||||
|
"name": "Jo\u00E3o Mendes",
|
||||||
|
"twitter": "joaojmendes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"name": "Build your first SharePoint client-side web part",
|
||||||
|
"description": "Client-side web parts are client-side components that run in the context of a SharePoint page. Client-side web parts can be deployed to SharePoint environments that support the SharePoint Framework. You can also use modern JavaScript web frameworks, tools, and libraries to build them.",
|
||||||
|
"url": "https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||||
|
"version": "2.0",
|
||||||
|
"bundles": {
|
||||||
|
"banner-web-part": {
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"entrypoint": "./lib/webparts/banner/BannerWebPart.js",
|
||||||
|
"manifest": "./src/webparts/banner/BannerWebPart.manifest.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"externals": {},
|
||||||
|
"localizedResources": {
|
||||||
|
"BannerWebPartStrings": "lib/webparts/banner/loc/{locale}.js",
|
||||||
|
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js",
|
||||||
|
"PropertyControlStrings": "node_modules/@pnp/spfx-property-controls/lib/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": "react-banner",
|
||||||
|
"accessKey": "<!-- ACCESS KEY -->"
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||||
|
"solution": {
|
||||||
|
"name": "react-banner-client-side-solution",
|
||||||
|
"id": "e8b4422e-9b4e-431d-81d6-ebe6bae3c8a1",
|
||||||
|
"version": "1.0.0.0",
|
||||||
|
"includeClientSideAssets": true,
|
||||||
|
"skipFeatureDeployment": true
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"zippedPackage": "solution/react-banner.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,57 @@
|
||||||
|
// gulpfile.js
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const gulp = require('gulp');
|
||||||
|
const build = require('@microsoft/sp-build-web');
|
||||||
|
const merge = require('webpack-merge');
|
||||||
|
const TerserPlugin = require('terser-webpack-plugin-legacy');
|
||||||
|
build.addSuppression(/Warning - \[sass\] The local CSS class .* is not camelCase and will not be type-safe./gi);
|
||||||
|
|
||||||
|
// force use of projects specified typescript version
|
||||||
|
const typeScriptConfig = require('@microsoft/gulp-core-build-typescript/lib/TypeScriptConfiguration');
|
||||||
|
typeScriptConfig.TypeScriptConfiguration.setTypescriptCompiler(require('typescript'));
|
||||||
|
|
||||||
|
// disable tslint
|
||||||
|
build.tslint.enabled = false;
|
||||||
|
|
||||||
|
const eslint = require('gulp-eslint');
|
||||||
|
|
||||||
|
const eslintSubTask = build.subTask('eslint', function (gulp, buildOptions, done) {
|
||||||
|
return gulp.src(['src/**/*.{ts,tsx}'])
|
||||||
|
// eslint() attaches the lint output to the "eslint" property
|
||||||
|
// of the file object so it can be used by other modules.
|
||||||
|
.pipe(eslint())
|
||||||
|
// eslint.format() outputs the lint results to the console.
|
||||||
|
// Alternatively use eslint.formatEach() (see Docs).
|
||||||
|
.pipe(eslint.format())
|
||||||
|
// To have the process exit with an error code (1) on
|
||||||
|
// lint error, return the stream and pipe to failAfterError last.
|
||||||
|
.pipe(eslint.failAfterError());
|
||||||
|
});
|
||||||
|
|
||||||
|
build.rig.addPreBuildTask(build.task('eslint-task', eslintSubTask));
|
||||||
|
// force use of projects specified react version
|
||||||
|
build.configureWebpack.mergeConfig({
|
||||||
|
|
||||||
|
additionalConfiguration: (generatedConfiguration) => {
|
||||||
|
// force use of projects specified react version
|
||||||
|
generatedConfiguration.externals = generatedConfiguration.externals
|
||||||
|
.filter(name => !(["react", "react-dom"].includes(name)));
|
||||||
|
// force use TerserPlugIn (remove UglifyJs)
|
||||||
|
generatedConfiguration.plugins.forEach((plugin, i) => {
|
||||||
|
if (plugin.options && plugin.options.mangle) {
|
||||||
|
generatedConfiguration.plugins.splice(i, 1);
|
||||||
|
generatedConfiguration = merge(generatedConfiguration, {
|
||||||
|
plugins: [
|
||||||
|
new TerserPlugin()
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
return generatedConfiguration;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
build.initialize(gulp);
|
|
@ -0,0 +1,56 @@
|
||||||
|
{
|
||||||
|
"name": "react-news-banner",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "gulp bundle",
|
||||||
|
"clean": "gulp clean",
|
||||||
|
"test": "gulp test"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fluentui/theme": "^2.1.0",
|
||||||
|
"@microsoft/office-ui-fabric-react-bundle": "^1.11.0",
|
||||||
|
"@microsoft/sp-core-library": "~1.4.1",
|
||||||
|
"@microsoft/sp-lodash-subset": "~1.4.1",
|
||||||
|
"@microsoft/sp-office-ui-fabric-core": "^1.11.0",
|
||||||
|
"@microsoft/sp-tslint-rules": "^1.11.0",
|
||||||
|
"@microsoft/sp-webpart-base": "~1.4.1",
|
||||||
|
"@pnp/common": "^1.3.11",
|
||||||
|
"@pnp/logging": "^1.3.11",
|
||||||
|
"@pnp/odata": "^1.3.11",
|
||||||
|
"@pnp/sp": "^1.3.11",
|
||||||
|
"@pnp/spfx-controls-react": "^1.21.1",
|
||||||
|
"@pnp/spfx-property-controls": "^1.3.0",
|
||||||
|
"@uifabric/merge-styles": "^7.19.2",
|
||||||
|
"date-fns": "^2.21.2",
|
||||||
|
"enhanced-resolve": "^5.8.0",
|
||||||
|
"idb-keyval": "^5.0.5",
|
||||||
|
"office-ui-fabric-react": "^6.214.1",
|
||||||
|
"react": "^17.0.2",
|
||||||
|
"react-dom": "^17.0.2",
|
||||||
|
"spfx-uifabric-themes": "^0.8.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@microsoft/sp-build-web": "1.4.1",
|
||||||
|
"@microsoft/sp-module-interfaces": "1.4.1",
|
||||||
|
"@microsoft/sp-webpart-workbench": "1.4.1",
|
||||||
|
"@types/chai": "3.4.34",
|
||||||
|
"@types/es6-promise": "0.0.33",
|
||||||
|
"@types/mocha": "2.2.38",
|
||||||
|
"@types/react": "^16.9.19",
|
||||||
|
"@types/react-dom": "^16.9.0",
|
||||||
|
"@types/webpack-env": "1.13.1",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
||||||
|
"@typescript-eslint/parser": "^4.22.0",
|
||||||
|
"ajv": "~5.2.2",
|
||||||
|
"eslint": "^7.25.0",
|
||||||
|
"eslint-plugin-react": "^7.23.2",
|
||||||
|
"eslint-plugin-react-hooks": "^4.2.0",
|
||||||
|
"gulp": "~3.9.1",
|
||||||
|
"gulp-eslint": "^6.0.0",
|
||||||
|
"terser-webpack-plugin-legacy": "^1.2.3",
|
||||||
|
"typescript": "3.9.7",
|
||||||
|
"webpack-merge": "^4.2.1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
@import "~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
max-height: 550px;
|
||||||
|
min-height: 550px;
|
||||||
|
max-width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
// box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.imageContainer {
|
||||||
|
width: 70%;
|
||||||
|
}
|
||||||
|
.overlay {
|
||||||
|
position: relative;
|
||||||
|
background-color: white;
|
||||||
|
opacity: 0.8;
|
||||||
|
top: -500px;
|
||||||
|
max-width: 320px;
|
||||||
|
color: $ms-color-themeDark;
|
||||||
|
|
||||||
|
max-height: 120px;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 20px;
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image {
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.documentCard {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
max-width: 100%;
|
||||||
|
padding-left: 15px;
|
||||||
|
padding-right: 15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
.documentCard:hover {
|
||||||
|
background-color: $ms-color-themePrimary;
|
||||||
|
color: $ms-color-white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list {
|
||||||
|
width: 30%;
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-left: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
|
background-color: $ms-color-neutralLighterAlt;
|
||||||
|
border-width: 1.2px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: $ms-color-neutralQuaternaryAlt;
|
||||||
|
overflow-y:auto;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.list::-webkit-scrollbar-thumb {
|
||||||
|
background-Color: $ms-color-neutralQuaternaryAlt
|
||||||
|
}
|
||||||
|
.list::-webkit-scrollbar {
|
||||||
|
height: 10px;
|
||||||
|
width: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
@include ms-Grid-row;
|
||||||
|
@include ms-fontColor-white;
|
||||||
|
background-color: $ms-color-themeDark;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.column {
|
||||||
|
@include ms-Grid-col;
|
||||||
|
@include ms-lg10;
|
||||||
|
@include ms-xl8;
|
||||||
|
@include ms-xlPush2;
|
||||||
|
@include ms-lgPush1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
@include ms-font-xl;
|
||||||
|
font-weight: 700;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
width:100%;
|
||||||
|
text-transform: uppercase;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 4;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.title::hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subTitle {
|
||||||
|
@include ms-font-l;
|
||||||
|
padding-top: 10px;
|
||||||
|
// @include ms-fontColor-white;
|
||||||
|
color: $ms-color-themeDark;
|
||||||
|
font-weight: 700;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 4;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lineSeparator {
|
||||||
|
border-bottom: 1.3px;
|
||||||
|
border-bottom-style: solid;
|
||||||
|
border-bottom-color: $ms-color-neutralQuaternaryAlt;
|
||||||
|
margin-left: 15px;
|
||||||
|
margin-right: 15px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subTitleNews {
|
||||||
|
@include ms-font-m;
|
||||||
|
// color: $ms-color-themeDark;
|
||||||
|
font-weight: 700;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
font-weight: $ms-font-weight-semibold;
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
vertical-align: top;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 4;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttonConfigure {
|
||||||
|
// Our button
|
||||||
|
text-decoration: none;
|
||||||
|
height: 32px;
|
||||||
|
|
||||||
|
// Primary Button
|
||||||
|
min-width: 80px;
|
||||||
|
background-color: $ms-color-themePrimary;
|
||||||
|
border-color: $ms-color-themePrimary;
|
||||||
|
color: $ms-color-white;
|
||||||
|
|
||||||
|
// Basic Button
|
||||||
|
outline: transparent;
|
||||||
|
position: relative;
|
||||||
|
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
font-weight: $ms-font-weight-regular;
|
||||||
|
border-width: 0;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.labelConfigure {
|
||||||
|
color: $ms-color-themeDark;
|
||||||
|
font-weight: $ms-font-weight-semibold;
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
margin: 0 4px;
|
||||||
|
vertical-align: top;
|
||||||
|
display: inline-block;
|
||||||
|
color: $ms-color-white;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,193 @@
|
||||||
|
import { IBannerProps } from "./IBannerProps";
|
||||||
|
import styles from "./Banner.module.scss";
|
||||||
|
import * as React from "react";
|
||||||
|
import { BannerCard } from "../BannerCard";
|
||||||
|
import { IBannerState } from "./IBannerState";
|
||||||
|
import { IListItem } from "../../entities/IListItem";
|
||||||
|
import { useList } from "../../hooks/useList";
|
||||||
|
import { reducer } from "./BannerReducer";
|
||||||
|
import { EBannerTypes } from "./EBannerTypes";
|
||||||
|
import { Placeholder } from '@pnp/spfx-controls-react';
|
||||||
|
|
||||||
|
import {
|
||||||
|
MessageBar,
|
||||||
|
MessageBarType,
|
||||||
|
} from "office-ui-fabric-react/lib/MessageBar";
|
||||||
|
import {
|
||||||
|
Spinner,
|
||||||
|
SpinnerSize,
|
||||||
|
} from "office-ui-fabric-react/lib/Spinner";
|
||||||
|
import {
|
||||||
|
Stack,
|
||||||
|
} from "office-ui-fabric-react/lib/Stack";
|
||||||
|
import strings from "BannerWebPartStrings";
|
||||||
|
|
||||||
|
const initialState: IBannerState = {
|
||||||
|
isLoading: false,
|
||||||
|
items: [],
|
||||||
|
messageError: undefined,
|
||||||
|
selectedItem: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const Banner: React.FunctionComponent<IBannerProps> = (
|
||||||
|
props: React.PropsWithChildren<IBannerProps>
|
||||||
|
) => {
|
||||||
|
const { selectedProperties, webpartContext } = props;
|
||||||
|
const [state, dispatch] = React.useReducer(reducer, initialState);
|
||||||
|
const { getItems } = useList();
|
||||||
|
const { isLoading, items, messageError, selectedItem } = state;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const _onSelectedItem = React.useCallback((item: IListItem) => {
|
||||||
|
dispatch({
|
||||||
|
type: EBannerTypes.SET_SELECTED_ITEM,
|
||||||
|
payload: item,
|
||||||
|
});
|
||||||
|
},[]);
|
||||||
|
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
if (!selectedProperties.listId) return;
|
||||||
|
try {
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: EBannerTypes.SET_ISLOADING,
|
||||||
|
payload: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const _items = await getItems(selectedProperties);
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: EBannerTypes.SET_ITEMS,
|
||||||
|
payload: _items,
|
||||||
|
});
|
||||||
|
dispatch({
|
||||||
|
type: EBannerTypes.SET_SELECTED_ITEM,
|
||||||
|
payload: _items[0],
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: EBannerTypes.SET_MESSAGE,
|
||||||
|
payload: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: EBannerTypes.SET_ISLOADING,
|
||||||
|
payload: false,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
dispatch({
|
||||||
|
type: EBannerTypes.SET_MESSAGE,
|
||||||
|
payload: {
|
||||||
|
message: "Something went worg",
|
||||||
|
messageBarType: MessageBarType.error,
|
||||||
|
isToShow: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
dispatch({
|
||||||
|
type: EBannerTypes.SET_ISLOADING,
|
||||||
|
payload: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [selectedProperties]);
|
||||||
|
|
||||||
|
if (messageError?.isToShow) {
|
||||||
|
return (
|
||||||
|
<MessageBar messageBarType={messageError.messageBarType} isMultiline>
|
||||||
|
{messageError?.message ?? strings.MessageErrorDefault}
|
||||||
|
</MessageBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<Stack horizontal horizontalAlign="center" verticalAlign="center">
|
||||||
|
<Spinner size={SpinnerSize.large}></Spinner>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
dateFieldName,
|
||||||
|
descriptionFieldName,
|
||||||
|
imageUrlFieldName,
|
||||||
|
listId,
|
||||||
|
sites,
|
||||||
|
titleLink,
|
||||||
|
} = selectedProperties;
|
||||||
|
|
||||||
|
if (
|
||||||
|
!titleLink ||
|
||||||
|
!sites ||
|
||||||
|
!sites.length ||
|
||||||
|
!listId ||
|
||||||
|
!dateFieldName ||
|
||||||
|
!descriptionFieldName ||
|
||||||
|
!imageUrlFieldName
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<Placeholder iconName='Edit'
|
||||||
|
iconText={strings.PlaceholderIconText}
|
||||||
|
description={strings.PlaceHolderDescription}
|
||||||
|
buttonLabel={strings.PlaceHolderButtonDescription}
|
||||||
|
onConfigure={()=> {webpartContext.propertyPane.open()}} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
|
||||||
|
<div className={styles.container}>
|
||||||
|
<div className={styles.imageContainer}>
|
||||||
|
|
||||||
|
<img
|
||||||
|
className={styles.image}
|
||||||
|
src={selectedItem ? selectedItem.imageUrl : ""}
|
||||||
|
width={"100%"}
|
||||||
|
height={"100%"}
|
||||||
|
></img>
|
||||||
|
<div className={styles.overlay}>
|
||||||
|
<a
|
||||||
|
rel="noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
data-interception="off"
|
||||||
|
className={styles.title}
|
||||||
|
href={titleLink ? selectedItem?.linkUrl : ""}
|
||||||
|
>
|
||||||
|
{selectedItem ? selectedItem?.title : ""}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.list}>
|
||||||
|
{items.map((item, i) => {
|
||||||
|
const _isSeleted: boolean = item.id === selectedItem.id;
|
||||||
|
return (
|
||||||
|
<div key={i}>
|
||||||
|
{i > 0 && i < items.length ? (
|
||||||
|
<div className={styles.lineSeparator}></div>
|
||||||
|
) : null}
|
||||||
|
<BannerCard
|
||||||
|
item={item}
|
||||||
|
isSelected={_isSeleted}
|
||||||
|
onSeletedItem={_onSelectedItem}
|
||||||
|
selectedProperties={selectedProperties}
|
||||||
|
currentCultureName={
|
||||||
|
webpartContext.pageContext.cultureInfo.currentCultureName
|
||||||
|
}
|
||||||
|
></BannerCard>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { IListItem, INotification } from "./../../entities";
|
||||||
|
import { EBannerTypes } from "./EBannerTypes";
|
||||||
|
import { IBannerState } from "./IBannerState";
|
||||||
|
// Reducer
|
||||||
|
export const reducer = (
|
||||||
|
state: IBannerState,
|
||||||
|
action: { type: EBannerTypes; payload: unknown }
|
||||||
|
): IBannerState => {
|
||||||
|
switch (action.type) {
|
||||||
|
case EBannerTypes.SET_ITEMS:
|
||||||
|
return { ...state, items: action.payload as IListItem[] };
|
||||||
|
case EBannerTypes.SET_SELECTED_ITEM:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
selectedItem: action.payload as IListItem,
|
||||||
|
};
|
||||||
|
case EBannerTypes.SET_ISLOADING:
|
||||||
|
return { ...state, isLoading: action.payload as boolean };
|
||||||
|
case EBannerTypes.SET_MESSAGE:
|
||||||
|
return { ...state, messageError: action.payload as INotification };
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,10 @@
|
||||||
|
export enum EBannerTypes {
|
||||||
|
"SET_SELECTED_ITEM" = "SET_SELECTED_ITEM",
|
||||||
|
"SET_SELECTED_INDEX" = "SET_SELECTED_INDEX",
|
||||||
|
"SET_ITEMS" = "SET_ITEMS",
|
||||||
|
"SET_ISLOADING" ="SET_ISLOADING",
|
||||||
|
"SET_MESSAGE" ="SET_MESSAGE",
|
||||||
|
"SET_IS_RUNNING_ACTION" = "SET_IS_RUNNING_ACTION",
|
||||||
|
"SET_SHOW_DIALOG" = "SET_SHOW_DIALOG",
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
/* tslint:disable */
|
||||||
|
import { WebPartContext } from "@microsoft/sp-webpart-base";
|
||||||
|
import { ISelectedProperties } from "../../entities/ISeletedProperties";
|
||||||
|
|
||||||
|
export interface IBannerProps {
|
||||||
|
selectedProperties:ISelectedProperties;
|
||||||
|
webpartContext: WebPartContext;
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
/* tslint:disable */
|
||||||
|
import { INotification } from "../../entities";
|
||||||
|
import { IListItem } from "../../entities/IListItem";
|
||||||
|
|
||||||
|
export interface IBannerState {
|
||||||
|
selectedItem: IListItem;
|
||||||
|
items:IListItem[];
|
||||||
|
isLoading: boolean;
|
||||||
|
messageError: INotification
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
/* tslint:disable */
|
||||||
|
export * from './Banner';
|
|
@ -0,0 +1,52 @@
|
||||||
|
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||||
|
|
||||||
|
.subTitleNews {
|
||||||
|
@include ms-font-m;
|
||||||
|
// color: $ms-color-themeDark;
|
||||||
|
font-weight: 700;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
font-weight: $ms-font-weight-semibold;
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
vertical-align: top;
|
||||||
|
display: inline-block;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
max-width: 100%;
|
||||||
|
min-width: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 4;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.documentCard {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
max-width: 100%;
|
||||||
|
padding-left: 15px;
|
||||||
|
padding-right: 15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.documentCardSeleted {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
max-width: 100%;
|
||||||
|
padding-left: 15px;
|
||||||
|
padding-right: 15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
background-color: $ms-color-themePrimary;
|
||||||
|
color: $ms-color-white
|
||||||
|
|
||||||
|
}
|
||||||
|
.documentCard:hover {
|
||||||
|
background-color: $ms-color-themePrimary;
|
||||||
|
color: $ms-color-white;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/* tslint:disable */
|
||||||
|
import { format, parseISO } from "date-fns";
|
||||||
|
import React from "react";
|
||||||
|
import styles from "./BannerCard.module.scss";
|
||||||
|
import { IBannerCardProps } from "./IBannerCardProps";
|
||||||
|
|
||||||
|
export const BannerCard: React.FunctionComponent<IBannerCardProps> = (
|
||||||
|
props: React.PropsWithChildren<IBannerCardProps>
|
||||||
|
) => {
|
||||||
|
const { item, isSelected } = props;
|
||||||
|
const _date = format(parseISO(item.publishedDate), "PPPP");
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className={
|
||||||
|
isSelected ? styles.documentCardSeleted : styles.documentCard
|
||||||
|
}
|
||||||
|
onClick={() => {
|
||||||
|
props.onSeletedItem(item);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className={styles.subTitleNews}>{_date}</div>
|
||||||
|
<div className={styles.description}>{item.description}</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,11 @@
|
||||||
|
/* tslint:disable */
|
||||||
|
import { IListItem } from "../../entities/IListItem";
|
||||||
|
import { ISelectedProperties } from "../../entities/ISeletedProperties";
|
||||||
|
|
||||||
|
export interface IBannerCardProps {
|
||||||
|
item: IListItem;
|
||||||
|
isSelected: boolean;
|
||||||
|
onSeletedItem?: (item: IListItem) => void;
|
||||||
|
currentCultureName:string;
|
||||||
|
selectedProperties:ISelectedProperties;
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './BannerCard';
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './Banner';
|
|
@ -0,0 +1,9 @@
|
||||||
|
/* tslint:disable */
|
||||||
|
export interface IListItem {
|
||||||
|
id: string;
|
||||||
|
title:string;
|
||||||
|
publishedDate:string;
|
||||||
|
description:string;
|
||||||
|
imageUrl:string;
|
||||||
|
linkUrl:string;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { MessageBarType } from "office-ui-fabric-react";
|
||||||
|
|
||||||
|
export interface INotification {
|
||||||
|
message: string;
|
||||||
|
messageBarType: MessageBarType;
|
||||||
|
isToShow: boolean;
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
export interface ISPColumn {
|
||||||
|
'odata.type': string;
|
||||||
|
'odata.id': string;
|
||||||
|
'odata.editLink': string;
|
||||||
|
AutoIndexed: boolean;
|
||||||
|
CanBeDeleted: boolean;
|
||||||
|
ClientSideComponentId: string;
|
||||||
|
ClientSideComponentProperties?: string;
|
||||||
|
ClientValidationFormula?: string;
|
||||||
|
ClientValidationMessage?: string;
|
||||||
|
CustomFormatter?: string;
|
||||||
|
DefaultFormula?: string;
|
||||||
|
DefaultValue?: string;
|
||||||
|
Description: string;
|
||||||
|
Direction: string;
|
||||||
|
EnforceUniqueValues: boolean;
|
||||||
|
EntityPropertyName: string;
|
||||||
|
Filterable: boolean;
|
||||||
|
FromBaseType: boolean;
|
||||||
|
Group: string;
|
||||||
|
Hidden: boolean;
|
||||||
|
Id: string;
|
||||||
|
Indexed: boolean;
|
||||||
|
IndexStatus: number;
|
||||||
|
InternalName: string;
|
||||||
|
IsModern: boolean;
|
||||||
|
JSLink: string;
|
||||||
|
PinnedToFiltersPane: boolean;
|
||||||
|
ReadOnlyField: boolean;
|
||||||
|
Required: boolean;
|
||||||
|
SchemaXml: string;
|
||||||
|
Scope: string;
|
||||||
|
Sealed: boolean;
|
||||||
|
ShowInFiltersPane: number;
|
||||||
|
Sortable: boolean;
|
||||||
|
StaticName: string;
|
||||||
|
Title: string;
|
||||||
|
FieldTypeKind: number;
|
||||||
|
TypeAsString: string;
|
||||||
|
TypeDisplayName: string;
|
||||||
|
TypeShortDescription: string;
|
||||||
|
ValidationFormula?: string;
|
||||||
|
ValidationMessage?: string;
|
||||||
|
MaxLength: number;
|
||||||
|
RichText: boolean;
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
export interface ISPList {
|
||||||
|
'odata.metadata': string;
|
||||||
|
'odata.type': string;
|
||||||
|
'odata.id': string;
|
||||||
|
'odata.etag': string;
|
||||||
|
'odata.editLink': string;
|
||||||
|
AllowContentTypes: boolean;
|
||||||
|
BaseTemplate: number;
|
||||||
|
BaseType: number;
|
||||||
|
ContentTypesEnabled: boolean;
|
||||||
|
CrawlNonDefaultViews: boolean;
|
||||||
|
Created: string;
|
||||||
|
CurrentChangeToken: CurrentChangeToken;
|
||||||
|
DefaultContentApprovalWorkflowId: string;
|
||||||
|
DefaultItemOpenUseListSetting: boolean;
|
||||||
|
Description: string;
|
||||||
|
Direction: string;
|
||||||
|
DisableCommenting: boolean;
|
||||||
|
DisableGridEditing: boolean;
|
||||||
|
DocumentTemplateUrl?: string;
|
||||||
|
DraftVersionVisibility: number;
|
||||||
|
EnableAttachments: boolean;
|
||||||
|
EnableFolderCreation: boolean;
|
||||||
|
EnableMinorVersions: boolean;
|
||||||
|
EnableModeration: boolean;
|
||||||
|
EnableRequestSignOff: boolean;
|
||||||
|
EnableVersioning: boolean;
|
||||||
|
EntityTypeName: string;
|
||||||
|
ExemptFromBlockDownloadOfNonViewableFiles: boolean;
|
||||||
|
FileSavePostProcessingEnabled: boolean;
|
||||||
|
ForceCheckout: boolean;
|
||||||
|
HasExternalDataSource: boolean;
|
||||||
|
Hidden: boolean;
|
||||||
|
Id: string;
|
||||||
|
ImagePath: ImagePath;
|
||||||
|
ImageUrl: string;
|
||||||
|
IrmEnabled: boolean;
|
||||||
|
IrmExpire: boolean;
|
||||||
|
IrmReject: boolean;
|
||||||
|
IsApplicationList: boolean;
|
||||||
|
IsCatalog: boolean;
|
||||||
|
IsPrivate: boolean;
|
||||||
|
ItemCount: number;
|
||||||
|
LastItemDeletedDate: string;
|
||||||
|
LastItemModifiedDate: string;
|
||||||
|
LastItemUserModifiedDate: string;
|
||||||
|
ListExperienceOptions: number;
|
||||||
|
ListItemEntityTypeFullName: string;
|
||||||
|
MajorVersionLimit: number;
|
||||||
|
MajorWithMinorVersionsLimit: number;
|
||||||
|
MultipleDataList: boolean;
|
||||||
|
NoCrawl: boolean;
|
||||||
|
ParentWebPath: ImagePath;
|
||||||
|
ParentWebUrl: string;
|
||||||
|
ParserDisabled: boolean;
|
||||||
|
ServerTemplateCanCreateFolders: boolean;
|
||||||
|
TemplateFeatureId: string;
|
||||||
|
Title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImagePath {
|
||||||
|
DecodedUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CurrentChangeToken {
|
||||||
|
StringValue: string;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { IPropertyFieldSite } from '@pnp/spfx-property-controls/lib/PropertyFieldSitePicker';
|
||||||
|
|
||||||
|
export interface ISelectedProperties {
|
||||||
|
title: string;
|
||||||
|
listId: string;
|
||||||
|
sites: IPropertyFieldSite[];
|
||||||
|
titleFieldName: string;
|
||||||
|
dateFieldName: string;
|
||||||
|
descriptionFieldName: string;
|
||||||
|
imageUrlFieldName: string;
|
||||||
|
listBasetemplate: number;
|
||||||
|
numberItems: number;
|
||||||
|
titleLink: string;
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export * from './IListItem';
|
||||||
|
export * from './INotification';
|
||||||
|
export * from './ISeletedProperties';
|
||||||
|
export * from './ISPList';
|
||||||
|
export * from './ISPColumn';
|
|
@ -0,0 +1,95 @@
|
||||||
|
/* tslint:disable */
|
||||||
|
import { Web } from "@pnp/sp";
|
||||||
|
import { IListItem, ISPList } from "./../entities";
|
||||||
|
import { sortBy, uniqBy } from "lodash";
|
||||||
|
import { ISelectedProperties } from "../entities";
|
||||||
|
import { ISPColumn } from "../entities";
|
||||||
|
|
||||||
|
type retrunFunctions = {
|
||||||
|
getListColumns: (webUrl: string, listId: string) => Promise<ISPColumn[]>;
|
||||||
|
getLists: (webUrl: string, baseTemplate: number) => Promise<ISPList[]>;
|
||||||
|
getItems: (seletedProperties: ISelectedProperties) => Promise<IListItem[]>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useList = (): retrunFunctions => {
|
||||||
|
// Get List Columns
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const getListColumns = async (
|
||||||
|
webUrl: string,
|
||||||
|
listId: string
|
||||||
|
): Promise<ISPColumn[]> => {
|
||||||
|
const web = new Web(webUrl);
|
||||||
|
const _listColumnsResults: ISPColumn[] = await web.lists
|
||||||
|
.getById(listId)
|
||||||
|
.fields.filter("Hidden eq false")
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const _wColumns: ISPColumn[] = uniqBy(
|
||||||
|
sortBy(_listColumnsResults, "Title"),
|
||||||
|
"Title"
|
||||||
|
);
|
||||||
|
console.log(_wColumns);
|
||||||
|
return _wColumns;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getItems = async (
|
||||||
|
seletedProperties: ISelectedProperties
|
||||||
|
): Promise<IListItem[]> => {
|
||||||
|
const {
|
||||||
|
dateFieldName,
|
||||||
|
titleFieldName,
|
||||||
|
descriptionFieldName,
|
||||||
|
imageUrlFieldName,
|
||||||
|
listId,
|
||||||
|
numberItems,
|
||||||
|
titleLink,
|
||||||
|
sites,
|
||||||
|
} = seletedProperties;
|
||||||
|
const listItems: IListItem[] = [];
|
||||||
|
if (!listId && !sites) return [];
|
||||||
|
const web = new Web(sites[0].url);
|
||||||
|
const sortField: string = dateFieldName ?? "Title";
|
||||||
|
|
||||||
|
const _listResults = await web.lists
|
||||||
|
.getById(listId)
|
||||||
|
.items.orderBy(sortField, false)
|
||||||
|
.top(numberItems ?? 3)
|
||||||
|
.get();
|
||||||
|
if (_listResults && _listResults.length) {
|
||||||
|
for (const item of _listResults) {
|
||||||
|
listItems.push({
|
||||||
|
id: item.ID,
|
||||||
|
title: item[titleFieldName],
|
||||||
|
description: item[descriptionFieldName],
|
||||||
|
imageUrl: item[imageUrlFieldName]?.Url,
|
||||||
|
linkUrl: item[titleLink]?.Url,
|
||||||
|
publishedDate: item[dateFieldName],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listItems;
|
||||||
|
};
|
||||||
|
// Get Lists
|
||||||
|
const getLists = async (
|
||||||
|
webUrl: string,
|
||||||
|
baseTemplate: number
|
||||||
|
): Promise<ISPList[]> => {
|
||||||
|
let _filter = "Hidden eq false and ";
|
||||||
|
if (baseTemplate === 0) {
|
||||||
|
_filter = _filter + " BaseType ne 1";
|
||||||
|
} else {
|
||||||
|
_filter = _filter + " BaseType eq 1";
|
||||||
|
}
|
||||||
|
const web = new Web(webUrl);
|
||||||
|
const _lists: ISPList[] = await web.lists.filter(_filter).get();
|
||||||
|
|
||||||
|
console.log("lists", _lists);
|
||||||
|
return _lists;
|
||||||
|
};
|
||||||
|
// Return functions
|
||||||
|
return {
|
||||||
|
getListColumns,
|
||||||
|
getLists,
|
||||||
|
getItems,
|
||||||
|
};
|
||||||
|
};
|
|
@ -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": "6df4111a-bb08-43b8-b4bb-718ecde1148e",
|
||||||
|
"alias": "NewsBannerWebPart",
|
||||||
|
"componentType": "WebPart",
|
||||||
|
"supportsFullBleed": true,
|
||||||
|
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
|
||||||
|
"preconfiguredEntries": [{
|
||||||
|
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||||
|
"group": { "default": "SPFx Custom WebParts" },
|
||||||
|
"title": { "default": "Banner" },
|
||||||
|
"description": { "default": "Show news and images" },
|
||||||
|
"officeFabricIconFontName": "News",
|
||||||
|
"properties": {
|
||||||
|
"title": "News Banner"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
|
@ -0,0 +1,315 @@
|
||||||
|
|
||||||
|
import * as React from "react";
|
||||||
|
import * as ReactDom from "react-dom";
|
||||||
|
import { Version } from "@microsoft/sp-core-library";
|
||||||
|
import {
|
||||||
|
BaseClientSideWebPart,
|
||||||
|
IPropertyPaneConfiguration,
|
||||||
|
IPropertyPaneDropdownOption,
|
||||||
|
IPropertyPaneField,
|
||||||
|
IPropertyPaneGroup,
|
||||||
|
IPropertyPanePage,
|
||||||
|
PropertyPaneDropdown,
|
||||||
|
PropertyPaneSlider,
|
||||||
|
PropertyPaneTextField,
|
||||||
|
} from "@microsoft/sp-webpart-base";
|
||||||
|
|
||||||
|
import * as strings from "BannerWebPartStrings";
|
||||||
|
import { Banner } from "../../components/Banner";
|
||||||
|
import { IBannerProps } from "../../components/Banner/IBannerProps";
|
||||||
|
|
||||||
|
import { useList } from "../../hooks/useList";
|
||||||
|
import {
|
||||||
|
PropertyFieldSitePicker,
|
||||||
|
IPropertyFieldSite,
|
||||||
|
} from "@pnp/spfx-property-controls";
|
||||||
|
import { ISPList } from "../../entities/ISPList";
|
||||||
|
import { sp } from "@pnp/sp";
|
||||||
|
import { ISPColumn } from "../../entities";
|
||||||
|
export interface IBannerWebPartProps {
|
||||||
|
title: string;
|
||||||
|
listId: string;
|
||||||
|
titleFieldName: string;
|
||||||
|
dateFieldName: string;
|
||||||
|
descriptionFieldName: string;
|
||||||
|
imageUrlFieldName: string;
|
||||||
|
listBasetemplate: number;
|
||||||
|
numberItems: number;
|
||||||
|
sites: IPropertyFieldSite[];
|
||||||
|
titleLink: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
|
const { getListColumns, getLists } = useList();
|
||||||
|
|
||||||
|
export default class BannerWebPart extends BaseClientSideWebPart<
|
||||||
|
IBannerWebPartProps
|
||||||
|
> {
|
||||||
|
private textColumns: IPropertyPaneDropdownOption[] = [];
|
||||||
|
private dateColumns: IPropertyPaneDropdownOption[] = [];
|
||||||
|
private URLColumns: IPropertyPaneDropdownOption[] = [];
|
||||||
|
private columns: IPropertyPaneDropdownOption[] = [];
|
||||||
|
private lists: IPropertyPaneDropdownOption[] = [];
|
||||||
|
|
||||||
|
private listColumns: ISPColumn[] = [];
|
||||||
|
|
||||||
|
private _messageError: string = undefined;
|
||||||
|
|
||||||
|
protected async onInit(): Promise<void> {
|
||||||
|
sp.setup({
|
||||||
|
spfxContext: this.context,
|
||||||
|
});
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
public render(): void {
|
||||||
|
const element: React.ReactElement<IBannerProps> = React.createElement(
|
||||||
|
Banner,
|
||||||
|
{
|
||||||
|
selectedProperties: {
|
||||||
|
title: this.properties.titleFieldName,
|
||||||
|
listId: this.properties.listId,
|
||||||
|
titleFieldName: this.properties.titleFieldName,
|
||||||
|
dateFieldName: this.properties.dateFieldName,
|
||||||
|
descriptionFieldName: this.properties.descriptionFieldName,
|
||||||
|
imageUrlFieldName: this.properties.imageUrlFieldName,
|
||||||
|
listBasetemplate: this.properties.listBasetemplate,
|
||||||
|
numberItems: this.properties.numberItems,
|
||||||
|
sites: this.properties.sites,
|
||||||
|
titleLink: this.properties.titleLink,
|
||||||
|
},
|
||||||
|
webpartContext: this.context,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ReactDom.render(element, this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onDispose(): void {
|
||||||
|
ReactDom.unmountComponentAtNode(this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get dataVersion(): Version {
|
||||||
|
return Version.parse("1.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get disableReactivePropertyChanges():boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private addLists = async (webUrl: string): Promise<void> => {
|
||||||
|
try {
|
||||||
|
this.lists = [];
|
||||||
|
const lists: ISPList[] = await getLists(webUrl, 0);
|
||||||
|
for (const list of lists) {
|
||||||
|
this.lists.push({
|
||||||
|
key: list.Id,
|
||||||
|
text: list.Title,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
this._messageError = error.message;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
protected async onPropertyPaneConfigurationStart():Promise<void> {
|
||||||
|
if (
|
||||||
|
this.properties.titleFieldName ||
|
||||||
|
this.properties.descriptionFieldName ||
|
||||||
|
this.properties.dateFieldName ||
|
||||||
|
this.properties.imageUrlFieldName ||
|
||||||
|
this.properties.listId ||
|
||||||
|
(this.properties.sites && this.properties.sites.length)
|
||||||
|
) {
|
||||||
|
if (!this.lists.length) {
|
||||||
|
await this.addLists(this.properties.sites[0].url);
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
}
|
||||||
|
if (!this.listColumns.length && this.properties.listId) {
|
||||||
|
await this.addListColumns(this.properties.listId);
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async onPropertyPaneFieldChanged(
|
||||||
|
propertyPath: string,
|
||||||
|
oldValue: unknown,
|
||||||
|
newValue: unknown
|
||||||
|
):Promise<void> {
|
||||||
|
if (propertyPath === "listId") {
|
||||||
|
this.listColumns = [];
|
||||||
|
console.log("listd", this.properties.listId);
|
||||||
|
if (newValue as string === "") {
|
||||||
|
this.properties.titleFieldName = "";
|
||||||
|
this.properties.descriptionFieldName = "";
|
||||||
|
this.properties.dateFieldName = "";
|
||||||
|
this.properties.imageUrlFieldName = "";
|
||||||
|
this.properties.titleLink = "";
|
||||||
|
this.properties.numberItems = 6;
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
await this.addListColumns(newValue as string);
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (propertyPath === "sites") {
|
||||||
|
|
||||||
|
const value:IPropertyFieldSite[] = newValue as IPropertyFieldSite[];
|
||||||
|
if (value && !value.length) {
|
||||||
|
this.properties.titleFieldName = "";
|
||||||
|
this.properties.descriptionFieldName = "";
|
||||||
|
this.properties.dateFieldName = "";
|
||||||
|
this.properties.imageUrlFieldName = "";
|
||||||
|
this.properties.listId = "";
|
||||||
|
this.properties.titleLink = "";
|
||||||
|
this.properties.numberItems = 6;
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
await this.addLists(value[0].url);
|
||||||
|
this.context.propertyPane.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async addListColumns(newValue: string) {
|
||||||
|
try {
|
||||||
|
this.listColumns = [];
|
||||||
|
|
||||||
|
this.listColumns = await getListColumns(
|
||||||
|
this.properties.sites[0].url,
|
||||||
|
newValue
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const _column of this.listColumns) {
|
||||||
|
if (
|
||||||
|
(_column.TypeAsString === "Text" ||
|
||||||
|
_column.TypeAsString === "Note") &&
|
||||||
|
(_column.RichText === false || _column.RichText === undefined)
|
||||||
|
) {
|
||||||
|
this.textColumns.push({
|
||||||
|
key: _column.InternalName,
|
||||||
|
text: _column.Title,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_column.TypeAsString === "DateTime") {
|
||||||
|
this.dateColumns.push({
|
||||||
|
key: _column.InternalName,
|
||||||
|
text: _column.Title,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_column.TypeAsString === "URL") {
|
||||||
|
this.URLColumns.push({
|
||||||
|
key: _column.InternalName,
|
||||||
|
text: _column.Title,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
this._messageError = error.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||||
|
const _pages: IPropertyPanePage[] = [
|
||||||
|
{
|
||||||
|
header: {
|
||||||
|
description: strings.PropertyPaneDescription,
|
||||||
|
},
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
groupName: strings.BasicGroupName,
|
||||||
|
groupFields: [
|
||||||
|
PropertyPaneTextField("title", {
|
||||||
|
label: strings.DescriptionFieldLabel,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const groups: IPropertyPaneGroup = _pages[0].groups[0] as IPropertyPaneGroup;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const groupFields: IPropertyPaneField<any>[] = groups.groupFields;
|
||||||
|
|
||||||
|
groupFields.push(
|
||||||
|
PropertyFieldSitePicker("sites", {
|
||||||
|
label: "Select site",
|
||||||
|
initialSites: this.properties.sites,
|
||||||
|
context: this.context,
|
||||||
|
deferredValidationTime: 500,
|
||||||
|
multiSelect: false,
|
||||||
|
onPropertyChange: this.onPropertyPaneFieldChanged,
|
||||||
|
properties: this.properties,
|
||||||
|
key: "sitesFieldId",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
if (this.properties.sites && this.properties.sites.length) {
|
||||||
|
groupFields.push(
|
||||||
|
PropertyPaneDropdown("listId", {
|
||||||
|
label: strings.ListIdLabel,
|
||||||
|
options: this.lists,
|
||||||
|
selectedKey: this.properties.listId,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
// Show Columns
|
||||||
|
if (this.listColumns.length) {
|
||||||
|
groupFields.push(
|
||||||
|
PropertyPaneDropdown("titleFieldName", {
|
||||||
|
label: strings.TitleFieldLabel,
|
||||||
|
options: this.textColumns,
|
||||||
|
|
||||||
|
selectedKey: this.properties.titleFieldName,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
groupFields.push(
|
||||||
|
PropertyPaneDropdown("dateFieldName", {
|
||||||
|
label: "Select field with published date",
|
||||||
|
options: this.dateColumns,
|
||||||
|
selectedKey: this.properties.dateFieldName,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
groupFields.push(
|
||||||
|
PropertyPaneDropdown("descriptionFieldName", {
|
||||||
|
label: "Select field with description",
|
||||||
|
options: this.textColumns,
|
||||||
|
selectedKey: this.properties.descriptionFieldName,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
groupFields.push(
|
||||||
|
PropertyPaneDropdown("imageUrlFieldName", {
|
||||||
|
label: "Select field width image url",
|
||||||
|
options: this.URLColumns,
|
||||||
|
selectedKey: this.properties.imageUrlFieldName,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
groupFields.push(
|
||||||
|
PropertyPaneDropdown("titleLink", {
|
||||||
|
label: "Select field for title link",
|
||||||
|
options: this.URLColumns,
|
||||||
|
selectedKey: this.properties.titleLink,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
groupFields.push(
|
||||||
|
PropertyPaneSlider("numberItems", {
|
||||||
|
label: "Number Items to Show",
|
||||||
|
min: 3,
|
||||||
|
max: 20,
|
||||||
|
value: this.properties.numberItems
|
||||||
|
? this.properties.numberItems
|
||||||
|
: 3,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const _panelConfiguration: IPropertyPaneConfiguration = { pages: _pages };
|
||||||
|
return _panelConfiguration;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
define([], function() {
|
||||||
|
return {
|
||||||
|
MessageErrorDefault: "Something went wrong when trying get data.",
|
||||||
|
PlaceHolderButtonDescription: "Configure",
|
||||||
|
PlaceHolderDescription: "Please configure Banner web part",
|
||||||
|
PlaceholderIconText: "Configure your web part",
|
||||||
|
"PropertyPaneDescription": "Please select List, and columns with information to show",
|
||||||
|
"BasicGroupName": "Properties",
|
||||||
|
"DescriptionFieldLabel": "Title",
|
||||||
|
"ListIdLabel": "Select list",
|
||||||
|
"TitleFieldLabel": "Select field with title",
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,16 @@
|
||||||
|
declare interface IBannerWebPartStrings {
|
||||||
|
PropertyPaneDescription: string;
|
||||||
|
BasicGroupName: string;
|
||||||
|
DescriptionFieldLabel: string;
|
||||||
|
ListIdLabel: string;
|
||||||
|
MessageErrorDefault: string;
|
||||||
|
PlaceHolderButtonDescription: string;
|
||||||
|
PlaceHolderDescription: string;
|
||||||
|
PlaceholderIconText: string;
|
||||||
|
TitleFieldLabel: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'BannerWebPartStrings' {
|
||||||
|
const strings: IBannerWebPartStrings;
|
||||||
|
export = strings;
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/**
|
||||||
|
* This script updates the package-solution version analogue to the
|
||||||
|
* the package.json file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (process.env.npm_package_version === undefined) {
|
||||||
|
|
||||||
|
throw 'Package version cannot be evaluated';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// define path to package-solution file
|
||||||
|
const solution = './config/package-solution.json',
|
||||||
|
teams = './teams/manifest.json';
|
||||||
|
|
||||||
|
// require filesystem instance
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// get next automated package version from process variable
|
||||||
|
const nextPkgVersion = process.env.npm_package_version;
|
||||||
|
|
||||||
|
// make sure next build version match
|
||||||
|
const nextVersion = nextPkgVersion.indexOf('-') === -1 ?
|
||||||
|
nextPkgVersion : nextPkgVersion.split('-')[0];
|
||||||
|
|
||||||
|
// Update version in SPFx package-solution if exists
|
||||||
|
if (fs.existsSync(solution)) {
|
||||||
|
|
||||||
|
// read package-solution file
|
||||||
|
const solutionFileContent = fs.readFileSync(solution, 'UTF-8');
|
||||||
|
// parse file as json
|
||||||
|
const solutionContents = JSON.parse(solutionFileContent);
|
||||||
|
|
||||||
|
// set property of version to next version
|
||||||
|
solutionContents.solution.version = nextVersion + '.0';
|
||||||
|
|
||||||
|
// save file
|
||||||
|
fs.writeFileSync(
|
||||||
|
solution,
|
||||||
|
// convert file back to proper json
|
||||||
|
JSON.stringify(solutionContents, null, 2),
|
||||||
|
'UTF-8');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update version in teams manifest if exists
|
||||||
|
if (fs.existsSync(teams)) {
|
||||||
|
|
||||||
|
// read package-solution file
|
||||||
|
const teamsManifestContent = fs.readFileSync(teams, 'UTF-8');
|
||||||
|
// parse file as json
|
||||||
|
const teamsContent = JSON.parse(teamsManifestContent);
|
||||||
|
|
||||||
|
// set property of version to next version
|
||||||
|
teamsContent.version = nextVersion;
|
||||||
|
|
||||||
|
// save file
|
||||||
|
fs.writeFileSync(
|
||||||
|
teams,
|
||||||
|
// convert file back to proper json
|
||||||
|
JSON.stringify(teamsContent, null, 2),
|
||||||
|
'UTF-8');
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"jsx": "react",
|
||||||
|
"declaration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"./node_modules/@microsoft"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"es6-promise",
|
||||||
|
"webpack-env"
|
||||||
|
],
|
||||||
|
"lib": [
|
||||||
|
"es5",
|
||||||
|
"dom",
|
||||||
|
"es2015.collection"
|
||||||
|
],
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"esModuleInterop": true
|
||||||
|
},
|
||||||
|
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json"
|
||||||
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
"id": "0338da15-07f9-4a53-b267-d790fb495cca",
|
"id": "0338da15-07f9-4a53-b267-d790fb495cca",
|
||||||
"alias": "OrganizationChartWebPart",
|
"alias": "OrganizationChartWebPart",
|
||||||
"componentType": "WebPart",
|
"componentType": "WebPart",
|
||||||
|
"supportsFullBleed": true,
|
||||||
|
|
||||||
// The "*" signifies that the version should be taken from the package.json
|
// The "*" signifies that the version should be taken from the package.json
|
||||||
"version": "*",
|
"version": "*",
|
||||||
|
|