Merge pull request #3535 from ValerasNarbutas/main
Thank you @ValerasNarbutas, I'll remove the `package-lock.json`
This commit is contained in:
commit
2ea33247c2
|
@ -0,0 +1,39 @@
|
|||
// For more information on how to run this SPFx project in a VS Code Remote Container, please visit https://aka.ms/spfx-devcontainer
|
||||
{
|
||||
"name": "SPFx 1.16.1",
|
||||
"image": "docker.io/m365pnp/spfx:1.16.1",
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
"settings": {},
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"editorconfig.editorconfig",
|
||||
"dbaeumer.vscode-eslint"
|
||||
],
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
"forwardPorts": [
|
||||
4321,
|
||||
35729
|
||||
],
|
||||
"portsAttributes": {
|
||||
"4321": {
|
||||
"protocol": "https",
|
||||
"label": "Manifest",
|
||||
"onAutoForward": "silent",
|
||||
"requireLocalPort": true
|
||||
},
|
||||
// Not needed for SPFx>= 1.12.1
|
||||
// "5432": {
|
||||
// "protocol": "https",
|
||||
// "label": "Workbench",
|
||||
// "onAutoForward": "silent"
|
||||
// },
|
||||
"35729": {
|
||||
"protocol": "https",
|
||||
"label": "LiveReload",
|
||||
"onAutoForward": "silent",
|
||||
"requireLocalPort": true
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "bash .devcontainer/spfx-startup.sh",
|
||||
"remoteUser": "node"
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
echo
|
||||
echo -e "\e[1;94mInstalling Node dependencies\e[0m"
|
||||
npm install
|
||||
|
||||
## commands to create dev certificate and copy it to the root folder of the project
|
||||
echo
|
||||
echo -e "\e[1;94mGenerating dev certificate\e[0m"
|
||||
gulp trust-dev-cert
|
||||
|
||||
# Convert the generated PEM certificate to a CER certificate
|
||||
openssl x509 -inform PEM -in ~/.rushstack/rushstack-serve.pem -outform DER -out ./spfx-dev-cert.cer
|
||||
|
||||
# Copy the PEM ecrtificate for non-Windows hosts
|
||||
cp ~/.rushstack/rushstack-serve.pem ./spfx-dev-cert.pem
|
||||
|
||||
## add *.cer to .gitignore to prevent certificates from being saved in repo
|
||||
if ! grep -Fxq '*.cer' ./.gitignore
|
||||
then
|
||||
echo "# .CER Certificates" >> .gitignore
|
||||
echo "*.cer" >> .gitignore
|
||||
fi
|
||||
|
||||
## add *.pem to .gitignore to prevent certificates from being saved in repo
|
||||
if ! grep -Fxq '*.pem' ./.gitignore
|
||||
then
|
||||
echo "# .PEM Certificates" >> .gitignore
|
||||
echo "*.pem" >> .gitignore
|
||||
fi
|
||||
|
||||
echo
|
||||
echo -e "\e[1;92mReady!\e[0m"
|
||||
|
||||
echo -e "\n\e[1;94m**********\nOptional: if you plan on using gulp serve, don't forget to add the container certificate to your local machine. Please visit https://aka.ms/spfx-devcontainer for more information\n**********"
|
|
@ -0,0 +1,5 @@
|
|||
require('@rushstack/eslint-config/patch/modern-module-resolution');
|
||||
module.exports = {
|
||||
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
|
||||
parserOptions: { tsconfigRootDir: __dirname }
|
||||
};
|
|
@ -5,6 +5,8 @@ npm-debug.log*
|
|||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
.heft
|
||||
release
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
!dist
|
||||
config
|
||||
|
||||
gulpfile.js
|
||||
|
||||
release
|
||||
src
|
||||
temp
|
||||
|
||||
tsconfig.json
|
||||
tslint.json
|
||||
|
||||
*.log
|
||||
|
||||
.yo-rc.json
|
||||
.vscode
|
|
@ -2,11 +2,16 @@
|
|||
"@microsoft/generator-sharepoint": {
|
||||
"isCreatingSolution": true,
|
||||
"environment": "spo",
|
||||
"version": "1.11.0",
|
||||
"version": "1.16.1",
|
||||
"nodeVersion": "14.18.1",
|
||||
"libraryName": "advanced-page-properties",
|
||||
"libraryId": "daae06a2-8599-445c-93c0-3bd739305f56",
|
||||
"packageManager": "npm",
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart"
|
||||
"componentType": "webpart",
|
||||
"sdkVersions": {
|
||||
"@microsoft/microsoft-graph-client": "3.0.2",
|
||||
"@microsoft/teams-js": "2.4.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,22 +13,22 @@ Attempts to replicate the functionality of Page Properties with the following im
|
|||
|
||||
![see the difference](./assets/diff-screencap.png)
|
||||
|
||||
|
||||
## Compatibility
|
||||
|
||||
| :warning: Important |
|
||||
|:---------------------------|
|
||||
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|
||||
| Every SPFx version is optimally compatible with specific versions of Node.js. In order to be able to build this sample, you need to ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|
||||
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
|
||||
|
||||
![SPFx 1.11](https://img.shields.io/badge/SPFx-1.11.0-green.svg)
|
||||
![Node.js v10](https://img.shields.io/badge/Node.js-v10-green.svg)
|
||||
This sample is optimally compatible with the following environment configuration:
|
||||
|
||||
![SPFx 1.16.1](https://img.shields.io/badge/SPFx-1.16.1-green.svg)
|
||||
![Node.js v16 | v14 | v12](https://img.shields.io/badge/Node.js-v16%20%7C%20v14%20%7C%20v12-green.svg)
|
||||
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
|
||||
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
|
||||
![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
|
||||
![Teams Incompatible](https://img.shields.io/badge/Teams-Incompatible-lightgrey.svg)
|
||||
![Local Workbench Incompatible](https://img.shields.io/badge/Local%20Workbench-Incompatible-red.svg "This solution requires access to information about the hosting page")
|
||||
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-yellow.svg "Works better when placed on a modern site page.")
|
||||
![Local Workbench Unsupported](https://img.shields.io/badge/Local%20Workbench-Unsupported-red.svg "Local workbench is no longer available as of SPFx 1.13 and above")
|
||||
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
|
||||
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
|
||||
|
||||
## Applies to
|
||||
|
@ -44,8 +44,9 @@ None
|
|||
|
||||
## Contributors
|
||||
|
||||
- [Mike Homol](https://homol.work), Principal Consultant, [ThreeWill](https://threewill.com/)
|
||||
- Abderahman Moujahid
|
||||
- [Mike Homol](https://github.com/mhomol), <https://homol.work> Principal> Consultant, [ThreeWill](https://threewill.com/)
|
||||
- [Abderahman Moujahid](https://github.com/Abderahman88)
|
||||
- [Valeras Narbutas](https://github.com/ValerasNarbutas)
|
||||
|
||||
## Version history
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"- Improved support for dates"
|
||||
],
|
||||
"creationDateTime": "2021-03-30",
|
||||
"updateDateTime": "2022-01-12",
|
||||
"updateDateTime": "2023-03-06",
|
||||
"products": [
|
||||
"SharePoint"
|
||||
],
|
||||
|
@ -26,7 +26,7 @@
|
|||
},
|
||||
{
|
||||
"key": "SPFX-VERSION",
|
||||
"value": "1.11.0"
|
||||
"value": "1.16.1"
|
||||
}
|
||||
],
|
||||
"thumbnails": [
|
||||
|
@ -50,6 +50,13 @@
|
|||
}
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"gitHubAccount": "ValerasNarbutas",
|
||||
"company": "Macaw",
|
||||
"pictureUrl": "https://avatars.githubusercontent.com/u/16476453?v=4",
|
||||
"name": "Valeras Narbutas",
|
||||
"twitter": "ValerasNarbutas"
|
||||
},
|
||||
{
|
||||
"gitHubAccount": "mhomol",
|
||||
"company": "ThreeWill",
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./temp/deploy/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "advanced-page-properties",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./release/assets/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "advanced-page-properties",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"solution": {
|
||||
"name": "Advanced Page Properties",
|
||||
"id": "daae06a2-8599-445c-93c0-3bd739305f56",
|
||||
"version": "1.0.3.0",
|
||||
"version": "1.0.4.0",
|
||||
"includeClientSideAssets": true,
|
||||
"isDomainIsolated": false,
|
||||
"developer": {
|
||||
|
@ -12,7 +12,29 @@
|
|||
"privacyUrl": "",
|
||||
"termsOfUseUrl": "",
|
||||
"mpnId": "990019737"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"shortDescription": {
|
||||
"default": "advanced-page-properties description"
|
||||
},
|
||||
"longDescription": {
|
||||
"default": "advanced-page-properties description"
|
||||
},
|
||||
"screenshotPaths": [],
|
||||
"videoUrl": "",
|
||||
"categories": []
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"title": "advanced-page-properties AdvancedPagePropertiesWebPart Feature",
|
||||
"description": "The feature that activates AdvancedPagePropertiesWebPart from the advanced-page-properties solution.",
|
||||
"id": "bdbcb04e-9c90-4adb-b0f0-d025e4eb6cb5",
|
||||
"version": "1.0.3.0",
|
||||
"componentIds": [
|
||||
"bdbcb04e-9c90-4adb-b0f0-d025e4eb6cb5"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/advanced-page-properties.sppkg"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
|
||||
}
|
|
@ -1,10 +1,6 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://localhost:5432/workbench",
|
||||
"api": {
|
||||
"port": 5432,
|
||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||
}
|
||||
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
|
||||
}
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
const build = require('@microsoft/sp-build-web');
|
||||
|
||||
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||
|
||||
build.initialize(require('gulp'));
|
||||
'use strict';
|
||||
|
||||
const build = require('@microsoft/sp-build-web');
|
||||
|
||||
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||
|
||||
var getTasks = build.rig.getTasks;
|
||||
build.rig.getTasks = function () {
|
||||
var result = getTasks.call(build.rig);
|
||||
|
||||
result.set('serve', result.get('serve-deprecated'));
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
build.initialize(require('gulp'));
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@
|
|||
"private": true,
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
"node": ">=16.13.0 <17.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
|
@ -13,31 +13,36 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@fluentui/react": "^8.7.0",
|
||||
"@microsoft/sp-core-library": "1.11.0",
|
||||
"@microsoft/sp-lodash-subset": "1.11.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.11.0",
|
||||
"@microsoft/sp-property-pane": "1.11.0",
|
||||
"@microsoft/sp-webpart-base": "1.11.0",
|
||||
"@pnp/sp": "^2.3.0",
|
||||
"@microsoft/sp-adaptive-card-extension-base": "1.16.1",
|
||||
"@microsoft/sp-core-library": "1.16.1",
|
||||
"@microsoft/sp-lodash-subset": "1.16.1",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.16.1",
|
||||
"@microsoft/sp-property-pane": "1.16.1",
|
||||
"@microsoft/sp-tslint-rules": "^1.16.1",
|
||||
"@microsoft/sp-webpart-base": "1.16.1",
|
||||
"@pnp/logging": "^3.12.1",
|
||||
"@pnp/sp": "^3.9.0",
|
||||
"@pnp/spfx-property-controls": "^3.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"office-ui-fabric-react": "6.214.0",
|
||||
"react": "16.8.5",
|
||||
"react-dom": "16.8.5"
|
||||
"office-ui-fabric-react": "7.199.1",
|
||||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1",
|
||||
"tslib": "2.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "16.8.8",
|
||||
"@types/react-dom": "16.8.3",
|
||||
"@microsoft/eslint-config-spfx": "1.16.1",
|
||||
"@microsoft/eslint-plugin-spfx": "1.16.1",
|
||||
"@microsoft/rush-stack-compiler-4.5": "0.2.2",
|
||||
"@microsoft/sp-build-web": "1.16.1",
|
||||
"@microsoft/sp-tslint-rules": "1.11.0",
|
||||
"@microsoft/sp-module-interfaces": "1.11.0",
|
||||
"@microsoft/sp-webpart-workbench": "1.12.1",
|
||||
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
|
||||
"gulp": "~3.9.1",
|
||||
"@types/chai": "3.4.34",
|
||||
"@types/mocha": "2.2.38",
|
||||
"ajv": "~5.2.2",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"@types/es6-promise": "0.0.33"
|
||||
"@microsoft/sp-module-interfaces": "1.16.1",
|
||||
"@rushstack/eslint-config": "2.5.1",
|
||||
"@types/react": "17.0.45",
|
||||
"@types/react-dom": "17.0.17",
|
||||
"@types/webpack-env": "1.15.2",
|
||||
"ajv": "6.12.5",
|
||||
"eslint": "8.7.0",
|
||||
"eslint-plugin-react-hooks": "4.3.0",
|
||||
"gulp": "4.0.2",
|
||||
"typescript": "4.5.5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ import * as strings from 'AdvancedPagePropertiesWebPartStrings';
|
|||
import AdvancedPageProperties from './components/AdvancedPageProperties';
|
||||
import { IAdvancedPagePropertiesProps } from './components/IAdvancedPagePropertiesProps';
|
||||
//import { PropertyFieldMultiSelect } from '@pnp/spfx-property-controls/lib/PropertyFieldMultiSelect';
|
||||
import "@pnp/sp/fields";
|
||||
import "@pnp/sp/fields/list";
|
||||
import { FieldTypes, sp } from "@pnp/sp/presets/all";
|
||||
import { getSP } from './utilities/pnpjs-config';
|
||||
import { SPFI } from '@pnp/sp';
|
||||
|
||||
import { Log } from './utilities/Log';
|
||||
import * as _ from 'lodash';
|
||||
import {
|
||||
|
@ -28,7 +28,8 @@ export interface IAdvancedPagePropertiesWebPartProps {
|
|||
|
||||
export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart<IAdvancedPagePropertiesWebPartProps> {
|
||||
|
||||
private availableProperties: IPropertyPaneDropdownOption[] = [];
|
||||
private _availableProperties: IPropertyPaneDropdownOption[] = [];
|
||||
|
||||
private _themeProvider: ThemeProvider;
|
||||
private _themeVariant: IReadonlyTheme | undefined;
|
||||
|
||||
|
@ -37,8 +38,13 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
|
|||
this.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Private variable to store the SharePoint Factory Instance
|
||||
*/
|
||||
private _sp: SPFI;
|
||||
|
||||
protected async onInit(): Promise<void> {
|
||||
sp.setup({ spfxContext: this.context });
|
||||
this._sp = getSP(this.context);
|
||||
|
||||
// Consume the new ThemeProvider service
|
||||
this._themeProvider = this.context.serviceScope.consume(ThemeProvider.serviceKey);
|
||||
|
@ -68,17 +74,18 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
|
|||
|
||||
private async getPageProperties(): Promise<void> {
|
||||
Log.Write("Getting Site Page fields...");
|
||||
const list = await sp.web.lists.ensureSitePagesLibrary();
|
||||
const fi = await list.fields();
|
||||
const list = await this._sp.web.lists.ensureSitePagesLibrary();
|
||||
const _fields = await list.fields();
|
||||
this._availableProperties = [];
|
||||
|
||||
this.availableProperties = [];
|
||||
Log.Write(`${fi.length.toString()} fields retrieved!`);
|
||||
fi.forEach((f) => {
|
||||
if (!f.FromBaseType && !f.Hidden && f.SchemaXml.indexOf("ShowInListSettings=\"FALSE\"") === -1
|
||||
&& f.TypeAsString !== "Boolean" && f.TypeAsString !== "Note") {
|
||||
const internalFieldName = f.InternalName == "LinkTitle" ? "Title" : f.InternalName;
|
||||
this.availableProperties.push({ key: internalFieldName, text: f.Title });
|
||||
Log.Write(f.TypeAsString);
|
||||
Log.Write(`${_fields.length.toString()} fields retrieved!`);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_fields.forEach((field: any) => {
|
||||
if (!field.FromBaseType && !field.Hidden && field.SchemaXml.indexOf("ShowInListSettings=\"FALSE\"") === -1
|
||||
&& field.TypeAsString !== "Boolean" && field.TypeAsString !== "Note") {
|
||||
const internalFieldName = field.InternalName == "LinkTitle" ? "Title" : field.InternalName;
|
||||
this._availableProperties.push({ key: internalFieldName, text: field.Title });
|
||||
Log.Write(field.TypeAsString);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -91,20 +98,23 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
|
|||
return Version.parse('1.0');
|
||||
}
|
||||
|
||||
protected onAddButtonClick (value: any) {
|
||||
this.properties.selectedProperties.push(this.availableProperties[0].key.toString());
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
||||
protected onAddButtonClick (_value: any) {
|
||||
this.properties.selectedProperties.push(this._availableProperties[0].key.toString());
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
protected onDeleteButtonClick (value: any) {
|
||||
Log.Write(value.toString());
|
||||
var removed = this.properties.selectedProperties.splice(value, 1);
|
||||
const removed = this.properties.selectedProperties.splice(value, 1);
|
||||
Log.Write(`${removed[0]} removed.`);
|
||||
}
|
||||
|
||||
protected onPropertyPaneFieldChanged(propertyPath: string, oldValue: any, newValue: any): void {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
protected onPropertyPaneFieldChanged(propertyPath: string, _oldValue: any, newValue: any): void {
|
||||
if (propertyPath.indexOf("selectedProperty") >= 0) {
|
||||
Log.Write('Selected Property identified');
|
||||
let index: number = _.toInteger(propertyPath.replace("selectedProperty", ""));
|
||||
const index: number = _.toInteger(propertyPath.replace("selectedProperty", ""));
|
||||
this.properties.selectedProperties[index] = newValue;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +129,8 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
|
|||
Log.Write(`getPropertyPaneConfiguration`);
|
||||
|
||||
// Initialize with the Title entry
|
||||
var propDrops: IPropertyPaneField<any>[] = [];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const propDrops: IPropertyPaneField<any>[] = [];
|
||||
propDrops.push(PropertyPaneTextField('title', {
|
||||
label: strings.TitleFieldLabel
|
||||
}));
|
||||
|
@ -129,7 +140,7 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
|
|||
propDrops.push(PropertyPaneDropdown(`selectedProperty${index.toString()}`,
|
||||
{
|
||||
label: strings.SelectedPropertiesFieldLabel,
|
||||
options: this.availableProperties,
|
||||
options: this._availableProperties,
|
||||
selectedKey: prop,
|
||||
}));
|
||||
// Every drop down gets its own delete button
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@import '~office-ui-fabric-react/dist/sass/References.scss';
|
||||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.advancedPageProperties {
|
||||
.container {
|
||||
|
|
|
@ -6,8 +6,7 @@ import * as _ from 'lodash';
|
|||
import { useState, useEffect, useRef } from 'react';
|
||||
import { PageProperty } from '../models';
|
||||
|
||||
import { sp } from "@pnp/sp";
|
||||
import { DateTimeFieldFormatType, DateTimeFieldFriendlyFormatType, FieldTypes, IField, IFieldInfo } from "@pnp/sp/fields/types";
|
||||
import { getSP } from '../utilities/pnpjs-config';
|
||||
import "@pnp/sp/webs";
|
||||
import "@pnp/sp/lists";
|
||||
import "@pnp/sp/fields";
|
||||
|
@ -28,21 +27,22 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
|
|||
|
||||
propsRef.current = props;
|
||||
|
||||
sp.setup({ spfxContext: props.context });
|
||||
const _sp = getSP(propsRef.current.context);
|
||||
|
||||
/**
|
||||
* refreshProperties
|
||||
* @description Gets the actual values for any selected properties, along with critical field metadata and ultimately re-sets the pagePropValues state
|
||||
*/
|
||||
async function refreshProperties () {
|
||||
var newSetOfValues: PageProperty[] = [];
|
||||
const newSetOfValues: PageProperty[] = [];
|
||||
|
||||
if (props.selectedProperties !== undefined && props.selectedProperties !== null) {
|
||||
Log.Write(`${props.selectedProperties.length.toString()} properties used.`);
|
||||
|
||||
// Get the value(s) for the field from the list item itself
|
||||
var allValues: any = {};
|
||||
const sitePagesList = await sp.web.lists.ensureSitePagesLibrary();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let allValues: any = {};
|
||||
const sitePagesList = await _sp.web.lists.ensureSitePagesLibrary();
|
||||
if (props.context.pageContext.listItem !== undefined && props.context.pageContext.listItem !== null) {
|
||||
allValues = await sitePagesList.items.getById(props.context.pageContext.listItem.id).select(...props.selectedProperties).fieldValuesAsText();
|
||||
}
|
||||
|
@ -56,7 +56,9 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
|
|||
const field = await sitePagesList.fields.getByInternalNameOrTitle(prop)();
|
||||
|
||||
// Establish the values array
|
||||
var values: any[] = [];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let values: any[] = [];
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (allValues.hasOwnProperty(field.InternalName)) {
|
||||
switch (field.TypeAsString) {
|
||||
case "UserMulti":
|
||||
|
@ -102,7 +104,7 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
|
|||
*/
|
||||
const RenderPageProperties = () => {
|
||||
if (pagePropValues !== undefined && pagePropValues !== null) {
|
||||
var retVal = _.map(pagePropValues, (prop) => {
|
||||
const retVal = _.map(pagePropValues, (prop) => {
|
||||
return (
|
||||
<>
|
||||
<div className={styles.propNameRow}>{prop.info.Title}<span style={{display: 'none'}}> - {prop.info.TypeAsString}</span></div>
|
||||
|
@ -125,10 +127,11 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
|
|||
* @returns
|
||||
*/
|
||||
const RenderPagePropValue = (prop: PageProperty) => {
|
||||
var retVal = _.map(prop.values, (val) => {
|
||||
const retVal = _.map(prop.values, (val) => {
|
||||
if (val !== null && val !== "") {
|
||||
switch (prop.info.TypeAsString) {
|
||||
case "URL":
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
const url_parts = val.split(",");
|
||||
return (
|
||||
<span className={styles.urlValue}><a href={url_parts[0]} target="_blank" rel="noopener noreferrer" style={{color: semanticColors.link}}>{url_parts[1]}</a></span>
|
||||
|
|
|
@ -2,5 +2,6 @@ import { IFieldInfo } from "@pnp/sp/fields";
|
|||
|
||||
export interface PageProperty {
|
||||
info: IFieldInfo;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
values: any[];
|
||||
}
|
||||
|
|
|
@ -2,13 +2,11 @@ import * as strings from "AdvancedPagePropertiesWebPartStrings";
|
|||
|
||||
export class Log {
|
||||
private static readonly logStyle: string = "background: crimson; padding: 5px; border-radius: 5px; color: white";
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
public static Write(s: string, always: boolean = false) {
|
||||
let d = new Date();
|
||||
let dateStr = d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds() + '.' + d.getMilliseconds();
|
||||
public static Write(s: string, always = false):void {
|
||||
const d = new Date();
|
||||
const dateStr = d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds() + '.' + d.getMilliseconds();
|
||||
|
||||
if (window.location.search.indexOf("debug") >= 0 || always) {
|
||||
console.log(`%c${strings.LogAppName} >> ${dateStr} >> ${s}`, Log.logStyle);
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import { WebPartContext } from "@microsoft/sp-webpart-base";
|
||||
|
||||
// import pnp, pnp logging system, and any other selective imports needed
|
||||
import { spfi, SPFI, SPFx } from "@pnp/sp";
|
||||
import { LogLevel, PnPLogging } from "@pnp/logging";
|
||||
import "@pnp/sp/webs";
|
||||
import "@pnp/sp/lists";
|
||||
import "@pnp/sp/fields";
|
||||
import "@pnp/sp/items";
|
||||
import "@pnp/sp/regional-settings/web";
|
||||
|
||||
|
||||
let _sp: SPFI = null;
|
||||
|
||||
export const getSP = (context?: WebPartContext): SPFI => {
|
||||
if (context != null) {
|
||||
//You must add the @pnp/logging package to include the PnPLogging behavior it is no longer a peer dependency
|
||||
// The LogLevel set's at what level a message will be written to the console
|
||||
_sp = spfi().using(SPFx(context)).using(PnPLogging(LogLevel.Warning));
|
||||
}
|
||||
return _sp;
|
||||
};
|
|
@ -1,39 +1,37 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/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"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib"
|
||||
]
|
||||
}
|
||||
{
|
||||
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.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,
|
||||
"noImplicitAny": true,
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection",
|
||||
"es2015.promise"
|
||||
],
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
|
||||
"rules": {
|
||||
"class-name": false,
|
||||
"export-name": false,
|
||||
"forin": false,
|
||||
"label-position": false,
|
||||
"member-access": true,
|
||||
"no-arg": false,
|
||||
"no-console": false,
|
||||
"no-construct": false,
|
||||
"no-duplicate-variable": true,
|
||||
"no-eval": false,
|
||||
"no-function-expression": true,
|
||||
"no-internal-module": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-unnecessary-semicolons": true,
|
||||
"no-unused-expression": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-with-statement": true,
|
||||
"semicolon": true,
|
||||
"trailing-comma": false,
|
||||
"typedef": false,
|
||||
"typedef-whitespace": false,
|
||||
"use-named-parameter": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue