diff --git a/blocks/gmo-program-list/gmo-program-list.js b/blocks/gmo-program-list/gmo-program-list.js index d1b94f1..71806d5 100644 --- a/blocks/gmo-program-list/gmo-program-list.js +++ b/blocks/gmo-program-list/gmo-program-list.js @@ -33,11 +33,13 @@ const headerConfig = [ } ] +const DEFAULT_ITEMS_PER_PAGE = 8; //Global variables used by helper functions let currentPageInfo = {}; let cursorArray = []; let currentPage = 1; -let currentNumberPerPage = 4; +let currentNumberPerPage = DEFAULT_ITEMS_PER_PAGE; + let currentGraphqlFilter = {}; //Get Campaign Count for pagination let campaignCount = await graphqlCampaignCount(); @@ -62,7 +64,7 @@ document.addEventListener('gmoCampaignListBlock', async function() { currentPageInfo = {}; cursorArray = []; currentPage = 1; - currentNumberPerPage = 4; + currentNumberPerPage = DEFAULT_ITEMS_PER_PAGE; decorate( block, currentNumberPerPage, '', false, false, currentGraphqlFilter); @@ -120,16 +122,6 @@ export default async function decorate(block, numPerPage = currentNumberPerPage, footerNext.classList.remove('active'); } decorateIcons(block); - - //Debug Global Variables - //debug_console(); -} - -function debug_console(){ - console.log('currentPageInfo',currentPageInfo); - console.log('cursorArray',cursorArray); - console.log('currentPage',currentPage); - console.log('campaignCount',campaignCount); } @@ -193,7 +185,7 @@ async function buildCampaignList(campaigns, numPerPage) { Program Name
- ${checkBlankString(campaign.node.campaignName)} + ${checkBlankString(campaign.node.campaignName,'Marketing Moment Not Available')} Marketing Moment
`; @@ -351,7 +343,6 @@ function buildListFooter(rows, rowsPerPage) { const footerPerPageDropdown = document.createElement('select'); footerPerPageDropdown.id = 'per-page'; footerPerPageDropdown.innerHTML = ` - diff --git a/scripts/graphql.js b/scripts/graphql.js index 525fdc0..72f6cea 100644 --- a/scripts/graphql.js +++ b/scripts/graphql.js @@ -216,9 +216,7 @@ export function generateFilterJSON(filterParams) { // Convert the result object to JSON const jsonResult = JSON.stringify(result,null,4); - // Logging the JSON to see the output - console.debug('Graphql filter',jsonResult); - console.debug('result', result); + return result; } diff --git a/scripts/shared-program.js b/scripts/shared-program.js index f6a2e61..39e8db9 100644 --- a/scripts/shared-program.js +++ b/scripts/shared-program.js @@ -46,9 +46,9 @@ export async function getProductMapping(product) { /* * Check for undefined/blank property and supply 'Not Available' if no data */ -export function checkBlankString(string) { - if (string == undefined || string == '' ) { - return 'Not Available'; +export function checkBlankString(string, notAvailableText = 'Not Available') { + if (string == undefined || string == '') { + return notAvailableText; } else { return string; }