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

Stage to Main | Aug 9 #167

Merged
merged 5 commits into from
Aug 10, 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
2 changes: 1 addition & 1 deletion ecc/blocks/ecc-dashboard/ecc-dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
font-weight: 700;
text-align: left;
font-size: var(--type-body-xxs-size);
color: var(--color-gray-500);
color: var(--spectrum-color-gray-500);
user-select: none;
width: 100px;
white-space: nowrap;
Expand Down
45 changes: 26 additions & 19 deletions ecc/blocks/ecc-dashboard/ecc-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ export function cloneFilter(obj) {
return output;
}

function showToast(props, msg, options = {}) {
const toastArea = props.el.querySelector('sp-theme.toast-area');
const toast = createTag('sp-toast', { open: true, ...options }, msg, { parent: toastArea });
toast.addEventListener('close', () => {
toast.remove();
});
}

function toClassName(name) {
return name && typeof name === 'string'
? name.toLowerCase().replace(/[^0-9a-z]/gi, '-')
Expand Down Expand Up @@ -225,7 +233,8 @@ function sortData(props, config, options = {}) {
el?.classList.add('active');
}

function buildToastMsg(eventTitle, msgTemplate) {
function buildToastMsgWithEventTitle(eventTitle, configValue) {
const msgTemplate = configValue instanceof Array ? configValue.join('<br/>') : configValue;
return msgTemplate.replace(/\[\[(.*?)\]\]/g, eventTitle);
}

Expand All @@ -252,6 +261,7 @@ function initMoreOptions(props, config, eventObj, row) {
updateDashboardData(resp, props);

sortData(props, config, { resort: true });
showToast(props, buildToastMsgWithEventTitle(eventObj.title, config['event-unpublished-msg']), { variant: 'positive' });
});
} else {
const pub = buildTool(toolBox, 'Publish', 'publish-rocket');
Expand All @@ -264,6 +274,8 @@ function initMoreOptions(props, config, eventObj, row) {
updateDashboardData(resp, props);

sortData(props, config, { resort: true });

showToast(props, buildToastMsgWithEventTitle(eventObj.title, config['event-published-msg']), { variant: 'positive' });
});
}

Expand All @@ -276,11 +288,15 @@ function initMoreOptions(props, config, eventObj, row) {
if (eventObj.detailPagePath) {
previewPre.href = (() => {
const url = new URL(`${getEventPageHost(eventObj.published)}${eventObj.detailPagePath}`);
url.searchParams.set('previewMode', 'true');
url.searchParams.set('cachebuster', Date.now());
url.searchParams.set('timing', +eventObj.localEndTimeMillis - 10);
return url.toString();
})();
previewPost.href = (() => {
const url = new URL(`${getEventPageHost(eventObj.published)}${eventObj.detailPagePath}`);
url.searchParams.set('previewMode', 'true');
url.searchParams.set('cachebuster', Date.now());
url.searchParams.set('timing', +eventObj.localEndTimeMillis + 10);
return url.toString();
})();
Expand All @@ -297,7 +313,6 @@ function initMoreOptions(props, config, eventObj, row) {
// clone
clone.addEventListener('click', async (e) => {
e.preventDefault();
const spTheme = props.el.querySelector('sp-theme.toast-area');
const payload = { ...eventObj };
payload.title = `${eventObj.title} - copy`;
toolBox.remove();
Expand All @@ -312,11 +327,10 @@ function initMoreOptions(props, config, eventObj, row) {
props.currentSort = { field: 'modificationTime', el: modTimeHeader };
sortData(props, config, { direction: 'desc' });
}
const msgTemplate = config['clone-event-toast-msg'] instanceof Array ? config['clone-event-toast-msg'].join('<br/>') : config['clone-event-toast-msg'];
const toastMsg = buildToastMsg(newEventJSON.title, msgTemplate);
createTag('sp-toast', { open: true, variant: 'info' }, toastMsg, { parent: spTheme });

const newRow = props.el.querySelector(`tr[data-event-id="${newEventJSON.eventId}"]`);
highlightRow(newRow);
showToast(props, buildToastMsgWithEventTitle(newEventJSON.title, config['clone-event-toast-msg']), { variant: 'info' });
});

// delete
Expand Down Expand Up @@ -348,7 +362,7 @@ function initMoreOptions(props, config, eventObj, row) {
props.paginatedData = newJson.events;

sortData(props, config, { resort: true });
createTag('sp-toast', { open: true }, config['delete-event-toast-msg'], { parent: spTheme });
showToast(props, config['delete-event-toast-msg']);
});

dialogCancelBtn.addEventListener('click', () => {
Expand Down Expand Up @@ -395,32 +409,27 @@ function buildEventTitleTag(config, eventObj) {
}

// TODO: to retire
function buildVenueTag(config, eventObj) {
function buildVenueTag(eventObj) {
const { venue } = eventObj;
if (!venue) return null;

const url = new URL(`${window.location.origin}${config['create-form-url']}`);
url.searchParams.set('eventId', eventObj.eventId);

const venueTag = createTag('a', { class: 'vanue-name', href: url.toString() }, venue.venueName);
const venueTag = createTag('span', { class: 'vanue-name' }, venue.venueName);
return venueTag;
}

function buildRSVPTag(config, eventObj) {
let text = 'RSVP';
if (eventObj.externalEventId?.startsWith('st')) text = 'SplashThat';
const text = `${eventObj.attendeeCount} / ${eventObj.attendeeLimit}`;

const url = new URL(`${window.location.origin}${config['create-form-url']}`);
url.searchParams.set('eventId', eventObj.eventId);

const rsvpTag = createTag('a', { class: 'rsvp-tag', href: `${url.toString()}#form-step-rsvp` }, text);
const rsvpTag = createTag('span', { class: 'rsvp-tag' }, text);
return rsvpTag;
}

async function populateRow(props, config, index) {
const event = props.paginatedData[index];
const tBody = props.el.querySelector('table.dashboard-table tbody');
const toastArea = props.el.querySelector('.toast-area');
const sp = new URLSearchParams(window.location.search);

// TODO: build each column's element specifically rather than just text
Expand All @@ -430,7 +439,7 @@ async function populateRow(props, config, index) {
const statusCell = createTag('td', {}, createTag('div', { class: 'td-wrapper' }, buildStatusTag(event)));
const startDateCell = createTag('td', {}, createTag('div', { class: 'td-wrapper' }, formatLocaleDate(event.startDate)));
const modDateCell = createTag('td', {}, createTag('div', { class: 'td-wrapper' }, formatLocaleDate(event.modificationTime)));
const venueCell = createTag('td', {}, createTag('div', { class: 'td-wrapper' }, buildVenueTag(config, event)));
const venueCell = createTag('td', {}, createTag('div', { class: 'td-wrapper' }, buildVenueTag(event)));
const geoCell = createTag('td', {}, createTag('div', { class: 'td-wrapper' }, getCountryName(event)));
const externalEventId = createTag('td', {}, createTag('div', { class: 'td-wrapper' }, buildRSVPTag(config, event)));
const moreOptionsCell = createTag('td', { class: 'option-col' }, createTag('div', { class: 'td-wrapper' }, getIcon('more-small-list')));
Expand All @@ -451,9 +460,7 @@ async function populateRow(props, config, index) {

if (event.eventId === sp.get('newEventId')) {
if (!props.el.classList.contains('toast-shown')) {
const msgTemplate = config['new-event-toast-msg'] instanceof Array ? config['new-event-toast-msg'].join('<br/>') : config['new-event-toast-msg'];
const toastMsg = buildToastMsg(event.title, msgTemplate);
createTag('sp-toast', { class: 'new-event-confirmation-toast', open: true, variant: 'positive' }, toastMsg, { parent: toastArea });
showToast(props, buildToastMsgWithEventTitle(event.title, config['new-event-toast-msg']), { variant: 'positive' });

props.el.classList.add('toast-shown');
}
Expand Down
1 change: 0 additions & 1 deletion ecc/blocks/event-info-component/event-info-component.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
width: 100%;
outline: none;
resize: vertical;
min-height: 40px;
}

.event-info-component label {
Expand Down
1 change: 0 additions & 1 deletion ecc/blocks/form-handler/form-handler.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
}

.form-handler sp-textfield {
display: unset;
outline: none;
}

Expand Down
2 changes: 1 addition & 1 deletion ecc/blocks/form-handler/form-handler.js
Original file line number Diff line number Diff line change
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&timing=${testTime}`;
a.href = `${getEventPageHost(eventDataResp.published)}${eventDataResp.detailPagePath}?previewMode=true&cachebuster=${Date.now()}&timing=${testTime}`;
a.classList.remove('preview-not-ready');
}
}
Expand Down
1 change: 0 additions & 1 deletion ecc/blocks/venue-info-component/venue-info-component.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
}

.venue-info-component sp-textfield[readonly] {
padding-bottom: 10px;
border-bottom: 1px solid var(--color-gray-500);
}

Expand Down
Loading