Skip to content

Commit

Permalink
add programID parameter to deliverable query (#109)
Browse files Browse the repository at this point in the history
* add programID parameter to deliverable query

* quick null check for status color

* remove console log
  • Loading branch information
mdickson-adbe authored and Shivani gupta committed Oct 1, 2024
1 parent 1671390 commit c70d822
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions blocks/gmo-program-details/gmo-program-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ 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");

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;
Expand Down
21 changes: 15 additions & 6 deletions blocks/gmo-program-list/gmo-program-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c70d822

Please sign in to comment.