- added spreadsheet form element;
This commit is contained in:
@@ -92,6 +92,29 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormsCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
const EXCLUDED_TYPES = new Set(['fileupload', 'fileselect', 'table', 'criteria_table', 'spreadsheet']);
|
||||
const raw = (resp.data ?? []).flatMap(form =>
|
||||
(form.content ?? [])
|
||||
.filter(f => !EXCLUDED_TYPES.has(f.name))
|
||||
.map(f => ({
|
||||
id: f.id,
|
||||
label: f.label,
|
||||
placeholder: f.settings?.find(s => s.name === 'placeholder')?.value ?? ''
|
||||
}))
|
||||
);
|
||||
const byLabel = new Map();
|
||||
raw.forEach(f => {
|
||||
if (!byLabel.has(f.label)) byLabel.set(f.label, { label: f.label, ids: [], placeholder: f.placeholder });
|
||||
byLabel.get(f.label).ids.push(f.id);
|
||||
});
|
||||
storeSet('callFormFields', Array.from(byLabel.values()));
|
||||
}
|
||||
}
|
||||
|
||||
const errGetFormsCallback = () => {}
|
||||
|
||||
const getFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
storeSet('formId', resp.data.id);
|
||||
@@ -117,12 +140,14 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
useEffect(() => {
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallbacks);
|
||||
FormsService.getFormsForCall(id, getFormsCallback, errGetFormsCallback);
|
||||
|
||||
return () => {
|
||||
storeSet('formId', 0);
|
||||
storeSet('formElements', []);
|
||||
storeSet('activeElement', '');
|
||||
storeSet('selectedElement', '');
|
||||
storeSet('callFormFields', []);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user