Skip to content

Commit

Permalink
Sticky deliverables header, update graphql endpoints (#102)
Browse files Browse the repository at this point in the history
* platforms mapping with graphql

- also cleaned up extraneous/defunct code

* refactor chevrons for column sort

* add title attribs

* remove kpi column

* rename blocks

* cleaning up redundant code

* continuing cleanup

* fix pagination bug

* fix css bug in audience card

* cleanup, readd missing row

- remove commented code
- remove commented html
- readd campaign name to overview tab if available

* resolve undone null check for product label

* handle bad response from product icon map

* update query endpoints, css tweak on deliverables
  • Loading branch information
mdickson-adbe authored May 31, 2024
1 parent af034d3 commit 3b438d2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
10 changes: 10 additions & 0 deletions blocks/gmo-program-details/gmo-program-details.css
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,16 @@ body {
color: #505050;
display: flex;
align-items: center;
position: sticky;
position: -webkit-sticky;
top: 0;
}
}
.table-content {
height: 45vh;
overflow-y: auto;
&::-webkit-scrollbar {
display: none;
}
}
.inactive {
Expand Down
11 changes: 8 additions & 3 deletions blocks/gmo-program-details/gmo-program-details.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { decorateIcons, readBlockConfig } from '../../scripts/lib-franklin.js';
import { getQueryVariable } from '../../scripts/shared.js';
import { getProgramInfo } from '../../scripts/graphql.js';
import { executeQuery } from '../../scripts/graphql.js';
import { resolveMappings, filterArray, getProductMapping, checkBlankString } from '../../scripts/shared-program.js';
import { getBaseConfigPath } from '../../scripts/site-config.js';
import { searchAsset } from '../../scripts/assets.js';

let blockConfig;
const programName = getQueryVariable('programName');
const programRefNumber = getQueryVariable('programReferenceNumber');
const deliverableMappings = resolveMappings("getDeliverableTypeMapping");
const platformMappings = resolveMappings("getPlatformsMapping");

export default async function decorate(block) {

const programData = await getProgramInfo(programName, "getProgramDetails");
const deliverables = getProgramInfo(programName, "getProgramDeliverables");
const encodedSemi = encodeURIComponent(';');
const encodedProgram = encodeURIComponent(programName);
const programQueryString = `getProgramDetails${encodedSemi}programName=${encodedProgram}${encodedSemi}programReferenceNumber=${encodeURIComponent(programRefNumber)}`;
const programData = await executeQuery(programQueryString);
const deliverableQueryString = `getProgramDeliverables${encodedSemi}programName=${encodedProgram}`;
const deliverables = await executeQuery(deliverableQueryString);

const p0TargetMarketArea = programData.data.programList.items[0].p0TargetMarketArea;
const p1TargetMarketArea = programData.data.programList.items[0].p1TargetMarketArea;
Expand Down
4 changes: 3 additions & 1 deletion blocks/gmo-program-list/gmo-program-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ async function buildCampaignList(campaigns, numPerPage) {
campaignInfoWrapper.classList.add('campaign-info-wrapper', 'column-1');

const campaignIconLink = document.createElement('a');
campaignIconLink.href = host + `/${detailsPage}?programName=${campaign.node.programName}`;
let campaignDetailsLink = host + `/${detailsPage}?programName=${campaign.node.programName}&`;
campaignDetailsLink += `programReferenceNumber=${campaign.node.programReferenceNumber ? campaign.node.programReferenceNumber : ""}`
campaignIconLink.href = campaignDetailsLink;

const campaignIcon = document.createElement('div');
campaignIcon.classList.add('campaign-icon');
Expand Down
23 changes: 9 additions & 14 deletions scripts/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,18 @@ export function generateFilterJSON(filterParams) {
return result;
}

// add additional query types as needed
export async function getProgramInfo(programName, queryType) {
// general function for executing graphql queries
export async function executeQuery(queryString) {
const baseApiUrl = `${await getGraphqlEndpoint()}/graphql/execute.json`;
const projectId = 'gmo';
//const queryName = (queryType == "deliverables") ? "getProgramDeliverables" : "getProgramDetails";
const encodedProgramName = encodeURIComponent(programName);
const encodedSemiColon = encodeURIComponent(';');
//persisted query URLs have to be encoded together with the first semicolon
const graphqlEndpoint = `${baseApiUrl}/${projectId}/${queryType}${encodedSemiColon}programName=${encodedProgramName}`;
const queryEndpoint = `${baseApiUrl}/${projectId}/${queryString}`;
const jwtToken = await getBearerToken();

// Return the fetch promise chain so that it can be awaited outside
return fetch(graphqlEndpoint, {
method: 'GET',
headers: {
Authorization: jwtToken,
},
return fetch(queryEndpoint, {
method: 'GET',
headers: {
Authorization: jwtToken,
},
}).then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
Expand All @@ -250,4 +245,4 @@ export async function getProgramInfo(programName, queryType) {
console.error('Error fetching data: ', error);
throw error; // Rethrow or handle error as appropriate
});
}
};

0 comments on commit 3b438d2

Please sign in to comment.