diff --git a/blocks/gmo-program-details/gmo-program-details.js b/blocks/gmo-program-details/gmo-program-details.js index 5347cb4..5552209 100644 --- a/blocks/gmo-program-details/gmo-program-details.js +++ b/blocks/gmo-program-details/gmo-program-details.js @@ -7,7 +7,7 @@ import { searchAsset } from '../../scripts/assets.js'; let blockConfig; const programName = getQueryVariable('programName'); -const programRefNumber = getQueryVariable('programReferenceNumber'); +const programID = getQueryVariable('programID'); const deliverableMappings = resolveMappings("getDeliverableTypeMapping"); const platformMappings = resolveMappings("getPlatformsMapping"); @@ -15,9 +15,9 @@ export default async function decorate(block) { const encodedSemi = encodeURIComponent(';'); const encodedProgram = encodeURIComponent(programName); - const programQueryString = `getProgramDetails${encodedSemi}programName=${encodedProgram}${encodedSemi}programReferenceNumber=${encodeURIComponent(programRefNumber)}`; + const programQueryString = `getProgramDetails${encodedSemi}programName=${encodedProgram}${encodedSemi}programID=${encodeURIComponent(programID)}`; const programData = await executeQuery(programQueryString); - const deliverableQueryString = `getProgramDeliverables${encodedSemi}programName=${encodedProgram}`; + const deliverableQueryString = `getProgramDeliverables${encodedSemi}programName=${encodedProgram}${encodedSemi}programID=${encodeURIComponent(programID)}`; const deliverables = await executeQuery(deliverableQueryString); const p0TargetMarketArea = programData.data.programList.items[0].p0TargetMarketArea; diff --git a/blocks/gmo-program-list/gmo-program-list.js b/blocks/gmo-program-list/gmo-program-list.js index b86c039..76265c2 100644 --- a/blocks/gmo-program-list/gmo-program-list.js +++ b/blocks/gmo-program-list/gmo-program-list.js @@ -152,7 +152,7 @@ async function buildCampaignList(campaigns, numPerPage) { const campaignRow = document.createElement('div'); const programName = campaign.node.programName; const campaignName = campaign.node.campaignName; - const programRef = campaign.node.programReferenceNumber; + const programID = campaign.node.programID ? campaign.node.programID : ""; campaignRow.classList.add('campaign-row'); if ((index + 1) > numPerPage) campaignRow.classList.add('hidden'); @@ -161,15 +161,15 @@ async function buildCampaignList(campaigns, numPerPage) { campaignInfoWrapper.classList.add('campaign-info-wrapper', 'column-1'); const campaignIconLink = document.createElement('a'); - let campaignDetailsLink = host + `/${detailsPage}?programName=${campaign.node.programName}&`; - campaignDetailsLink += `programReferenceNumber=${campaign.node.programReferenceNumber ? campaign.node.programReferenceNumber : ""}` + let campaignDetailsLink = host + `/${detailsPage}?programName=${programName}&`; + campaignDetailsLink += `programID=${programID}` campaignIconLink.href = campaignDetailsLink; const campaignIcon = document.createElement('div'); campaignIcon.classList.add('campaign-icon'); campaignIcon.dataset.programname = programName; campaignIcon.dataset.campaignname = campaignName; - campaignIcon.dataset.reference = programRef; + campaignIcon.dataset.programid = programID; addThumbnail(campaignIcon, programName, campaignName); campaignIconLink.appendChild(campaignIcon); const campaignNameWrapper = document.createElement('div'); @@ -225,9 +225,18 @@ function buildStatus(statusWrapper, campaign) { const statusStr = checkBlankString(campaign.node.status); const statusArray = statusMapping.data.jsonByPath.item.json.options; const statusMatch = statusArray.filter(item => item.value === statusStr); - const statusText = statusMatch.length > 0 ? statusMatch[0].text : statusStr; + + let statusText, statusColor; + if (statusMatch.length > 0) { + statusText = statusMatch[0].text; + statusColor = statusMatch[0]["color-code"]; + } else { + statusText = statusStr; + statusColor = "BABABA"; + } + campaignStatus.textContent = statusText; - campaignStatus.style.backgroundColor = "#" + statusMatch[0]["color-code"]; + campaignStatus.style.backgroundColor = "#" + statusColor; campaignStatus.classList.add('status'); campaignStatus.dataset.property = 'status'; statusWrapper.appendChild(campaignStatus);