Skip to content

Commit

Permalink
Updated logic to display the total asset count for an image
Browse files Browse the repository at this point in the history
  • Loading branch information
TyroneAEM committed Jun 27, 2024
1 parent a79a6f6 commit e42f19c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions blocks/gmo-program-details/gmo-program-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,18 @@ export default async function decorate(block) {
const programData = await programDataPromise;
const program = programData.data.programList.items[0];
const header = buildHeader(program, queryVars).outerHTML;

// Update the header with the actual data
block.querySelector('.placeholder-header').outerHTML = header;

let imageObject = null;
let totalassets = 0;
if (program) {
try {
imageObject = await searchAsset(program.programName, program.campaignName);
if (imageObject) {
insertImageIntoCampaignImg(block, imageObject);
document.getElementById('totalassets').textContent = imageObject.assetCount;
} else {
document.getElementById('totalassets').textContent = 0;
totalassets = imageObject.assetCount;
}
} catch (error) {
console.error("Failed to load campaign image:", error);
Expand Down Expand Up @@ -145,7 +144,7 @@ export default async function decorate(block) {
${buildArtifactLinks(program).outerHTML}
<div class="total-assets total-assets-tooltip">
<div class="h3">Total Approved Assets</div>
<span id="totalassets" class="description"></span>
<span id="totalassets" class="description">${totalassets}</span>
<span class="tooltiptext">To view the assets, go to the "All Asset" search page and use Program and Campaign name facet to filter the assets</span>
</div>
</div>
Expand Down

0 comments on commit e42f19c

Please sign in to comment.