Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add programID parameter to deliverable query #109

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading