Skip to content

Commit

Permalink
Merge pull request #175 from adobecom/stage
Browse files Browse the repository at this point in the history
Stage to Main sync up | Aug 15
  • Loading branch information
apganapa-adobe authored Aug 15, 2024
2 parents d0f7db6 + dc6e7b2 commit a0eeb7c
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 57 deletions.
3 changes: 2 additions & 1 deletion ecc/blocks/ecc-dashboard/ecc-dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@
width: 90px;
min-width: 90px;
object-fit: cover;
border-radius: 4px;
border-radius: 6px;
background-color: var(--color-gray-400);
}

.ecc-dashboard table .event-row td {
Expand Down
33 changes: 20 additions & 13 deletions ecc/blocks/ecc-dashboard/ecc-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function cloneFilter(obj) {
'hostEmail',
'rsvpFormFields',
'relatedProducts',
'venue',
];

const output = {};
Expand Down Expand Up @@ -128,17 +129,21 @@ function buildThumbnail(data) {
const heroImage = images.find((photo) => photo.imageKind === 'event-hero-image');
const venueImage = images.find((photo) => photo.imageKind === 'venue-image');

const img = createTag('img', {
class: 'event-thumbnail-img',
src: (cardImage?.sharepointUrl && cardImage?.sharepointUrl.replace('https://www.adobe.com', getEventPageHost(data.published)))
|| cardImage?.imageUrl
|| (heroImage?.sharepointUrl && cardImage?.sharepointUrl.replace('https://www.adobe.com', getEventPageHost(data.published)))
|| heroImage?.imageUrl
|| (venueImage?.sharepointUrl && cardImage?.sharepointUrl.replace('https://www.adobe.com', getEventPageHost(data.published)))
|| venueImage?.imageUrl
|| images[0]?.imageUrl
|| '/ecc/icons/icon-placeholder.svg',
});
// TODO: remove after no more adobe.com images
const imgSrc = (cardImage?.sharepointUrl
&& `${getEventPageHost()}${cardImage?.sharepointUrl.replace('https://www.adobe.com', '')}`)
|| cardImage?.imageUrl
|| (heroImage?.sharepointUrl
&& `${getEventPageHost()}${heroImage?.sharepointUrl.replace('https://www.adobe.com', '')}`)
|| heroImage?.imageUrl
|| (venueImage?.sharepointUrl
&& `${getEventPageHost()}${venueImage?.sharepointUrl.replace('https://www.adobe.com', '')}`)
|| venueImage?.imageUrl
|| images[0]?.imageUrl;

const img = createTag('img', { class: 'event-thumbnail-img' });

if (imgSrc) img.src = imgSrc;
container.append(img);
};

Expand Down Expand Up @@ -287,19 +292,21 @@ function initMoreOptions(props, config, eventObj, row) {

if (eventObj.detailPagePath) {
previewPre.href = (() => {
const url = new URL(`${getEventPageHost(eventObj.published)}${eventObj.detailPagePath}`);
const url = new URL(`${getEventPageHost()}${eventObj.detailPagePath}`);
url.searchParams.set('previewMode', 'true');
url.searchParams.set('cachebuster', Date.now());
url.searchParams.set('timing', +eventObj.localEndTimeMillis - 10);
return url.toString();
})();
previewPre.target = '_blank';
previewPost.href = (() => {
const url = new URL(`${getEventPageHost(eventObj.published)}${eventObj.detailPagePath}`);
const url = new URL(`${getEventPageHost()}${eventObj.detailPagePath}`);
url.searchParams.set('previewMode', 'true');
url.searchParams.set('cachebuster', Date.now());
url.searchParams.set('timing', +eventObj.localEndTimeMillis + 10);
return url.toString();
})();
previewPost.target = '_blank';
} else {
previewPre.classList.add('disabled');
previewPost.classList.add('disabled');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export function onSubmit(component, props) {
if (checkbox.checked) {
const communityTopicUrl = component.querySelector('#community-url-details').value;
props.payload = { ...props.payload, communityTopicUrl };
} else {
const tempPayload = { ...props.payload };
delete tempPayload.communityTopicUrl;
props.payload = tempPayload;
}
}

Expand All @@ -28,7 +32,6 @@ export default function init(component, props) {
}

const updateInputState = () => {
input.disabled = !checkbox.checked;
input.required = checkbox.checked;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ function updateInput(component, state) {
if (dateInput.dataset.startDate && dateInput.dataset.endDate) {
const options = { year: 'numeric', month: 'long', day: 'numeric' };
const dateLocale = getConfig().locale?.ietf || 'en-US';
const startDateTime = new Date(dateInput.dataset.startDate)
const startDateTime = state.selectedStartDate
.toLocaleDateString(dateLocale, options);
const endDateTime = new Date(dateInput.dataset.endDate)
const endDateTime = state.selectedEndDate
.toLocaleDateString(dateLocale, options);
const dateValue = dateInput.dataset.startDate === dateInput.dataset.endDate
? startDateTime : `${startDateTime} - ${endDateTime}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,35 @@ export default async function init(component, props) {

const { venue, showVenuePostEvent } = eventData;

const venueNameInput = component.querySelector('#venue-info-venue-name');
const addressInput = component.querySelector('#venue-info-venue-address');
const cityInput = component.querySelector('#location-city');
const stateInput = component.querySelector('#location-state');
const stateCodeInput = component.querySelector('#location-state-code');
const postalCodeInput = component.querySelector('#location-zip-code');
const countryInput = component.querySelector('#location-country');
const placeLatInput = component.querySelector('#google-place-lat');
const placeLngInput = component.querySelector('#google-place-lng');
const placeIdInput = component.querySelector('#google-place-id');
const mapUrlInput = component.querySelector('#google-map-url');
const gmtoffsetInput = component.querySelector('#google-place-gmt-offset');

venueNameInput.addEventListener('change', () => {
if (!venueNameInput.value) {
changeInputValue(addressInput, 'value', '');
changeInputValue(cityInput, 'value', '');
changeInputValue(stateInput, 'value', '');
changeInputValue(stateCodeInput, 'value', '');
changeInputValue(postalCodeInput, 'value', '');
changeInputValue(countryInput, 'value', '');
changeInputValue(placeLatInput, 'value', '');
changeInputValue(placeLngInput, 'value', '');
changeInputValue(placeIdInput, 'value', '');
changeInputValue(mapUrlInput, 'value', '');
changeInputValue(gmtoffsetInput, 'value', '');
}
});

if (venue) {
const {
venueName,
Expand All @@ -121,17 +150,18 @@ export default async function init(component, props) {
mapUrl,
} = venue;

changeInputValue(component.querySelector('#venue-info-venue-name'), 'value', venueName);
changeInputValue(component.querySelector('#venue-info-venue-address'), 'value', address);
changeInputValue(component.querySelector('#location-city'), 'value', city);
changeInputValue(component.querySelector('#location-state'), 'value', state);
changeInputValue(component.querySelector('#location-state-code'), 'value', statecode);
changeInputValue(component.querySelector('#location-zip-code'), 'value', postalCode);
changeInputValue(component.querySelector('#location-country'), 'value', country);
changeInputValue(component.querySelector('#google-place-lat'), 'value', venue.coordinates?.lat);
changeInputValue(component.querySelector('#google-place-lng'), 'value', venue.coordinates?.lon);
changeInputValue(component.querySelector('#google-place-id'), 'value', placeId);
changeInputValue(component.querySelector('#google-map-url'), 'value', mapUrl);
changeInputValue(venueNameInput, 'value', venueName);
changeInputValue(addressInput, 'value', address);
changeInputValue(cityInput, 'value', city);
changeInputValue(stateInput, 'value', state);
changeInputValue(stateCodeInput, 'value', statecode);
changeInputValue(postalCodeInput, 'value', postalCode);
changeInputValue(countryInput, 'value', country);
changeInputValue(placeLatInput, 'value', venue.coordinates?.lat);
changeInputValue(placeLngInput, 'value', venue.coordinates?.lon);
changeInputValue(placeIdInput, 'value', placeId);
changeInputValue(mapUrlInput, 'value', mapUrl);
changeInputValue(gmtoffsetInput, 'value', venue.gmtOffset);

if (venueName) component.classList.add('prefilled');
}
Expand All @@ -141,18 +171,18 @@ export default async function init(component, props) {
}

const getVenueDataInForm = () => {
const venueName = component.querySelector('#venue-info-venue-name').value;
const address = component.querySelector('#venue-info-venue-address').value;
const city = component.querySelector('#location-city').value;
const state = component.querySelector('#location-state').value;
const stateCode = component.querySelector('#location-state-code').value;
const postalCode = component.querySelector('#location-zip-code').value;
const country = component.querySelector('#location-country').value;
const placeId = component.querySelector('#google-place-id').value;
const mapUrl = component.querySelector('#google-map-url').value;
const lat = +component.querySelector('#google-place-lat').value;
const lon = +component.querySelector('#google-place-lng').value;
const gmtOffset = +component.querySelector('#google-place-gmt-offset').value;
const venueName = venueNameInput.value;
const address = addressInput.value;
const city = cityInput.value;
const state = stateInput.value;
const stateCode = stateCodeInput.value;
const postalCode = postalCodeInput.value;
const country = countryInput.value;
const placeId = placeIdInput.value;
const mapUrl = mapUrlInput.value;
const lat = +placeLatInput.value;
const lon = +placeLngInput.value;
const gmtOffset = +gmtoffsetInput.value;

const venueData = {
venueName,
Expand Down
6 changes: 2 additions & 4 deletions ecc/blocks/form-handler/data-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export function quickFilter(obj) {

export function setPayloadCache(payload) {
if (!payload) return;
const output = quickFilter(payload);
payloadCache = { ...payloadCache, ...output };
payloadCache = quickFilter(payload);
}

export function getFilteredCachedPayload() {
Expand All @@ -62,8 +61,7 @@ export function getFilteredCachedPayload() {

export function setResponseCache(response) {
if (!response) return;
const output = quickFilter(response);
responseCache = { ...responseCache, ...output };
responseCache = quickFilter(response);
}

export function getFilteredCachedResponse() {
Expand Down
12 changes: 9 additions & 3 deletions ecc/blocks/form-handler/form-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ function decorateForm(el) {
});
}

function showSaveSuccessMessage(props) {
function showSaveSuccessMessage(props, detail = { message: 'Edits saved successfully' }) {
const toastArea = props.el.querySelector('.toast-area');
if (!toastArea) return;

Expand All @@ -377,7 +377,7 @@ function showSaveSuccessMessage(props) {
msg.remove();
});

const toast = createTag('sp-toast', { class: 'save-success-msg', open: true, variant: 'positive', timeout: 6000 }, 'Edits saved successfully', { parent: toastArea });
const toast = createTag('sp-toast', { class: 'save-success-msg', open: true, variant: 'positive', timeout: 6000 }, detail.message || 'Edits saved successfully', { parent: toastArea });
toast.addEventListener('close', () => {
toast.remove();
});
Expand Down Expand Up @@ -611,7 +611,7 @@ function updateCtas(props) {
if (a.classList.contains('preview-btns')) {
const testTime = a.classList.contains('pre-event') ? +props.eventDataResp.localEndTimeMillis - 10 : +props.eventDataResp.localEndTimeMillis + 10;
if (eventDataResp.detailPagePath) {
a.href = `${getEventPageHost(eventDataResp.published)}${eventDataResp.detailPagePath}?previewMode=true&cachebuster=${Date.now()}&timing=${testTime}`;
a.href = `${getEventPageHost()}${eventDataResp.detailPagePath}?previewMode=true&cachebuster=${Date.now()}&timing=${testTime}`;
a.classList.remove('preview-not-ready');
}
}
Expand Down Expand Up @@ -773,6 +773,12 @@ async function buildECCForm(el) {
e.preventDefault();
buildErrorMessage(proxyProps, e.detail);
});

el.addEventListener('show-success-toast', (e) => {
e.stopPropagation();
e.preventDefault();
showSaveSuccessMessage(proxyProps, e.detail);
});
}

function buildLoadingScreen(el) {
Expand Down
1 change: 0 additions & 1 deletion ecc/blocks/venue-info-component/venue-info-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export default function init(el) {
id: 'venue-info-venue-address',
quiet: true,
size: 'xl',
readonly: true,
});
break;
case 3:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getSponsors } from '../../scripts/esp-controller.js';
import { LIBS } from '../../scripts/scripts.js';
import { style } from './partner-selector-group.css.js';

Expand All @@ -21,6 +22,11 @@ export default class PartnerSelectorGroup extends LitElement {

static styles = style;

reloadSeriesSponsors = async () => {
const spResp = await getSponsors(this.seriesId);
if (spResp) this.seriesSponsors = spResp.sponsors;
};

addPartner() {
this.partners = [...this.partners, {}];
}
Expand All @@ -36,7 +42,7 @@ export default class PartnerSelectorGroup extends LitElement {
handlePartnerUpdate(updatedPartner, index) {
this.partners = this.partners
.map((partner, i) => (i === index ? updatedPartner : partner));

this.reloadSeriesSponsors();
this.requestUpdate();
}

Expand Down
1 change: 0 additions & 1 deletion ecc/components/partner-selector/partner-selector.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const style = css`
fieldset image-dropzone {
display: block;
width: 280px;
height: 164px;
}
Expand Down
1 change: 1 addition & 0 deletions ecc/components/partner-selector/partner-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default class PartnerSelector extends LitElement {

this.partner.hasUnsavedChanges = false;
this.dispatchEvent(new CustomEvent('update-partner', { detail: { partner: this.partner } }));
this.dispatchEvent(new CustomEvent('show-success-toast', { detail: { message: 'Partner saved successfully' }, bubbles: true, composed: true }));
this.buttonStatePending = false;
this.requestUpdate();
}
Expand Down
4 changes: 2 additions & 2 deletions ecc/components/product-selector/product-selector.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ fieldset {
padding: 0;
}
.rsvp-field-wrapper {
.product-field-wrapper {
display: flex;
align-items: center;
gap: 16px;
}
.rsvp-field-wrapper img.product-img {
.product-field-wrapper img.product-img {
display: block;
width: 40px;
height: 40px;
Expand Down
2 changes: 1 addition & 1 deletion ecc/components/product-selector/product-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class ProductSelector extends LitElement {
const imageSource = this.getImageSource();

return html`
<fieldset class="rsvp-field-wrapper">
<fieldset class="product-field-wrapper">
<img class="product-img" src="${imageSource}" alt="${title || nothing}">
<sp-picker class="product-select-input" label="Select a product" value=${name || nothing} @change="${this.handleSelectChange}">
${availableProducts}
Expand Down
8 changes: 4 additions & 4 deletions ecc/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export function convertTo24HourFormat(timeStr) {
return `${formattedHours}:${formattedMinutes}:00`;
}

export function getEventPageHost(published = false) {
if (window.location.href.includes('.hlx.') || !published) {
export function getEventPageHost() {
if (window.location.href.includes('.hlx.')) {
return window.location.origin.replace(window.location.hostname, `${ECC_ENV}--events-milo--adobecom.hlx.page`);
}

Expand Down Expand Up @@ -162,8 +162,8 @@ export async function decorateTextfield(cell, extraOptions) {
}

export function changeInputValue(input, attr, value) {
if (!input || !value) return;
input[attr] = value;
if (!input) return;
input[attr] = value || '';
input.dispatchEvent(new Event('change'));
}

Expand Down

0 comments on commit a0eeb7c

Please sign in to comment.