feat(datepicker): formatting dates for mass-inputs
This commit is contained in:
parent
f5636b81d1
commit
b9fd4d7d28
@ -112,4 +112,20 @@ export class Datepicker {
|
||||
if (!this.datepickerInstance.select || !this._element.value) return;
|
||||
this._element.value = dateFormat(this.datepickerInstance.select, FORM_DATE_FORMAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls formatElementValue on all datepicker objects registered for a form.
|
||||
* @param {*} formID ID of the form for which all datepicker date values should be formatted
|
||||
*/
|
||||
static formatAllFormElementValues(formID) {
|
||||
if (!Datepicker.datepickerCollections) {
|
||||
// no datepicker collections yet (i.e. constructor was never called) => do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
if (Datepicker.datepickerCollections.has(formID)) {
|
||||
const datepickerInstances = Datepicker.datepickerCollections.get(formID);
|
||||
datepickerInstances.forEach(instance => instance.formatElementValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import { Utility } from '../../core/utility';
|
||||
import { Datepicker } from '../form/datepicker';
|
||||
|
||||
const MASS_INPUT_CELL_SELECTOR = '.massinput__cell';
|
||||
const MASS_INPUT_ADD_CELL_SELECTOR = '.massinput__cell--add';
|
||||
@ -95,6 +96,9 @@ export class MassInput {
|
||||
return false;
|
||||
}
|
||||
|
||||
// format any date values before submission
|
||||
Datepicker.formatAllFormElementValues(this._massInputForm.id);
|
||||
|
||||
event.preventDefault();
|
||||
const requestBody = this._serializeForm(submitButton, enctype);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user