Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MWPW-156526] ECC Form Status Tag #181

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ecc/blocks/form-handler/form-handler.css
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,24 @@
color: var(--color-red);
}

.form-handler .main-frame .section:first-of-type .step-heading-wrapper {
display: flex;
align-items: center;
gap: 16px;
}

.form-handler .main-frame .section:first-of-type .step-heading-wrapper .event-status-tag {
padding: 0 8px;
background-color: var(--color-white);
border-radius: 4px;
}

.form-handler .main-frame .section:not(:first-of-type) {
padding: 24px 56px;
border-radius: 10px;
margin: 24px;
box-shadow: 0 3px 6px 0 rgb(0 0 0 / 16%);
background-color: var(--color-white);
}

.form-handler .fragment.hidden {
Expand Down Expand Up @@ -368,6 +381,10 @@
width: 20px;
}

.form-handler .main-frame .section:first-of-type .step-heading-wrapper .event-status-tag .icon {
margin-right: 4px;
}

.form-handler .form-handler-ctas-panel .form-handler-forward-wrapper > div:first-of-type {
padding-right: 64px;
border-right: 1px solid var(--color-black);
Expand Down
29 changes: 29 additions & 0 deletions ecc/blocks/form-handler/form-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,15 @@ function initFormCtas(props) {
});

backBtn.addEventListener('click', async () => {
toggleBtnsSubmittingState(true);
const resp = await saveEvent(props);
if (resp?.error) {
buildErrorMessage(props, resp);
} else {
props.currentStep -= 1;
}

toggleBtnsSubmittingState(false);
});
}

Expand Down Expand Up @@ -666,6 +669,29 @@ function initDeepLink(props) {
}
}

function updateStatusTag(props) {
const { eventDataResp } = props;

if (eventDataResp?.published === undefined) return;

const currentFragment = getCurrentFragment(props);

const headingSection = currentFragment.querySelector(':scope > .section:first-child');

const eixstingStatusTag = headingSection.querySelector('.event-status-tag');
if (eixstingStatusTag) eixstingStatusTag.remove();

const heading = headingSection.querySelector('h2', 'h3', 'h3', 'h4');
const headingWrapper = createTag('div', { class: 'step-heading-wrapper' });
const dot = eventDataResp.published ? getIcon('dot-purple') : getIcon('dot-green');
const text = eventDataResp.published ? 'Published' : 'Draft';
const statusTag = createTag('span', { class: 'event-status-tag' });

statusTag.append(dot, text);
heading.parentElement?.replaceChild(headingWrapper, heading);
headingWrapper.append(heading, statusTag);
}

async function buildECCForm(el) {
const props = {
el,
Expand All @@ -691,6 +717,7 @@ async function buildECCForm(el) {
renderFormNavigation(target, oldValue, value);
updateSideNav(target);
initRequiredFieldsValidation(target);
updateStatusTag(target);
break;
}

Expand Down Expand Up @@ -746,6 +773,8 @@ async function buildECCForm(el) {
updateRequiredFields(proxyProps);
enableSideNavForEditFlow(proxyProps);
initDeepLink(proxyProps);
updateStatusTag(proxyProps);

el.addEventListener('show-error-toast', (e) => {
e.stopPropagation();
e.preventDefault();
Expand Down
Loading