forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformSubmit.js
More file actions
37 lines (32 loc) · 1.18 KB
/
formSubmit.js
File metadata and controls
37 lines (32 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { enableUnlimitedInputs } from './unlimitedInput';
import { updateAdvancedTextarea } from './toggleAdvanced';
import { showSpinner } from './helpers';
export default function handleFormSubmit() {
const pageForm = document.querySelector('#vstobjects');
if (pageForm) {
pageForm.addEventListener('submit', () => {
// Show loading spinner
showSpinner();
// Enable any disabled inputs to ensure all fields are submitted
if (pageForm.classList.contains('js-enable-inputs-on-submit')) {
document.querySelectorAll('input[disabled]').forEach((input) => {
input.disabled = false;
});
}
// Enable any disabled unlimited inputs and set their value to "unlimited"
enableUnlimitedInputs();
// Update the "advanced options" textarea with "basic options" input values
const basicOptionsWrapper = document.querySelector('.js-basic-options');
if (basicOptionsWrapper && !basicOptionsWrapper.classList.contains('u-hidden')) {
updateAdvancedTextarea();
}
});
}
const bulkEditForm = document.querySelector('[x-bind="BulkEdit"]');
if (bulkEditForm) {
bulkEditForm.addEventListener('submit', () => {
// Show loading spinner
showSpinner();
});
}
}