From 2936818c245e5ed4e3014f2cad9ca4bbf66a59f3 Mon Sep 17 00:00:00 2001 From: Samruddhi <150183547+staware30@users.noreply.github.com> Date: Thu, 28 Mar 2024 09:01:03 -0700 Subject: [PATCH 1/7] updated hydration-utils.js (#54) MH: Added Firefly product to AA Modal 'Product' Field List --- contenthub/hydration/hydration-utils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/contenthub/hydration/hydration-utils.js b/contenthub/hydration/hydration-utils.js index bdcf6216..8f828a3d 100644 --- a/contenthub/hydration/hydration-utils.js +++ b/contenthub/hydration/hydration-utils.js @@ -145,6 +145,7 @@ export function getMetadataSchema(facetOptions){ { name: 'Digital Editions', id: 'digital-editions' }, { name: 'Dreamweaver', id: 'dreamweaver' }, { name: 'Fill Sign', id: 'fill-sign' }, + { name: 'Firefly', id: 'firefly' }, { name: 'Frame.io', id: 'frame-io' }, { name: 'Fresco', id: 'fresco' }, { name: 'Http Dynamic Streaming', id: 'http-dynamic-streaming' }, From 1ebda0f9293ae46f837c3a6a9b9df69e1bb56989 Mon Sep 17 00:00:00 2001 From: Samruddhi <150183547+staware30@users.noreply.github.com> Date: Thu, 4 Apr 2024 09:08:16 -0700 Subject: [PATCH 2/7] MH: Add 'Asset Owner' Field to Add Assets Modal (#57) * MH: Add 'Asset Owner' Field to Add Assets Modal * Update hydration-utils.js * Comment Update --- contenthub/hydration/hydration-utils.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contenthub/hydration/hydration-utils.js b/contenthub/hydration/hydration-utils.js index 8f828a3d..a4b36809 100644 --- a/contenthub/hydration/hydration-utils.js +++ b/contenthub/hydration/hydration-utils.js @@ -31,9 +31,8 @@ export function formIsComplete(metadataSchema, formValues) { if(formValues['gmo:campaignName']){ if(!formValues['gmo:programName']) return false; - if(!formValues['gmo:deliverableType']) return false; } - + if(formValues['gmo:licensedContent'] !== 'no'){ if(!formValues['gmo:usageTerms']) return false; if(formValues['gmo:licensedContent'] === 'yes-expire' && !formValues['gmo:licenseExpiryDate']) return false; @@ -255,11 +254,6 @@ export function getMetadataSchema(facetOptions){ name: 'Tutorial', }, ], - requires: [{ - property: 'gmo:campaignName', - expectedValue: '', - operator: '!==' - }] }, { mapToProperty: 'gmo:licensedContent', @@ -294,6 +288,12 @@ export function getMetadataSchema(facetOptions){ { property: 'gmo:licensedContent', expectedValue: '', operator: '!==' } ], }, + { + mapToProperty: 'gmo:owner', + label:'Campaign/Asset Owner', + element: 'textarea', + required: true, + }, { mapToProperty: 'gmo:contentType', label: 'Content Type', From 6e7e550d8e0dc4fb334e78f7c141eef1d35c3fc1 Mon Sep 17 00:00:00 2001 From: Samruddhi <150183547+staware30@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:45:43 -0700 Subject: [PATCH 3/7] Update hydration-utils.js (#63) * Update hydration-utils.js * changed Target Market to multi-select --- contenthub/hydration/hydration-utils.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/contenthub/hydration/hydration-utils.js b/contenthub/hydration/hydration-utils.js index a4b36809..e6237d12 100644 --- a/contenthub/hydration/hydration-utils.js +++ b/contenthub/hydration/hydration-utils.js @@ -194,14 +194,14 @@ export function getMetadataSchema(facetOptions){ { mapToProperty: 'gmo:campaignName', label: 'Campaign', - placeholder: 'Select campaign', + placeholder: 'Select one', element: 'dropdown', dropdownOptions: [{id: '', name: 'N/A'}, ...facetOptions['gmo-campaignName']], }, { mapToProperty: 'gmo:programName', label: 'Program', - placeholder: 'Select program name', + placeholder: 'Select one', element: 'dropdown', dropdownOptions: facetOptions['gmo-programName'], required: true, @@ -214,6 +214,7 @@ export function getMetadataSchema(facetOptions){ { mapToProperty: 'gmo:deliverableType', label: 'Select deliverable type', + placeholder: 'Select one', element: 'dropdown', required: true, dropdownOptions: [ @@ -344,7 +345,7 @@ export function getMetadataSchema(facetOptions){ { mapToProperty: 'gmo:ddomStage', label: 'DDOM Stage', - placeholder: 'Select multiple', + placeholder: 'Select one or more', element: 'tags', dropdownOptions: [ { @@ -372,8 +373,8 @@ export function getMetadataSchema(facetOptions){ { mapToProperty: 'gmo:p0TargetMarketGeo', label: 'Target Market', - placeholder: 'Select One', - element: 'dropdown', + placeholder: 'Select one or more', + element: 'tags', dropdownOptions: [ { id: 'apac', From 9f58975b74786cc416d166e22a6c39e44933c3a9 Mon Sep 17 00:00:00 2001 From: mathieu-lessard Date: Thu, 18 Apr 2024 09:11:06 -0700 Subject: [PATCH 4/7] Added custom values for campaign and program (#67) * Changed Campaign and Program to ComboBox * Corrected Campaign Prompt * Matched values to Workfront * Fixed validation for new values * Corrected validation now that select fields are comboboxes --------- Co-authored-by: Mathieu Lessard --- contenthub/hydration/hydration-utils.js | 32 ++++++++++++++++++------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/contenthub/hydration/hydration-utils.js b/contenthub/hydration/hydration-utils.js index e6237d12..61471d8c 100644 --- a/contenthub/hydration/hydration-utils.js +++ b/contenthub/hydration/hydration-utils.js @@ -24,7 +24,7 @@ export function formIsComplete(metadataSchema, formValues) { const incomplete = metadataSchema.find((schema) => { if(!schema.required) return; if(schema.requires) return; - return Array.isArray(formValues[schema.mapToProperty]) ? formValues[schema.mapToProperty].length === 0 : formValues[schema.mapToProperty] === ''; + return !(schema.mapToProperty in formValues) || Array.isArray(formValues[schema.mapToProperty]) ? formValues[schema.mapToProperty].length === 0 : formValues[schema.mapToProperty] === ''; }); if(incomplete) return false; @@ -35,7 +35,7 @@ export function formIsComplete(metadataSchema, formValues) { if(formValues['gmo:licensedContent'] !== 'no'){ if(!formValues['gmo:usageTerms']) return false; - if(formValues['gmo:licensedContent'] === 'yes-expire' && !formValues['gmo:licenseExpiryDate']) return false; + if(formValues['gmo:licensedContent'] === 'yes-expires' && !formValues['gmo:licenseExpiryDate']) return false; } return true; }; @@ -46,7 +46,7 @@ export const licenseDateFieldShow = { placeholder: 'Select date', required: true, element: 'datepicker', - requires: [{ property: 'gmo:licensedContent', expectedValue: 'yes-expire' }], + requires: [{ property: 'gmo:licensedContent', expectedValue: 'yes-expires' }], }; const licenseExpirePerpitytity = new Date(); @@ -195,15 +195,29 @@ export function getMetadataSchema(facetOptions){ mapToProperty: 'gmo:campaignName', label: 'Campaign', placeholder: 'Select one', - element: 'dropdown', - dropdownOptions: [{id: '', name: 'N/A'}, ...facetOptions['gmo-campaignName']], + element: 'text', + getSuggestions: async (value) => { + return facetOptions['gmo-campaignName'].filter( + (option) => { + const name = option.name.toLowerCase(); + return value.toLowerCase().split(' ').every((val) => name.includes(val)); + } + ) + }, }, { mapToProperty: 'gmo:programName', label: 'Program', placeholder: 'Select one', - element: 'dropdown', - dropdownOptions: facetOptions['gmo-programName'], + element: 'text', + getSuggestions: async (value) => { + return facetOptions['gmo-programName'].filter( + (option) => { + const name = option.name.toLowerCase(); + return value.toLowerCase().split(' ').every((val) => name.includes(val)); + } + ) + }, required: true, requires: [{ property: 'gmo:campaignName', @@ -268,11 +282,11 @@ export function getMetadataSchema(facetOptions){ name: 'No', }, { - id: 'yes-expire', + id: 'yes-expires', name: 'Yes (Expires)', }, { - id: 'yes-perpetuity', + id: 'yes-in-perpetuity', name: 'Yes (in Perpetuity)', }, ], From 4b2aa395e4dfe8ee4e7230a2592d54f9b02d2b5d Mon Sep 17 00:00:00 2001 From: mdickson-adbe <95774602+mdickson-adbe@users.noreply.github.com> Date: Thu, 9 May 2024 11:28:00 -0400 Subject: [PATCH 5/7] Assets 98993 (#75) * many updates * finish dynamic properties - all properties should be dynamic based on graphql data - refactored some common lookups to a shared javascript file - updated overflow for overview/description - made status, products more presentable - more elegant handling of empty audience and kpi lists * test rename svg to resolve issue * finish updating icon names and mapping * resolve pr comments --- .../gmo-campaign-details.css | 18 ++ .../gmo-campaign-details.js | 160 +++++++++++++----- .../gmo-campaign-list/gmo-campaign-list.css | 3 + blocks/gmo-campaign-list/gmo-campaign-list.js | 46 +++-- icons/{Acrobat.svg => acro-icon.svg} | 0 icons/{Express.svg => express-icon.svg} | 0 icons/{Lightroom.svg => lr-icon.svg} | 0 icons/{Photoshop.svg => ps-icon.svg} | 0 scripts/graphql.js | 29 ++++ scripts/shared-campaigns.js | 37 ++++ 10 files changed, 239 insertions(+), 54 deletions(-) rename icons/{Acrobat.svg => acro-icon.svg} (100%) rename icons/{Express.svg => express-icon.svg} (100%) rename icons/{Lightroom.svg => lr-icon.svg} (100%) rename icons/{Photoshop.svg => ps-icon.svg} (100%) create mode 100644 scripts/shared-campaigns.js diff --git a/blocks/gmo-campaign-details/gmo-campaign-details.css b/blocks/gmo-campaign-details/gmo-campaign-details.css index d0bae026..bc4a3596 100644 --- a/blocks/gmo-campaign-details/gmo-campaign-details.css +++ b/blocks/gmo-campaign-details/gmo-campaign-details.css @@ -12,6 +12,7 @@ body { align-items: center; border: 1px solid #D3D3D3; border-radius: 4px; + cursor: pointer; & > .icon { width: 20px; height: 30px; @@ -54,6 +55,9 @@ body { width: 17px; } } + & > .campaign-img { + background-color: #e1e1e1; + } & .header-row1 { display: flex; align-items: center; @@ -127,11 +131,18 @@ body { font: normal normal normal 14px/21px Adobe Clean; letter-spacing: 0px; color: black; + &.hide-overflow { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 3; + overflow: hidden; + } } & .button.no-bg { font: normal normal normal 14px/17px Adobe Clean; margin-top: 10px; color: #505050; + cursor: pointer; } } .kpis-wrapper { @@ -142,6 +153,10 @@ body { -moz-columns: 2; font: normal normal normal 14px/21px Adobe Clean; } + & div { + font-size: 14px; + margin-top: 15px; + } } .use-cases-wrapper { margin-bottom: 30px; @@ -209,6 +224,9 @@ body { padding-left: 15px; } } + &.audiences > div { + font-size: 14px; + } } .milestone, .card-content { font: normal normal normal 14px/21px Adobe Clean; diff --git a/blocks/gmo-campaign-details/gmo-campaign-details.js b/blocks/gmo-campaign-details/gmo-campaign-details.js index 03babcda..760dc344 100644 --- a/blocks/gmo-campaign-details/gmo-campaign-details.js +++ b/blocks/gmo-campaign-details/gmo-campaign-details.js @@ -1,4 +1,9 @@ import { decorateIcons } from '../../scripts/lib-franklin.js'; +import { getQueryVariable } from '../../scripts/shared.js'; +import { getProgramDetails } from '../../scripts/graphql.js'; +import { checkBlankString } from '../gmo-campaign-list/gmo-campaign-list.js' +import { statusMappings, productMappings } from '../../scripts/shared-campaigns.js'; +import { getBaseConfigPath } from '../../scripts/site-config.js'; const testData = [ { @@ -423,7 +428,16 @@ import { decorateIcons } from '../../scripts/lib-franklin.js'; export default async function decorate(block) { //const rows = buildTable(testData); + // /graphql/execute.json/gmo/getProgramDetails;programName= + const programName = getQueryVariable('programName'); + const graphqlData = await getProgramDetails(programName); + const program = graphqlData.data.programList.items[0]; const rows = buildTableNoGroups(testData); + const kpis = buildKPIList(program).outerHTML; + const products = buildProductList(program).outerHTML; + const audiences = buildAudienceList(program).outerHTML; + const date = formatDate(program.launchDate); + const status = buildStatus(program.status).outerHTML; block.innerHTML = `
@@ -435,12 +449,12 @@ export default async function decorate(block) {
- Express Mobile Beta -
In Progress
+ ${program.programName} + ${status}
- 03/07/2024 + ${date}
@@ -453,20 +467,11 @@ export default async function decorate(block) {
At a Glance Product Value - - Express mobile public beta is not a major at scale marketing moment (due to the limited nature of beta experience) with key audiences of - Existing Express users, investors and media. Marketing approach is signaling to the market our continued momentum with the new mobile - beta release, focusing efforts on PR, social/community and in-app surfaces. - -
Read more
+
${checkBlankString(program.productValue.plaintext)}
+
Read more
KPIs to Measure Success -
    -
  • PR impressions & dedicated earned stories
  • -
  • Mobile exports
  • -
  • Community & social interactions
  • -
  • 100% by EOL
  • -
+ ${kpis}
Hero Use Cases @@ -519,10 +524,7 @@ export default async function decorate(block) {
Products
-
- - Adobe Express Mobile App -
+ ${products}
Feature Scope
@@ -534,26 +536,7 @@ export default async function decorate(block) {
Audiences
-
- - Existing Express Users -
-
- - Prospects with priority on communicators -
-
- - CC entitled members who have not used Express -
-
- - CC free unentitled members on mobile (PsX, LR) -
-
- - K12 -
+ ${audiences}
@@ -597,6 +580,13 @@ export default async function decorate(block) { block.querySelector('.tab-wrapper').addEventListener('click', (event) => { switchTab(event.target); }) + block.querySelector('.back-button').addEventListener('click', () => { + const host = location.origin + getBaseConfigPath(); + document.location.href = host + `/campaigns`; + }) + block.querySelector('.read-more').addEventListener('click', () => { + document.querySelector('.overview-wrapper > .description').classList.toggle('hide-overflow'); + }) decorateIcons(block); } @@ -612,6 +602,98 @@ function switchTab(tab) { tab.classList.toggle('active'); } +function buildKPIList(program) { + let kpiList = document.createElement('ul'); + program.primaryKpi?.forEach((kpi) => { + const kpiLi = createKPI(kpi); + kpiList.appendChild(kpiLi); + }) + program.additionalKpi?.forEach((kpi) => { + const kpiLi = createKPI(kpi); + kpiList.appendChild(kpiLi); + }) + if (kpiList.children.length == 0) { + kpiList.remove(); + kpiList = document.createElement('div'); + kpiList.textContent = "Not Available"; + } + return kpiList; +} + +function createKPI(kpi) { + const kpiLi = document.createElement('li'); + const kpiText = parseString(kpi); + kpiLi.textContent = kpiText; + return kpiLi; +} + +function buildProductList(program) { + const product = checkBlankString(program.productOffering); + const productList = document.createElement('div'); + productList.classList.add('product', 'card-content'); + const productName = productMappings[product].name; + const productLabel = productMappings[product].icon; + productList.innerHTML = ` + + ${productName} + ` + return productList; +} + +function buildAudienceList(program) { + const audienceList = document.createElement('div'); + program.primaryAudience?.forEach((audience) => { + const audienceDiv = createAudience(audience); + audienceList.appendChild(audienceDiv); + }) + program.additionalAudiences?.forEach((audience) => { + const audienceDiv = createAudience(audience); + audienceList.appendChild(audienceDiv); + }) + if (audienceList.children.length == 0) audienceList.textContent = "Not Available"; + return audienceList; +} + +function buildStatus(status) { + const statusDiv = document.createElement('div'); + statusDiv.classList.add('campaign-status'); + const statusLabel = statusMappings[status].label; + const statusColor = statusMappings[status].color; + statusDiv.textContent = statusLabel; + statusDiv.classList.add(statusColor); + return statusDiv; +} + +function createAudience(audience) { + const text = parseString(audience); + const audienceDiv = document.createElement('div'); + audienceDiv.classList.add('audience', 'card-content'); + audienceDiv.innerHTML = ` + + ${text} + `; + return audienceDiv; +} + +function parseString(text) { + let parsed = text.replace(/-/g, ' ').split(' '); + parsed[0] = parsed[0].charAt(0).toUpperCase() + parsed[0].slice(1); + parsed = parsed.join(' '); + return parsed; +} + +function formatDate(dateString) { + const parts = dateString.split('-'); + const yyyy = parts[0]; + const mm = parts[1]; + const dd = parts[2]; + + // Formatting the date into mm/dd/yyyy format + const formattedDate = mm + '/' + dd + '/' + yyyy; + + return formattedDate; +} + function buildTable(data) { const rows = document.createElement('div'); const uniqueCategories = getUniqueValues(data, 'category'); diff --git a/blocks/gmo-campaign-list/gmo-campaign-list.css b/blocks/gmo-campaign-list/gmo-campaign-list.css index a636f0b9..08bd5ad6 100644 --- a/blocks/gmo-campaign-list/gmo-campaign-list.css +++ b/blocks/gmo-campaign-list/gmo-campaign-list.css @@ -89,6 +89,9 @@ body { } .campaign-description { line-height:20px; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 4; overflow: hidden; text-overflow: ellipsis; } diff --git a/blocks/gmo-campaign-list/gmo-campaign-list.js b/blocks/gmo-campaign-list/gmo-campaign-list.js index 6894173c..c66257df 100644 --- a/blocks/gmo-campaign-list/gmo-campaign-list.js +++ b/blocks/gmo-campaign-list/gmo-campaign-list.js @@ -1,6 +1,8 @@ import { readBlockConfig } from '../../scripts/lib-franklin.js'; import { decorateIcons } from '../../scripts/lib-franklin.js'; import { graphqlAllCampaignsFilter, graphqlCampaignCount, generateFilterJSON } from '../../scripts/graphql.js'; +import { productMappings, statusMappings } from '../../scripts/shared-campaigns.js' +import { getBaseConfigPath } from '../../scripts/site-config.js'; const headerConfig = [ { @@ -102,17 +104,13 @@ export default async function decorate(block, numPerPage = currentNumberPerPage, const footerPrev = document.querySelector('.footer-pagination-button.prev'); if (currentPageInfo.hasPreviousPage){ footerPrev.classList.add('active'); - } - else - { + } else { footerPrev.classList.remove('active'); } if (currentPageInfo.hasNextPage){ footerNext.classList.add('active'); - } - else - { + } else { footerNext.classList.remove('active'); } decorateIcons(block); @@ -138,22 +136,29 @@ function buildCampaignList(campaigns, numPerPage) { const listWrapper = document.createElement('div'); listWrapper.classList.add('list-items'); listWrapper.dataset.totalresults = campaigns.length; - + const host = location.origin + getBaseConfigPath(); + campaigns.forEach((campaign, index) => { const campaignRow = document.createElement('div'); campaignRow.classList.add('campaign-row'); if ((index + 1) > numPerPage) campaignRow.classList.add('hidden'); const campaignInfoWrapper = document.createElement('div'); campaignInfoWrapper.classList.add('campaign-info-wrapper','column-1'); + const campaignIconLink = document.createElement('a'); + campaignIconLink.href = host + `/campaign-details?programName=${campaign.node.programName}` + const campaignIcon = document.createElement('div'); campaignIcon.classList.add('campaign-icon'); + campaignIcon.dataset.programname = campaign.node.programName; + campaignIcon.dataset.campaignname = campaign.node.campaignName; + campaignIconLink.appendChild(campaignIcon); const campaignName = document.createElement('div'); campaignName.classList.add('campaign-name-wrapper', 'vertical-center'); campaignName.innerHTML = `
${checkBlankString(campaign.node.campaignName)}
${checkBlankString(campaign.node.programName)}
` - campaignInfoWrapper.appendChild(campaignIcon); + campaignInfoWrapper.appendChild(campaignIconLink); campaignInfoWrapper.appendChild(campaignName); const campaignOverviewWrapper = document.createElement('div'); campaignOverviewWrapper.classList.add('column-2', 'campaign-description-wrapper','vertical-center'); @@ -171,9 +176,10 @@ function buildCampaignList(campaigns, numPerPage) { const campaignStatusWrapper = document.createElement('div'); campaignStatusWrapper.classList.add('status-wrapper', 'column-6','vertical-center'); const campaignStatus = document.createElement('div'); - const statusString = checkBlankString(campaign.node.status); + const statusStr = checkBlankString(campaign.node.status); + const statusString = statusMappings[statusStr].label; campaignStatus.textContent = statusString; - campaignStatus.classList.add(determineStatusColor(statusString)); + campaignStatus.classList.add(statusMappings[statusStr].color); campaignStatus.classList.add('status'); campaignStatus.dataset.property = 'status'; campaignStatusWrapper.appendChild(campaignStatus); @@ -197,13 +203,16 @@ function buildProductsList(productList) { function buildProduct(product) { const productEl = document.createElement('div'); - let productIcon = product; - if (product == null) product = 'None'; - if (product == 'Not Available') productIcon = "gear"; + //let productIcon = product; + if (product == null) product = 'Not Available'; + //if (product == 'Not Available') productIcon = "gear"; + const productLabel = productMappings[product].name; + const productIcon = productMappings[product].icon; + productEl.classList.add('product-entry'); productEl.innerHTML = ` - ${product} + ${productLabel} ` return productEl; } @@ -431,6 +440,7 @@ function sortColumn(dir, property) { }); } +/* function determineStatusColor(status) { switch(status) { case 'Current': @@ -443,12 +453,18 @@ function determineStatusColor(status) { return 'red'; } } +*/ // supply dummy data if none present -function checkBlankString(string) { +export function checkBlankString(string) { if (string == undefined || string == '' ) { return 'Not Available'; } else { return string; } } + +function openCampaignDetails(campaignName) { + document.location.href = `/campaign-details?campaignName=${campaignName}`; +} + diff --git a/icons/Acrobat.svg b/icons/acro-icon.svg similarity index 100% rename from icons/Acrobat.svg rename to icons/acro-icon.svg diff --git a/icons/Express.svg b/icons/express-icon.svg similarity index 100% rename from icons/Express.svg rename to icons/express-icon.svg diff --git a/icons/Lightroom.svg b/icons/lr-icon.svg similarity index 100% rename from icons/Lightroom.svg rename to icons/lr-icon.svg diff --git a/icons/Photoshop.svg b/icons/ps-icon.svg similarity index 100% rename from icons/Photoshop.svg rename to icons/ps-icon.svg diff --git a/scripts/graphql.js b/scripts/graphql.js index 35243c75..e39b9c3c 100644 --- a/scripts/graphql.js +++ b/scripts/graphql.js @@ -221,3 +221,32 @@ export function generateFilterJSON(filterParams) { console.debug('result', result); return result; } + +export async function getProgramDetails(programName) { + const baseApiUrl = `${await getGraphqlEndpoint()}/graphql/execute.json`; + const projectId = 'gmo'; + const queryName = 'getProgramDetails'; + const encodedProgramName = encodeURIComponent(programName); + const encodedSemiColon = encodeURIComponent(';'); + //persisted query URLs have to be encoded together with the first semicolon + const graphqlEndpoint = `${baseApiUrl}/${projectId}/${queryName}${encodedSemiColon}programName=${encodedProgramName}`; + const jwtToken = await getBearerToken(); + + // Return the fetch promise chain so that it can be awaited outside + return fetch(graphqlEndpoint, { + method: 'GET', + headers: { + Authorization: jwtToken, + }, + }).then(response => { + if (!response.ok) { + throw new Error(`HTTP error! Status: ${response.status}`); + } + return response.json(); + }).then(data => { + return data; // Make sure to return the data so that the promise resolves with it + }).catch(error => { + console.error('Error fetching data: ', error); + throw error; // Rethrow or handle error as appropriate + }); +} diff --git a/scripts/shared-campaigns.js b/scripts/shared-campaigns.js new file mode 100644 index 00000000..51993236 --- /dev/null +++ b/scripts/shared-campaigns.js @@ -0,0 +1,37 @@ +export const statusMappings = { + "PLN": { + "label": "Planning", + "color": "green" + }, + "CUR": { + "label": "Current", + "color": "green" + }, + "CPL": { + "label": "Complete", + "color": "green" + } +} + +export const productMappings = { + "acrobat-pro": { + "name": "Acrobat Pro", + "icon": "acro-icon" + }, + "lightroom": { + "name": "Lightroom", + "icon": "lr-icon", + }, + "adobe-express": { + "name": "Adobe Express", + "icon": "express-icon" + }, + "photoshop": { + "name": "Photoshop", + "icon": "ps-icon" + }, + "Not Available": { + "name": "Not Available", + "icon": "gear" + } +} \ No newline at end of file From d564007844ba098c8fe3fb61472e54bc3ac5571d Mon Sep 17 00:00:00 2001 From: mathieu-lessard Date: Thu, 9 May 2024 09:24:36 -0700 Subject: [PATCH 6/7] Release 05.09.2024 (#78) * Added mapping for uuid (#74) Co-authored-by: Mathieu Lessard * Removed Prefix from Displayed UUID Value on Assets (#76) --------- Co-authored-by: Mathieu Lessard Co-authored-by: Christopher Heintzman --- scripts/metadata-html-builder.js | 6 ++++++ scripts/metadata.js | 1 + 2 files changed, 7 insertions(+) diff --git a/scripts/metadata-html-builder.js b/scripts/metadata-html-builder.js index 8ae18086..92da6528 100644 --- a/scripts/metadata-html-builder.js +++ b/scripts/metadata-html-builder.js @@ -139,6 +139,12 @@ export async function fetchMetadataAndCreateHTML(metadataViewConfig, assetData, if (assetData === undefined || assetJSON === undefined) { assetJSON = await getAssetMetadata(getAssetIdFromURL()); } + // Remove "urn:aaid:aem:" prefix from displayed 'assetId' value + if (assetJSON.assetId) { + // A deep copy of the assetJSON object is created to avoid modifying the original object + assetJSON = JSON.parse(JSON.stringify(assetJSON)); + assetJSON.assetId = assetJSON.assetId.replace('urn:aaid:aem:', ''); + } const metadataContainer = document.createElement('div'); metadataContainer.classList.add('metadata-container'); diff --git a/scripts/metadata.js b/scripts/metadata.js index f9368c5a..ccc53b8b 100644 --- a/scripts/metadata.js +++ b/scripts/metadata.js @@ -12,6 +12,7 @@ import { fetchCached } from './fetch-util.js'; import { getBaseConfigPath, getMetadataConfigs } from './site-config.js'; const SEARCH_FIELD_TO_POLARIS_API_MAP = { + uuid: 'assetId', 'dc-format': 'repositoryMetadata.dc:format', 'repo-name': 'repositoryMetadata.repo:name', 'repo-createDate': 'repositoryMetadata.repo:createDate', From 664b9f5a67e294784a03ab913bd5b6b73dfa4b78 Mon Sep 17 00:00:00 2001 From: TyroneAEM <147942284+TyroneAEM@users.noreply.github.com> Date: Thu, 9 May 2024 11:31:30 -0500 Subject: [PATCH 7/7] ASSETS-88902 : Add Target Geo Filter in the Landing Page (update all dropdown lists to use updated graphql queries) (#77) * Add hardcoded Geo(graphy) dropdown list filter to Campaign Header * Fixed Previous Page pagination logic for calculating the cursor for the Previous page * Updated Products and Status Dropdown Lists code to use updated graphql persisted queries --- .../gmo-campaign-header.js | 91 ++++++++++--------- blocks/gmo-campaign-list/gmo-campaign-list.js | 16 +++- 2 files changed, 60 insertions(+), 47 deletions(-) diff --git a/blocks/gmo-campaign-header/gmo-campaign-header.js b/blocks/gmo-campaign-header/gmo-campaign-header.js index d287d3fc..7a7a231e 100644 --- a/blocks/gmo-campaign-header/gmo-campaign-header.js +++ b/blocks/gmo-campaign-header/gmo-campaign-header.js @@ -58,7 +58,27 @@ export default async function decorate(block) { + +
+
Geography
+
+ + +
+
+ +
@@ -122,53 +142,13 @@ export default async function decorate(block) { //Status List const statusResponse = await graphqlQueryNameList('getStatusList'); - const statuses = statusResponse.data.programList.items; - - // Extract unique statuses - const uniqueStatuses = Array.from(new Set(statuses.map(item => item.status))); - let dropdownContent = document.getElementById('dropdownStatusOptions'); - // Clear existing options - dropdownContent.innerHTML = ''; - // Append new options - uniqueStatuses.forEach((status, index) => { - // Create a new anchor element for each status - var anchor = document.createElement('a'); - anchor.href = "#"; - anchor.id = "option" + (index + 1); // increment index for 1-based id - //anchor.dataset.value = "option" + (index + 1); - anchor.dataset.value = status; - anchor.dataset.type = "status"; - anchor.className = "dropoption"; - anchor.textContent = status; // using the status as the text - // Append to the dropdown - dropdownContent.appendChild(anchor); - }); + const statuses = statusResponse.data.jsonByPath.item.json.options; + populateDropdown(statuses, 'dropdownStatusOptions', 'status'); //Product List const productResponse = await graphqlQueryNameList('getProductList'); - const products = productResponse.data.programList.items; - - // Extract unique statuses - const uniqueProducts = Array.from(new Set(products.map(item => item.productOffering))); - let dropdownProductContent = document.getElementById('dropdownProductOptions'); - // Clear existing options - dropdownProductContent.innerHTML = ''; - // Append new options - uniqueProducts.forEach((product, index) => { - // Create a new anchor element for each status - var anchor = document.createElement('a'); - anchor.href = "#"; - anchor.id = "option" + (index + 1); // increment index for 1-based id - //anchor.dataset.value = "option" + (index + 1); - anchor.dataset.value = product; - anchor.dataset.type = "productOffering";//field in graphQL - anchor.className = "dropoption"; - anchor.textContent = product; // using the status as the text - // Append to the dropdown - dropdownProductContent.appendChild(anchor); - }); - - //End product dropdown + const products = productResponse.data.jsonByPath.item.json.options; + populateDropdown(products, 'dropdownProductOptions', 'productOffering'); document.querySelectorAll('.dropdown-button').forEach((button) => { button.addEventListener('click', (event) => { @@ -188,6 +168,29 @@ export default async function decorate(block) { decorateIcons(block); } +function populateDropdown(options, dropdownId, type) { + let dropdownContent = document.getElementById(dropdownId); + // Clear existing options + dropdownContent.innerHTML = ''; + + // Append new options + options.forEach((option, index) => { + // Create a new anchor element for each option + var anchor = document.createElement('a'); + anchor.href = "#"; + anchor.id = "option" + (index + 1); // increment index for 1-based id + anchor.dataset.value = option.value; + anchor.dataset.type = type; + anchor.className = "dropoption"; + anchor.textContent = option.text; // using the option text + // Append to the dropdown + dropdownContent.appendChild(anchor); + }); +} + + + + function toggleDropdown(element) { const dropdown = element.closest('.filter-dropdown'); const icons = dropdown.querySelectorAll('.icon'); diff --git a/blocks/gmo-campaign-list/gmo-campaign-list.js b/blocks/gmo-campaign-list/gmo-campaign-list.js index c66257df..8a424159 100644 --- a/blocks/gmo-campaign-list/gmo-campaign-list.js +++ b/blocks/gmo-campaign-list/gmo-campaign-list.js @@ -114,8 +114,18 @@ 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); + +} function getFilterValues(){ // Select all elements with the class 'selected-filter' @@ -379,10 +389,10 @@ function prevPage(prevBtn) { if (currentPageInfo.hasPreviousPage) { currentPage--; const block = document.querySelector('.gmo-campaign-list.block'); - const currentCursor = currentPageInfo.nextCursor || currentPageInfo.currentCursor; - //Calculate cursor for previous page - const indexCursor = cursorArray.indexOf(currentCursor) - currentPageInfo.itemCount - currentNumberPerPage; + const currentCursor = currentPageInfo.currentCursor; + //Calculate cursor for previous page + const indexCursor = cursorArray.indexOf(currentCursor) - currentNumberPerPage; decorate(block, currentNumberPerPage, cursorArray[indexCursor], true, false); if (!(prevBtn.classList.contains('active'))) { return;