Merge pull request #2049 from Abderahman88/patch-2034

[react-advanced-page-properties] Fix webpart on sites in a different language
This commit is contained in:
Hugo Bernier 2021-09-23 02:18:50 -04:00 committed by GitHub
commit e8e49c3e18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 19 deletions

View File

@ -38,18 +38,14 @@ None
Solution|Author(s)
--------|---------
src/react-advanced-page-properties | [Mike Homol](https://homol.work), Principal Consultant, [ThreeWill](https://threewill.com/)
react-advanced-page-properties | Abderahman Moujahid
## Version history
Version|Date|Comments
-------|----|--------
1.0|March 30, 2021|Initial release
## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
---
1.0.0|March 30, 2021|Initial release
1.0.1|September 22, 2021|Added support for multi-language sites
## Minimal Path to Awesome
@ -59,17 +55,15 @@ Version|Date|Comments
- **npm install**
- **gulp serve**
> Include any additional steps as needed.
## Features
> Add the part
### Add the part
Once the solution is installed in the app catalog and the app has been added to the site, you should see it available to a page.
![add the part](./assets/add-to-page.png)
> Familiarity is key
### Familiarity is key
This web part tries to mimic the original Page Properties web part as much as possible. You should recognize the functionality of the property setup.

View File

@ -15,7 +15,7 @@
"- Improved support for dates"
],
"creationDateTime": "2021-03-30",
"updateDateTime": "2021-03-30",
"updateDateTime": "2021-09-22",
"products": [
"SharePoint",
"Office"
@ -57,6 +57,12 @@
"pictureUrl": "https://github.com/mhomol.png",
"name": "Mike Homol",
"twitter": "homol"
},
{
"gitHubAccount": "Abderahman88",
"company": "",
"pictureUrl": "https://avatars.githubusercontent.com/u/36161889?s=460\u0026u=afdd5f6681bc375ee3811482dec79824c12d8170\u0026v=4",
"name": "Abderahman Moujahid"
}
],
"references": [

View File

@ -3,7 +3,7 @@
"solution": {
"name": "Advanced Page Properties",
"id": "daae06a2-8599-445c-93c0-3bd739305f56",
"version": "1.0.0.0",
"version": "1.0.1.0",
"includeClientSideAssets": true,
"isDomainIsolated": false,
"developer": {

View File

@ -68,13 +68,13 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
private async getPageProperties(): Promise<void> {
Log.Write("Getting Site Page fields...");
const list = sp.web.lists.getByTitle("Site Pages");
const list = await sp.web.lists.ensureSiteAssetsLibrary();
const fi = await list.fields();
this.availableProperties = [];
Log.Write(`${fi.length.toString()} fields retrieved!`);
fi.forEach((f) => {
if (!f.FromBaseType && !f.Hidden && !f.Sealed && f.SchemaXml.indexOf("ShowInListSettings=\"FALSE\"") === -1
if (!f.FromBaseType && !f.Hidden && f.SchemaXml.indexOf("ShowInListSettings=\"FALSE\"") === -1
&& f.TypeAsString !== "Boolean" && f.TypeAsString !== "Note" && f.TypeAsString !== "User") {
this.availableProperties.push({ key: f.InternalName, text: f.Title });
Log.Write(f.TypeAsString);

View File

@ -42,9 +42,9 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
// Get the value(s) for the field from the list item itself
var allValues: any = {};
const siteAssetsList = await sp.web.lists.ensureSitePagesLibrary();
if (props.context.pageContext.listItem !== undefined && props.context.pageContext.listItem !== null) {
allValues = await sp.web.lists.getByTitle("Site Pages").items.getById(props.context.pageContext.listItem.id).select(...props.selectedProperties).get();
console.log(allValues);
allValues = await siteAssetsList.items.getById(props.context.pageContext.listItem.id).select(...props.selectedProperties).get();
}
for (let i = 0; i < props.selectedProperties.length; i++) {
@ -53,7 +53,7 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
Log.Write(`Selected Property: ${prop}`);
// Get field information, in case anything is needed in conjunction with value types
const field = await sp.web.lists.getByTitle("Site Pages").fields.getByInternalNameOrTitle(prop)();
const field = await siteAssetsList.fields.getByInternalNameOrTitle(prop)();
// Establish the values array
var values: any[] = [];
@ -123,7 +123,6 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
* @returns
*/
const RenderPagePropValue = (prop: PageProperty) => {
console.log(prop);
var retVal = _.map(prop.values, (val) => {
if (val !== null) {
switch (prop.info.TypeAsString) {