Updates.
This commit is contained in:
parent
07a01cd2f8
commit
a575ca628d
1 changed files with 45 additions and 44 deletions
|
|
@ -6,53 +6,54 @@ export function fetchCmsContentForPage(issPage) {
|
||||||
const clientName = store.issConfig.clientName;
|
const clientName = store.issConfig.clientName;
|
||||||
const pageName = issPage + (clientName.length == 0 ? "" : "_" + clientName);
|
const pageName = issPage + (clientName.length == 0 ? "" : "_" + clientName);
|
||||||
|
|
||||||
return store.getPageData(pageName)
|
return store.getPageData(pageName)
|
||||||
.then(
|
.then(
|
||||||
// Get the client specific page if it exists.
|
// Get the client specific page if it exists.
|
||||||
(response) => { return processPageData(response); },
|
(response) => { return processPageData(response); },
|
||||||
(error) => {
|
(error) => {
|
||||||
// If the client specific page does not exist, get the base page.
|
// If the client specific page does not exist, get the base page.
|
||||||
if ( clientName.length > 0 )
|
if ( clientName.length > 0 )
|
||||||
{
|
{
|
||||||
return store.getPageData(issPage)
|
return store.getPageData(issPage)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return processPageData(response);
|
return processPageData(response);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function processPageData(response) {
|
// Support method for processing the page data from the CMS call.
|
||||||
const pageDataFromCms = {};
|
function processPageData(response) {
|
||||||
|
const pageDataFromCms = {};
|
||||||
response.data.Result.forEach((widget) => {
|
|
||||||
let widgetWithReplacements = findAndReplaceGlobalStateValues(
|
response.data.Result.forEach((widget) => {
|
||||||
widget.Model,
|
let widgetWithReplacements = findAndReplaceGlobalStateValues(
|
||||||
widget.Name
|
widget.Model,
|
||||||
|
widget.Name
|
||||||
|
);
|
||||||
|
|
||||||
|
// If we already have this widget, push it on the collection
|
||||||
|
if (widgetWithReplacements.Name in pageDataFromCms) {
|
||||||
|
pageDataFromCms[widgetWithReplacements.Name].push(
|
||||||
|
widgetWithReplacements.Model
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
// If we already have this widget, push it on the collection
|
}
|
||||||
if (widgetWithReplacements.Name in pageDataFromCms) {
|
|
||||||
pageDataFromCms[widgetWithReplacements.Name].push(
|
pageDataFromCms[widgetWithReplacements.Name] = [
|
||||||
widgetWithReplacements.Model
|
widgetWithReplacements.Model,
|
||||||
);
|
];
|
||||||
return;
|
});
|
||||||
}
|
|
||||||
|
Object.keys(pageDataFromCms).forEach((key) => {
|
||||||
pageDataFromCms[widgetWithReplacements.Name] = [
|
if (pageDataFromCms[key].length === 1) {
|
||||||
widgetWithReplacements.Model,
|
pageDataFromCms[key] = pageDataFromCms[key][0];
|
||||||
];
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(pageDataFromCms).forEach((key) => {
|
return pageDataFromCms;
|
||||||
if (pageDataFromCms[key].length === 1) {
|
}
|
||||||
pageDataFromCms[key] = pageDataFromCms[key][0];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return pageDataFromCms;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parent function for processWidgetItemForReplacement. This will loop through the parent
|
// Parent function for processWidgetItemForReplacement. This will loop through the parent
|
||||||
// object and pass any objects that need additional processing to the processWidgetItemForReplacement function.
|
// object and pass any objects that need additional processing to the processWidgetItemForReplacement function.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue