From 739169310b381a659759e332ce3cea3e50ebd0d8 Mon Sep 17 00:00:00 2001 From: Qiyun Dai Date: Fri, 13 Sep 2024 19:56:26 -0500 Subject: [PATCH 01/12] split response and payload update --- .../checkbox-component-controller.js | 6 ++++- .../event-agenda-component-controller.js | 6 ++++- ...ent-community-link-component-controller.js | 6 ++++- .../event-format-component-controller.js | 6 ++++- .../event-info-component-controller.js | 6 ++++- .../event-partners-component-controller.js | 6 ++++- .../event-topics-component-controller.js | 6 ++++- .../img-upload-component-controller.js | 6 ++++- .../product-promotion-component-controller.js | 6 ++++- .../profile-component-controller.js | 6 ++++- ...gistration-details-component-controller.js | 6 ++++- ...egistration-fields-component-controller.js | 6 ++++- .../terms-conditions-component-controller.js | 6 ++++- .../venue-info-component-controller.js | 6 ++++- ecc/blocks/form-handler/form-handler.js | 26 ++++++++++++++++--- 15 files changed, 92 insertions(+), 18 deletions(-) diff --git a/ecc/blocks/form-handler/controllers/checkbox-component-controller.js b/ecc/blocks/form-handler/controllers/checkbox-component-controller.js index ff78c213..59674058 100644 --- a/ecc/blocks/form-handler/controllers/checkbox-component-controller.js +++ b/ecc/blocks/form-handler/controllers/checkbox-component-controller.js @@ -40,7 +40,11 @@ export default function init(component, props) { }); } -export async function onUpdate(_component, _props) { +export async function onPayloadUpdate(_component, _props) { + // Do nothing +} + +export async function onRespUpdate(_component, _props) { // Do nothing } diff --git a/ecc/blocks/form-handler/controllers/event-agenda-component-controller.js b/ecc/blocks/form-handler/controllers/event-agenda-component-controller.js index c3865d02..59759f2d 100644 --- a/ecc/blocks/form-handler/controllers/event-agenda-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-agenda-component-controller.js @@ -17,7 +17,11 @@ export function onSubmit(component, props) { props.payload = { ...props.payload, ...agendaInfo }; } -export async function onUpdate(_component, _props) { +export async function onPayloadUpdate(_component, _props) { + // Do nothing +} + +export async function onRespUpdate(_component, _props) { // Do nothing } diff --git a/ecc/blocks/form-handler/controllers/event-community-link-component-controller.js b/ecc/blocks/form-handler/controllers/event-community-link-component-controller.js index 77c76d85..ac54ce5b 100644 --- a/ecc/blocks/form-handler/controllers/event-community-link-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-community-link-component-controller.js @@ -16,7 +16,11 @@ export function onSubmit(component, props) { } } -export async function onUpdate(_component, _props) { +export async function onPayloadUpdate(_component, _props) { + // Do nothing +} + +export async function onRespUpdate(_component, _props) { // Do nothing } diff --git a/ecc/blocks/form-handler/controllers/event-format-component-controller.js b/ecc/blocks/form-handler/controllers/event-format-component-controller.js index bd527715..ee5d7673 100644 --- a/ecc/blocks/form-handler/controllers/event-format-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-format-component-controller.js @@ -52,7 +52,7 @@ function initStepLock(component) { onFormatChange(); } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { const { seriesId } = props.payload; if (seriesId) { const partnerSelectorGroups = document.querySelectorAll('partner-selector-group'); @@ -67,6 +67,10 @@ export async function onUpdate(component, props) { } } +export async function onRespUpdate(_component, _props) { + // Do nothing +} + async function populateSeriesOptions(props, component) { const seriesSelect = component.querySelector('#series-select-input'); if (!seriesSelect) return; diff --git a/ecc/blocks/form-handler/controllers/event-info-component-controller.js b/ecc/blocks/form-handler/controllers/event-info-component-controller.js index d7538031..12b7aebd 100644 --- a/ecc/blocks/form-handler/controllers/event-info-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-info-component-controller.js @@ -342,10 +342,14 @@ export function onSubmit(component, props) { props.payload = { ...props.payload, ...eventInfo }; } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { // do nothing } +export async function onRespUpdate(_component, _props) { + // Do nothing +} + function checkEventDuplication(event, compareMetrics) { const titleMatch = event.title === compareMetrics.title; const startDateMatch = event.localStartDate === compareMetrics.startDate; diff --git a/ecc/blocks/form-handler/controllers/event-partners-component-controller.js b/ecc/blocks/form-handler/controllers/event-partners-component-controller.js index 1ecaa5d7..a250fdeb 100644 --- a/ecc/blocks/form-handler/controllers/event-partners-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-partners-component-controller.js @@ -95,7 +95,7 @@ export async function onSubmit(component, props) { props.payload = { ...props.payload, showSponsors }; } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { if (!PARTNERS_SERIES_ID || PARTNERS_SERIES_ID !== props.eventDataResp.seriesId) { const partnersGroup = component.querySelector('partner-selector-group'); @@ -108,6 +108,10 @@ export async function onUpdate(component, props) { } } +export async function onRespUpdate(_component, _props) { + // Do nothing +} + export default async function init(component, props) { const eventData = props.eventDataResp; const partnersGroup = component.querySelector('partner-selector-group'); diff --git a/ecc/blocks/form-handler/controllers/event-topics-component-controller.js b/ecc/blocks/form-handler/controllers/event-topics-component-controller.js index 1488807a..f0de27df 100644 --- a/ecc/blocks/form-handler/controllers/event-topics-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-topics-component-controller.js @@ -9,7 +9,11 @@ export function onSubmit(component, props) { props.payload = { ...props.payload, topics, fullTopicsValue }; } -export async function onUpdate(_component, _props) { +export async function onPayloadUpdate(_component, _props) { + // Do nothing +} + +export async function onRespUpdate(_component, _props) { // Do nothing } diff --git a/ecc/blocks/form-handler/controllers/img-upload-component-controller.js b/ecc/blocks/form-handler/controllers/img-upload-component-controller.js index 1138f0e4..9b2f1c47 100644 --- a/ecc/blocks/form-handler/controllers/img-upload-component-controller.js +++ b/ecc/blocks/form-handler/controllers/img-upload-component-controller.js @@ -38,10 +38,14 @@ function updateImgUploadComponentConfigs(component) { component.dataset.configs = JSON.stringify(configs); } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { updateImgUploadComponentConfigs(component); } +export async function onRespUpdate(_component, _props) { + // Do nothing +} + export default async function init(component, props) { const type = getComponentImageType(component); const dropzones = component.querySelectorAll('image-dropzone'); diff --git a/ecc/blocks/form-handler/controllers/product-promotion-component-controller.js b/ecc/blocks/form-handler/controllers/product-promotion-component-controller.js index 65b5046d..ff1e3566 100644 --- a/ecc/blocks/form-handler/controllers/product-promotion-component-controller.js +++ b/ecc/blocks/form-handler/controllers/product-promotion-component-controller.js @@ -100,10 +100,14 @@ async function updateProductSelector(component, props) { }); } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { await updateProductSelector(component, props); } +export async function onRespUpdate(_component, _props) { + // Do nothing +} + export default async function init(component, props) { const eventData = props.eventDataResp; const productGroup = component.querySelector('product-selector-group'); diff --git a/ecc/blocks/form-handler/controllers/profile-component-controller.js b/ecc/blocks/form-handler/controllers/profile-component-controller.js index 999eb50b..fd63b307 100644 --- a/ecc/blocks/form-handler/controllers/profile-component-controller.js +++ b/ecc/blocks/form-handler/controllers/profile-component-controller.js @@ -101,7 +101,7 @@ export async function onSubmit(component, props) { } } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { const containers = component.querySelectorAll('profile-container'); containers.forEach(async (container) => { if (props.payload.seriesId && props.payload.seriesId !== container.seriesId) { @@ -113,6 +113,10 @@ export async function onUpdate(component, props) { }); } +export async function onRespUpdate(_component, _props) { + // Do nothing +} + async function prefillProfiles(props) { const d = await props.eventDataResp; if (d?.eventId && d.seriesId) { diff --git a/ecc/blocks/form-handler/controllers/registration-details-component-controller.js b/ecc/blocks/form-handler/controllers/registration-details-component-controller.js index d19f3fad..cde7c625 100644 --- a/ecc/blocks/form-handler/controllers/registration-details-component-controller.js +++ b/ecc/blocks/form-handler/controllers/registration-details-component-controller.js @@ -59,7 +59,11 @@ export function onSubmit(component, props) { props.payload = { ...props.payload, ...rsvpData }; } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { + // Do nothing +} + +export async function onRespUpdate(component, props) { if (!props.eventDataResp) return; if (props.eventDataResp.cloudType === 'CreativeCloud') { diff --git a/ecc/blocks/form-handler/controllers/registration-fields-component-controller.js b/ecc/blocks/form-handler/controllers/registration-fields-component-controller.js index 6fc20673..353d6bb5 100644 --- a/ecc/blocks/form-handler/controllers/registration-fields-component-controller.js +++ b/ecc/blocks/form-handler/controllers/registration-fields-component-controller.js @@ -12,7 +12,11 @@ export function onSubmit(component, props) { props.payload = { ...props.payload, rsvpFormFields }; } -export async function onUpdate(_component, _props) { +export async function onPayloadUpdate(_component, _props) { + // Do nothing +} + +export async function onRespUpdate(_component, _props) { // Do nothing } diff --git a/ecc/blocks/form-handler/controllers/terms-conditions-component-controller.js b/ecc/blocks/form-handler/controllers/terms-conditions-component-controller.js index ce84b020..1e776f0c 100644 --- a/ecc/blocks/form-handler/controllers/terms-conditions-component-controller.js +++ b/ecc/blocks/form-handler/controllers/terms-conditions-component-controller.js @@ -63,12 +63,16 @@ async function loadPreview(component, templateId) { } } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { const { templateId } = props.payload; if (!templateId) return; await loadPreview(component, templateId); } +export async function onRespUpdate(_component, _props) { + // Do nothing +} + export default async function init(component, props) { const { templateId } = props.payload; if (!templateId) return; diff --git a/ecc/blocks/form-handler/controllers/venue-info-component-controller.js b/ecc/blocks/form-handler/controllers/venue-info-component-controller.js index 284d08d0..e2c00d7f 100644 --- a/ecc/blocks/form-handler/controllers/venue-info-component-controller.js +++ b/ecc/blocks/form-handler/controllers/venue-info-component-controller.js @@ -112,10 +112,14 @@ export async function onSubmit(component, props) { // do nothing. Depend on eventUpdated event. } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { // do nothing } +export async function onRespUpdate(_component, _props) { + // Do nothing +} + export default async function init(component, props) { const eventData = props.eventDataResp; diff --git a/ecc/blocks/form-handler/form-handler.js b/ecc/blocks/form-handler/form-handler.js index 972d3632..bb898551 100644 --- a/ecc/blocks/form-handler/form-handler.js +++ b/ecc/blocks/form-handler/form-handler.js @@ -294,14 +294,31 @@ async function handleEventUpdate(props) { await Promise.all(allComponentPromises); } -async function updateComponents(props) { +async function updateComponentsOnPayloadChange(props) { const allComponentPromises = VANILLA_COMPONENTS.map(async (comp) => { const mappedComponents = props.el.querySelectorAll(`.${comp}-component`); if (!mappedComponents.length) return {}; const promises = Array.from(mappedComponents).map(async (component) => { - const { onUpdate } = await import(`./controllers/${comp}-component-controller.js`); - const componentPayload = await onUpdate(component, props); + const { onPayloadUpdate } = await import(`./controllers/${comp}-component-controller.js`); + const componentPayload = await onPayloadUpdate(component, props); + return componentPayload; + }); + + return Promise.all(promises); + }); + + await Promise.all(allComponentPromises); +} + +async function updateComponentsOnRespChange(props) { + const allComponentPromises = VANILLA_COMPONENTS.map(async (comp) => { + const mappedComponents = props.el.querySelectorAll(`.${comp}-component`); + if (!mappedComponents.length) return {}; + + const promises = Array.from(mappedComponents).map(async (component) => { + const { onRespUpdate } = await import(`./controllers/${comp}-component-controller.js`); + const componentPayload = await onRespUpdate(component, props); return componentPayload; }); @@ -760,13 +777,14 @@ async function buildECCForm(el) { case 'payload': { setPayloadCache(value); - updateComponents(target); + updateComponentsOnPayloadChange(target); initRequiredFieldsValidation(target); break; } case 'eventDataResp': { setResponseCache(value); + updateComponentsOnRespChange(target); updateCtas(target); if (value.error) { props.el.classList.add('show-error'); From 1ea09275395616661d932e4dc982a5839cdee0b4 Mon Sep 17 00:00:00 2001 From: Qiyun Dai Date: Thu, 19 Sep 2024 17:18:15 -0500 Subject: [PATCH 02/12] Update event-community-link-component.js --- .../event-community-link-component.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ecc/blocks/event-community-link-component/event-community-link-component.js b/ecc/blocks/event-community-link-component/event-community-link-component.js index 9b2c210a..02f964dc 100644 --- a/ecc/blocks/event-community-link-component/event-community-link-component.js +++ b/ecc/blocks/event-community-link-component/event-community-link-component.js @@ -1,3 +1,4 @@ +import { LINK_REGEX } from '../../constants/constants.js'; import { LIBS } from '../../scripts/scripts.js'; import { generateToolTip } from '../../scripts/utils.js'; @@ -14,7 +15,7 @@ async function decorateFields(row) { id: 'community-url-details', class: 'text-input', placeholder: text, - pattern: '^https:\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$', + pattern: LINK_REGEX, size: 'xl', }); From 756040a7b8f050119fe3ae48f07bce14cb819b81 Mon Sep 17 00:00:00 2001 From: Qiyun Dai Date: Mon, 23 Sep 2024 10:29:49 -0500 Subject: [PATCH 03/12] making bio optional --- ecc/components/profile/profile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ecc/components/profile/profile.js b/ecc/components/profile/profile.js index cb814a9d..28090e31 100644 --- a/ecc/components/profile/profile.js +++ b/ecc/components/profile/profile.js @@ -169,7 +169,7 @@ export class Profile extends LitElement { saveDisabled() { // eslint-disable-next-line max-len - return !this.profile.firstName || !this.profile.lastName || !this.profile.title || !this.profile.bio; + return !this.profile.firstName || !this.profile.lastName || !this.profile.title; } renderNameFieldWithSearchIntegrated() { @@ -269,7 +269,7 @@ export class Profile extends LitElement { }; const bioData = { - value: this.profile?.bio, + value: this.profile?.bio ?? '', placeholder: fieldLabelsJSON.bio, helperText: fieldLabelsJSON.bioSubText, }; @@ -397,7 +397,7 @@ export class Profile extends LitElement { : nothing}
${this.profile.title}
-

${this.profile.bio}

+ ${this.profile.bio ? html`

${this.profile.bio}

` : nothing}
${this.profile?.socialMedia?.length ? html`