fix sitepages query
This commit is contained in:
parent
b40eefb535
commit
6549bedc47
|
@ -38,12 +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
|
||||
1.0.0|March 30, 2021|Initial release
|
||||
1.0.1|September 22, 2021|Added support for multi-language sites
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue