Skip to content

Commit

Permalink
assets.js (#132)
Browse files Browse the repository at this point in the history
Added helper function async function getUnderdevelopmentIcon() to display the underdevelopment icon.
Also display the under development icon when  programName and campaignName is null
gmo-program-details.js
When programName and campaignName is null display the under development icon
  • Loading branch information
TyroneAEM authored Jul 8, 2024
1 parent 5b61d34 commit 309fbd9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
15 changes: 13 additions & 2 deletions blocks/gmo-program-details/gmo-program-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default async function decorate(block) {
decorateIcons(block);
}
else
{
{ //programName and campaignName is null
block.innerHTML = `
<div class="back-button">
<span class="icon icon-back"></span>
Expand All @@ -64,7 +64,18 @@ export default async function decorate(block) {
${header}
<div class="no-data-msg">No data available.</div>
</div>
`
`;
try {
//programName and campaignName is null display under development icon
imageObject = await searchAsset(null, null);
if (imageObject) {
insertImageIntoCampaignImg(block, imageObject);
totalassets = imageObject.assetCount;
}
} catch (error) {
console.error("Failed to load campaign image:", error);
}

decorateIcons(block);
enableBackBtn(block, blockConfig);
return;
Expand Down
21 changes: 16 additions & 5 deletions scripts/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const getFilters = () => {
return `is_pur-expirationDate = 0 OR pur-expirationDate > ${currentEpoch}`;
};

async function getUnderdevelopmentIcon() {
const configPath = getBaseConfigPath();
const brandingConfig = await getBrandingConfig();
const underdevelopmentIconPath = `${configPath}/${brandingConfig.underdevelopmentIcon}`.replace(/\/\//g, '/');
return { imageUrl: underdevelopmentIconPath, imageAltText: 'Under Development', assetCount: 0 };
}

/**
* Search Asset for programName and campaignName parameters.
Expand All @@ -49,6 +55,13 @@ export async function searchAsset(programName, campaignName, imageWidth = 80) {

const indexName = await getSearchIndex();


if (programName==null && campaignName==null)
{
// Display Underdevelopment Icon
return await getUnderdevelopmentIcon();
}

// Initialize the facetFilters array
const facetFilters = [];
if (programName) { // Check if programName is not null
Expand Down Expand Up @@ -96,11 +109,8 @@ export async function searchAsset(programName, campaignName, imageWidth = 80) {
}
else
{
//Display Underdevelopment Icon
const configPath = getBaseConfigPath();
const brandingConfig = await getBrandingConfig();
const underdevelopmentIconPath = `${configPath}/${brandingConfig.underdevelopmentIcon}`.replace(/\/\//g, '/');
return {imageUrl : underdevelopmentIconPath, imageAltText: 'Under Development', assetCount: 0};
// Display Underdevelopment Icon
return await getUnderdevelopmentIcon();
}
}
// Handle other response codes
Expand All @@ -110,3 +120,4 @@ export async function searchAsset(programName, campaignName, imageWidth = 80) {
throw error;
}
}

0 comments on commit 309fbd9

Please sign in to comment.