diff --git a/blocks/gmo-program-details/gmo-program-details.js b/blocks/gmo-program-details/gmo-program-details.js index 55522099..ff05b20f 100644 --- a/blocks/gmo-program-details/gmo-program-details.js +++ b/blocks/gmo-program-details/gmo-program-details.js @@ -1,7 +1,7 @@ import { decorateIcons, readBlockConfig } from '../../scripts/lib-franklin.js'; import { getQueryVariable } from '../../scripts/shared.js'; import { executeQuery } from '../../scripts/graphql.js'; -import { resolveMappings, filterArray, getProductMapping, checkBlankString } from '../../scripts/shared-program.js'; +import { resolveMappings, filterArray, getProductMapping, checkBlankString, dateFormat } from '../../scripts/shared-program.js'; import { getBaseConfigPath } from '../../scripts/site-config.js'; import { searchAsset } from '../../scripts/assets.js'; @@ -376,7 +376,10 @@ async function buildTable(jsonResponse) { const deliverableList = jsonResponse.data.deliverableList.items; const programKpi = jsonResponse.data.programList?.items.primaryKpi; const rows = document.createElement('div'); - const uniqueCategories = getUniqueItems(deliverableList, 'deliverableType'); + // we want the 'null' deliverableType to be part of this set for filtering + const uniqueCatSet = new Set(); + deliverableList.forEach(object => { uniqueCatSet.add(object['deliverableType']) }) + const uniqueCategories = Array.from(uniqueCatSet); let emptyCategory = false; uniqueCategories.forEach(async (category) => { // build header row @@ -466,8 +469,8 @@ async function buildTableRow(deliverableJson, kpi, createHidden) { const status = (deliverableJson.deliverableStatusUpdate == null) ? "Not Available" : deliverableJson.deliverableStatusUpdate + "%"; const statusPct = (deliverableJson.deliverableStatusUpdate == null) ? "0%" : deliverableJson.deliverableStatusUpdate + "%"; dataRow.innerHTML = ` -
${deliverableJson.deliverableName}
-
${typeLabel}
+
${checkBlankString(deliverableJson.deliverableName)}
+
${checkBlankString(typeLabel)}
-
${checkBlankString(deliverableJson.taskCompletionDate)}
+
${dateFormat(deliverableJson.taskCompletionDate)}
${deliverableJson.previousTaskCompletionDate ? '
Revised from ' + deliverableJson.previousTaskCompletionDate + '
': ""}
${checkBlankString(deliverableJson.driver)}
diff --git a/blocks/gmo-program-list/gmo-program-list.js b/blocks/gmo-program-list/gmo-program-list.js index 76265c26..4ec0a174 100644 --- a/blocks/gmo-program-list/gmo-program-list.js +++ b/blocks/gmo-program-list/gmo-program-list.js @@ -1,7 +1,7 @@ import { readBlockConfig } from '../../scripts/lib-franklin.js'; import { decorateIcons } from '../../scripts/lib-franklin.js'; import { graphqlAllCampaignsFilter, graphqlCampaignCount, generateFilterJSON } from '../../scripts/graphql.js'; -import { getProductMapping, checkBlankString, statusMapping } from '../../scripts/shared-program.js' +import { getProductMapping, checkBlankString, statusMapping, dateFormat } from '../../scripts/shared-program.js' import { getBaseConfigPath } from '../../scripts/site-config.js'; import { searchAsset } from '../../scripts/assets.js'; @@ -485,9 +485,4 @@ function sortColumn(dir, property) { sortArray.forEach(({ row }, index) => { container.appendChild(row); }); -} - -function dateFormat(dateString) { - const formattedDate = dateString ? dateString.split('T')[0] : 'Not Available'; - return formattedDate; } \ No newline at end of file diff --git a/scripts/graphql.js b/scripts/graphql.js index 9ed80bce..0d59b62f 100644 --- a/scripts/graphql.js +++ b/scripts/graphql.js @@ -31,7 +31,7 @@ export async function graphqlQueryNameList(queryNameList) { } export async function graphqlCampaignCount(filter = {}) { - const queryName = 'getCampaignNameFilter'; + const queryName = 'getTotalPrograms'; const encodedSemiColon = encodeURIComponent(';'); const encodedFilter = encodeURIComponent(JSON.stringify(filter)); const graphqlEndpoint = `${baseApiUrl}/${projectId}/${queryName}${encodedSemiColon}filter=${encodedFilter}`; @@ -103,7 +103,7 @@ export async function graphqlAllCampaignsFilter(first,cursor,filter) { } export async function graphqlCampaignByName(campaignName) { - const queryName = 'getCampaignNames'; + const queryName = 'getCampaignNamesFilter'; const encodedCampaignName = encodeURIComponent(campaignName); const encodedSemiColon = encodeURIComponent(';'); //persisted query URLs have to be encoded together with the first semicolon diff --git a/scripts/shared-program.js b/scripts/shared-program.js index 39e8db93..e71afcf0 100644 --- a/scripts/shared-program.js +++ b/scripts/shared-program.js @@ -53,3 +53,8 @@ export function checkBlankString(string, notAvailableText = 'Not Available') { return string; } } + +export function dateFormat(dateString) { + const formattedDate = dateString ? dateString.split('T')[0] : 'Not Available'; + return formattedDate; +} \ No newline at end of file