feat(massinput): reduce size of ajax requests
This commit is contained in:
parent
8c7cc62aed
commit
72838e2592
@ -226,8 +226,21 @@ export class MassInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_serializeForm(submitButton, enctype) {
|
_serializeForm(submitButton, enctype) {
|
||||||
|
const rawFormData = new FormData(this._massInputForm);
|
||||||
|
const extraneousKeys = new Set();
|
||||||
|
for (const k of rawFormData.keys()) {
|
||||||
|
const n = k.replace(/\[\]$/, '');
|
||||||
|
const inputElements = Array.from(this._massInputForm.querySelectorAll(`[name=${n}]`));
|
||||||
|
const isBelowMassinput = inputElements.some((elem) => this._element.contains(elem));
|
||||||
|
const isFile = inputElements.some((elem) => elem.type === 'file');
|
||||||
|
|
||||||
|
if (!isBelowMassinput && isFile)
|
||||||
|
extraneousKeys.add(k);
|
||||||
|
}
|
||||||
|
for (const k of extraneousKeys)
|
||||||
|
rawFormData.delete(k);
|
||||||
// create new FormData and format any date values
|
// create new FormData and format any date values
|
||||||
const formData = Datepicker.unformatAll(this._massInputForm, new FormData(this._massInputForm));
|
const formData = Datepicker.unformatAll(this._massInputForm, rawFormData);
|
||||||
|
|
||||||
// manually add name and value of submit button to formData
|
// manually add name and value of submit button to formData
|
||||||
formData.append(submitButton.name, submitButton.value);
|
formData.append(submitButton.name, submitButton.value);
|
||||||
|
|||||||
Reference in New Issue
Block a user