Merge pull request #4104 from AriGunawan/feature/add_support_for_choice_and_date
This commit is contained in:
commit
8cfd4b13c6
|
@ -1 +1 @@
|
||||||
v16.13.0
|
v14.15.0
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
This is a web part that goes beyond the standard SharePoint Page Properties web part, offering expanded support for various metadata types and configurations. Effortlessly display key page details based on metadata files, providing a comprehensive view of your content. Streamline information management and enhance user interaction with this versatile and customizable web part.
|
This is a web part that goes beyond the standard SharePoint Page Properties web part, offering expanded support for various metadata types and configurations. Effortlessly display key page details based on metadata files, providing a comprehensive view of your content. Streamline information management and enhance user interaction with this versatile and customizable web part.
|
||||||
|
|
||||||
|
Currently support following types:
|
||||||
|
- Single line text
|
||||||
|
- Multiple line text
|
||||||
|
- Choice
|
||||||
|
- Date
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
- **Title**: Allow to set the displayed title. The built in SharePoint Page Properties web part doesn't allow user to change the displayed title. It will always be **Properties**
|
- **Title**: Allow to set the displayed title. The built in SharePoint Page Properties web part doesn't allow user to change the displayed title. It will always be **Properties**
|
||||||
|
@ -11,9 +17,12 @@ This is a web part that goes beyond the standard SharePoint Page Properties web
|
||||||
|
|
||||||
### Plan for next version
|
### Plan for next version
|
||||||
|
|
||||||
- Support choice field view
|
- Support taxonomy field view
|
||||||
- Support people field view
|
- Support people field view
|
||||||
- Support date time field view
|
- Support lookup field view
|
||||||
|
- Support currency field view
|
||||||
|
- Support hyperlink field view
|
||||||
|
- Support image field view
|
||||||
- Improve web part configuration
|
- Improve web part configuration
|
||||||
|
|
||||||
![Web part](assets/app.png)
|
![Web part](assets/app.png)
|
||||||
|
@ -30,7 +39,7 @@ This is a web part that goes beyond the standard SharePoint Page Properties web
|
||||||
- [SharePoint Framework](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
|
- [SharePoint Framework](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
|
||||||
- [Microsoft 365 tenant](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
|
- [Microsoft 365 tenant](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
|
||||||
|
|
||||||
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/m365devprogram)
|
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](https://aka.ms/m365devprogram)
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
|
@ -40,6 +49,7 @@ This is a web part that goes beyond the standard SharePoint Page Properties web
|
||||||
|
|
||||||
Version|Date|Comments
|
Version|Date|Comments
|
||||||
-------|----|--------
|
-------|----|--------
|
||||||
|
1.1|October 23, 2023|Add support for choice and date fields
|
||||||
1.0|September 23, 2023|Initial release
|
1.0|September 23, 2023|Initial release
|
||||||
|
|
||||||
## Minimal path to awesome
|
## Minimal path to awesome
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 459 KiB After Width: | Height: | Size: 521 KiB |
|
@ -10,7 +10,7 @@
|
||||||
"This is a web part that goes beyond the standard SharePoint Page Properties web part, offering expanded support for various metadata types and configurations. Effortlessly display key page details based on metadata files, providing a comprehensive view of your content. Streamline information management and enhance user interaction with this versatile and customizable web part."
|
"This is a web part that goes beyond the standard SharePoint Page Properties web part, offering expanded support for various metadata types and configurations. Effortlessly display key page details based on metadata files, providing a comprehensive view of your content. Streamline information management and enhance user interaction with this versatile and customizable web part."
|
||||||
],
|
],
|
||||||
"creationDateTime": "2023-09-23",
|
"creationDateTime": "2023-09-23",
|
||||||
"updateDateTime": "2023-09-23",
|
"updateDateTime": "2023-10-10",
|
||||||
"products": [
|
"products": [
|
||||||
"SharePoint"
|
"SharePoint"
|
||||||
],
|
],
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"solution": {
|
"solution": {
|
||||||
"name": "Enhanced Page Properties",
|
"name": "Enhanced Page Properties",
|
||||||
"id": "54ea24ef-5714-4f81-a9e6-e22f70e0c644",
|
"id": "54ea24ef-5714-4f81-a9e6-e22f70e0c644",
|
||||||
"version": "1.0.0.0",
|
"version": "1.1.0.0",
|
||||||
"includeClientSideAssets": true,
|
"includeClientSideAssets": true,
|
||||||
"skipFeatureDeployment": true,
|
"skipFeatureDeployment": true,
|
||||||
"isDomainIsolated": false,
|
"isDomainIsolated": false,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"@microsoft/sp-property-pane": "1.17.4",
|
"@microsoft/sp-property-pane": "1.17.4",
|
||||||
"@microsoft/sp-webpart-base": "1.17.4",
|
"@microsoft/sp-webpart-base": "1.17.4",
|
||||||
"@pnp/sp": "^3.17.0",
|
"@pnp/sp": "^3.17.0",
|
||||||
|
"date-fns": "^2.30.0",
|
||||||
"office-ui-fabric-react": "^7.199.1",
|
"office-ui-fabric-react": "^7.199.1",
|
||||||
"react": "17.0.1",
|
"react": "17.0.1",
|
||||||
"react-dom": "17.0.1",
|
"react-dom": "17.0.1",
|
||||||
|
@ -844,7 +845,6 @@
|
||||||
"version": "7.22.6",
|
"version": "7.22.6",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz",
|
||||||
"integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==",
|
"integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"regenerator-runtime": "^0.13.11"
|
"regenerator-runtime": "^0.13.11"
|
||||||
},
|
},
|
||||||
|
@ -15993,6 +15993,21 @@
|
||||||
"webidl-conversions": "^4.0.2"
|
"webidl-conversions": "^4.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/date-fns": {
|
||||||
|
"version": "2.30.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz",
|
||||||
|
"integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.21.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.11"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/date-fns"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/dateformat": {
|
"node_modules/dateformat": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz",
|
||||||
|
@ -28306,8 +28321,7 @@
|
||||||
"node_modules/regenerator-runtime": {
|
"node_modules/regenerator-runtime": {
|
||||||
"version": "0.13.11",
|
"version": "0.13.11",
|
||||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||||
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
|
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
|
||||||
"peer": true
|
|
||||||
},
|
},
|
||||||
"node_modules/regex-not": {
|
"node_modules/regex-not": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
@ -37462,7 +37476,6 @@
|
||||||
"version": "7.22.6",
|
"version": "7.22.6",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz",
|
||||||
"integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==",
|
"integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==",
|
||||||
"peer": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"regenerator-runtime": "^0.13.11"
|
"regenerator-runtime": "^0.13.11"
|
||||||
}
|
}
|
||||||
|
@ -49442,6 +49455,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"date-fns": {
|
||||||
|
"version": "2.30.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz",
|
||||||
|
"integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==",
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.21.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"dateformat": {
|
"dateformat": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz",
|
||||||
|
@ -59113,8 +59134,7 @@
|
||||||
"regenerator-runtime": {
|
"regenerator-runtime": {
|
||||||
"version": "0.13.11",
|
"version": "0.13.11",
|
||||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||||
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
|
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
|
||||||
"peer": true
|
|
||||||
},
|
},
|
||||||
"regex-not": {
|
"regex-not": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
"@microsoft/sp-property-pane": "1.17.4",
|
"@microsoft/sp-property-pane": "1.17.4",
|
||||||
"@microsoft/sp-webpart-base": "1.17.4",
|
"@microsoft/sp-webpart-base": "1.17.4",
|
||||||
"@pnp/sp": "^3.17.0",
|
"@pnp/sp": "^3.17.0",
|
||||||
|
"date-fns": "^2.30.0",
|
||||||
"office-ui-fabric-react": "^7.199.1",
|
"office-ui-fabric-react": "^7.199.1",
|
||||||
"react": "17.0.1",
|
"react": "17.0.1",
|
||||||
"react-dom": "17.0.1",
|
"react-dom": "17.0.1",
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { SPFI, spfi, SPFx } from "@pnp/sp";
|
||||||
|
|
||||||
import EnhancedPageProperties from "./components/EnhancedPageProperties";
|
import EnhancedPageProperties from "./components/EnhancedPageProperties";
|
||||||
import { IEnhancedPagePropertiesProps } from "./components/IEnhancedPagePropertiesProps";
|
import { IEnhancedPagePropertiesProps } from "./components/IEnhancedPagePropertiesProps";
|
||||||
|
import { IFieldInfo } from "@pnp/sp/fields";
|
||||||
|
|
||||||
export interface IEnhancedPagePropertiesWebPartProps {
|
export interface IEnhancedPagePropertiesWebPartProps {
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -23,14 +24,13 @@ export interface IEnhancedPagePropertiesWebPartProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface propertyItem {
|
export interface propertyItem {
|
||||||
|
field?: IFieldInfo;
|
||||||
|
value: string | string[];
|
||||||
label: string;
|
label: string;
|
||||||
field: string;
|
|
||||||
value: string;
|
|
||||||
isAvailable: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class EnhancedPagePropertiesWebPart extends BaseClientSideWebPart<IEnhancedPagePropertiesWebPartProps> {
|
export default class EnhancedPagePropertiesWebPart extends BaseClientSideWebPart<IEnhancedPagePropertiesWebPartProps> {
|
||||||
private readonly docLibTitle = 'Site Pages';
|
private readonly docLibTitle = "Site Pages";
|
||||||
private _sp: SPFI;
|
private _sp: SPFI;
|
||||||
|
|
||||||
public async render(): Promise<void> {
|
public async render(): Promise<void> {
|
||||||
|
@ -59,11 +59,11 @@ export default class EnhancedPagePropertiesWebPart extends BaseClientSideWebPart
|
||||||
.getByTitle(this.docLibTitle)
|
.getByTitle(this.docLibTitle)
|
||||||
.fields();
|
.fields();
|
||||||
// Filter to only non hidden fields
|
// Filter to only non hidden fields
|
||||||
const filteredAvailableFields: Map<string, string> = new Map();
|
const filteredAvailableFields: Map<string, IFieldInfo> = new Map();
|
||||||
for (let i = 0; i < availableFields.length; i++) {
|
for (let i = 0; i < availableFields.length; i++) {
|
||||||
const field = availableFields[i];
|
const field = availableFields[i];
|
||||||
if (field.Hidden) continue;
|
if (field.Hidden) continue;
|
||||||
filteredAvailableFields.set(field.InternalName, field.Title);
|
filteredAvailableFields.set(field.InternalName, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedFields = this.convertSelectedFieldsString();
|
const selectedFields = this.convertSelectedFieldsString();
|
||||||
|
@ -76,13 +76,12 @@ export default class EnhancedPagePropertiesWebPart extends BaseClientSideWebPart
|
||||||
...selectedFields.filter((field) => filteredAvailableFields.has(field))
|
...selectedFields.filter((field) => filteredAvailableFields.has(field))
|
||||||
)();
|
)();
|
||||||
for (let i = 0; i < selectedFields.length; i++) {
|
for (let i = 0; i < selectedFields.length; i++) {
|
||||||
const field = selectedFields[i];
|
const internalName = selectedFields[i];
|
||||||
const isAvailable = filteredAvailableFields.has(field);
|
const field = filteredAvailableFields.get(internalName);
|
||||||
propertyItems.push({
|
propertyItems.push({
|
||||||
field,
|
field,
|
||||||
isAvailable,
|
label: field ? field.Title : internalName,
|
||||||
label: isAvailable ? (filteredAvailableFields.get(field) || '') : field,
|
value: currentPageProperties[internalName],
|
||||||
value: currentPageProperties[field],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return propertyItems;
|
return propertyItems;
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.choice {
|
||||||
|
display: flex;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
background-color: #fafafa;
|
background-color: #fafafa;
|
||||||
padding: 8px 13px;
|
padding: 8px 13px;
|
||||||
|
@ -36,7 +41,6 @@
|
||||||
background-color: #fce100;
|
background-color: #fce100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@ import * as React from 'react';
|
||||||
|
|
||||||
import styles from './EnhancedPageProperties.module.scss';
|
import styles from './EnhancedPageProperties.module.scss';
|
||||||
import { IEnhancedPagePropertiesProps } from './IEnhancedPagePropertiesProps';
|
import { IEnhancedPagePropertiesProps } from './IEnhancedPagePropertiesProps';
|
||||||
|
import Value from './Value/Value';
|
||||||
|
|
||||||
export default function EnhancedPageProperties(
|
export default function EnhancedPageProperties(
|
||||||
props: IEnhancedPagePropertiesProps
|
props: IEnhancedPagePropertiesProps
|
||||||
|
@ -11,10 +12,10 @@ export default function EnhancedPageProperties(
|
||||||
<h2>{props.title}</h2>
|
<h2>{props.title}</h2>
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
{props.items.map((item) => (
|
{props.items.map((item) => (
|
||||||
<div key={item.field} className={styles.item}>
|
<div key={item.field?.Id} className={styles.item}>
|
||||||
<h3>{item.label}</h3>
|
<h3>{item.label}</h3>
|
||||||
{item.isAvailable ? (
|
{item.field ? (
|
||||||
<span>{item.value || "-"}</span>
|
<Value field={item.field} value={item.value} />
|
||||||
) : (
|
) : (
|
||||||
<span className={styles.errorMessage}>
|
<span className={styles.errorMessage}>
|
||||||
Field not available in the Library metadata. Please check again the
|
Field not available in the Library metadata. Please check again the
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { IFieldInfo } from "@pnp/sp/fields";
|
||||||
|
import { format } from "date-fns";
|
||||||
|
import * as React from "react";
|
||||||
|
import styles from "../EnhancedPageProperties.module.scss";
|
||||||
|
|
||||||
|
export interface IValueProps {
|
||||||
|
field: IFieldInfo;
|
||||||
|
value: string | string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Value(props: IValueProps): JSX.Element {
|
||||||
|
if (!props.value) return <span>-</span>;
|
||||||
|
|
||||||
|
switch (props.field.TypeDisplayName) {
|
||||||
|
case "Choice": {
|
||||||
|
const value = props.value as string[];
|
||||||
|
return (
|
||||||
|
<div className={styles.choice}>
|
||||||
|
{value.map((item: string) => (
|
||||||
|
<span key={item}>{item}</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case "Date and Time": {
|
||||||
|
return (
|
||||||
|
<span>{format(new Date(props.value as string), "dd MMMM yyyy")}</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return <span>{props.value}</span>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue