Skip to content

Commit

Permalink
[SCC Follow] Series error fix (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyundai authored Dec 13, 2024
1 parent 740d4a0 commit 83572ad
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ecc/blocks/event-format-component/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function populateSeriesOptions(props, component) {
const seriesSelect = component.querySelector('#series-select-input');
if (!seriesSelect) return;

const series = await getAllSeries();
const { series } = await getAllSeries();
if (!series) {
seriesSelect.pending = false;
seriesSelect.disabled = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* no css for wrapper block */
6 changes: 1 addition & 5 deletions ecc/blocks/series-creation-form/series-creation-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,11 @@ async function save(props, toPublish = false) {

let resp = props.response;

const onSave = async () => {

};

if (!resp.seriesId) {
resp = await createSeries(quickFilter(props.payload));
props.response = { ...props.response, ...resp };
updateDashboardLink(props);

if (resp?.seriesId) await handleSeriesUpdate(props);

if (!resp.error) {
Expand Down
28 changes: 14 additions & 14 deletions ecc/blocks/series-dashboard/series-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getDevToken,
} from '../../scripts/utils.js';
import { initProfileLogicTree } from '../../scripts/event-apis.js';
import { quickFilter } from '../series-creation-form/data-handler.js';

const { createTag } = await import(`${LIBS}/utils/utils.js`);

Expand Down Expand Up @@ -173,7 +174,7 @@ function initMoreOptions(props, config, seriesObj, row) {
row.classList.add('pending');
const resp = await unpublishSeries(seriesObj.seriesId, seriesObj);
updateDashboardData(resp, props);

sortData(props, config, { resort: true });
showToast(props, buildToastMsgWithEventTitle(seriesObj.title, config['unpublished-msg']), { variant: 'positive' });
});
Expand All @@ -186,9 +187,9 @@ function initMoreOptions(props, config, seriesObj, row) {
row.classList.add('pending');
const resp = await publishSeries(seriesObj.seriesId, seriesObj);
updateDashboardData(resp, props);

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

showToast(props, buildToastMsgWithEventTitle(seriesObj.title, config['published-msg']), { variant: 'positive' });
});
}
Expand All @@ -197,55 +198,54 @@ function initMoreOptions(props, config, seriesObj, row) {
// const viewTemplate = buildTool(toolBox, 'View Template', 'preview-eye');

const clone = buildTool(toolBox, 'Clone', 'clone');

if (seriesStatus && seriesStatus !== 'archived') {
const edit = buildTool(toolBox, 'Edit', 'edit-pencil');

const url = new URL(`${window.location.origin}${config['create-form-url']}`);
url.searchParams.set('seriesId', seriesObj.seriesId);
edit.href = url.toString();


const archive = buildTool(toolBox, 'Archive', 'archive');

archive.addEventListener('click', async (e) => {
e.preventDefault();

const spTheme = props.el.querySelector('sp-theme.toast-area');
if (!spTheme) return;

const underlay = spTheme.querySelector('sp-underlay');
const dialog = spTheme.querySelector('sp-dialog');
createTag('h1', { slot: 'heading' }, 'You are archiving this series.', { parent: dialog });
createTag('p', {}, 'Are you sure you want to do this? This cannot be undone.', { parent: dialog });
const buttonContainer = createTag('div', { class: 'button-container' }, '', { parent: dialog });
const dialogArchiveBtn = createTag('sp-button', { variant: 'secondary', slot: 'button' }, 'Yes, I want to archive this series', { parent: buttonContainer });
const dialogCancelBtn = createTag('sp-button', { variant: 'cta', slot: 'button' }, 'Do not archive', { parent: buttonContainer });

underlay.open = true;

dialogArchiveBtn.addEventListener('click', async () => {
toolBox.remove();
underlay.open = false;
dialog.innerHTML = '';
row.classList.add('pending');
const resp = await archiveSeries(seriesObj.seriesId);

if (resp.error) {
row.classList.remove('pending');
showToast(props, resp.error, { variant: 'negative' });
return;
}

const newJson = await getAllSeries();
props.data = newJson.series;
props.filteredData = newJson.series;
props.paginatedData = newJson.series;

sortData(props, config, { resort: true });
showToast(props, config['delete-toast-msg']);
});

dialogCancelBtn.addEventListener('click', () => {
toolBox.remove();
underlay.open = false;
Expand All @@ -254,7 +254,7 @@ function initMoreOptions(props, config, seriesObj, row) {
});
}
// const verHistory = buildTool(toolBox, 'Version History', 'version-history');

// clone
clone.addEventListener('click', async (e) => {
e.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
background-color: rgb(0 0 0 / 50%);
z-index: 2;
}

Expand Down Expand Up @@ -157,7 +157,7 @@
background: none;
border: none;
cursor: pointer;
filter: drop-shadow(1px 1px 1px #ffffff);
filter: drop-shadow(1px 1px 1px #fff);
}

.series-templates-component .picker-preview-actions button:hover {
Expand Down
10 changes: 5 additions & 5 deletions ecc/samples/sample-form/sample-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
createSeries,
updateSeries,
publishSeries,
getSeries,
} from '../../scripts/esp-controller.js';
import getJoinedData, { getFilteredCachedResponse, quickFilter, setPayloadCache, setResponseCache } from './data-handler.js';
import { initProfileLogicTree } from '../../scripts/event-apis.js';
Expand Down Expand Up @@ -217,13 +216,14 @@ async function loadData(props) {
const id = urlParams.get('id');

if (!id) return;

// fetch data to prefill the form

// props.el.classList.add('disabled');
props.el.classList.add('disabled');
// const data = await getSeries(id);
// props.response = { ...props.response, ...data };
// props.el.classList.remove('disabled');
const data = {};
props.response = { ...props.response, ...data };
props.el.classList.remove('disabled');
}

async function initComponents(props) {
Expand Down

0 comments on commit 83572ad

Please sign in to comment.