Add form data validation check & inform
This commit is contained in:
parent
3efa1beb4d
commit
0b88e625aa
2 changed files with 19 additions and 16 deletions
|
@ -24,10 +24,12 @@ socket.on("getType", data => {
|
||||||
save.innerText = "Save";
|
save.innerText = "Save";
|
||||||
save.addEventListener("click", ev => {
|
save.addEventListener("click", ev => {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
let data = {};
|
if (form.reportValidity()) {
|
||||||
for (const e of new FormData(form))
|
let data = {};
|
||||||
data[e[0]] = e[1];
|
for (const e of new FormData(form))
|
||||||
socket.emit("setTypeConfig", {type: type.type, configuration: data})
|
data[e[0]] = e[1];
|
||||||
|
socket.emit("setTypeConfig", {type: type.type, configuration: data})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
formRow.insertAdjacentElement("beforeend", save);
|
formRow.insertAdjacentElement("beforeend", save);
|
||||||
|
|
||||||
|
|
|
@ -160,22 +160,23 @@ deckSelect.addEventListener("change", ev => {
|
||||||
|
|
||||||
document.getElementById("save").addEventListener("click", ev => {
|
document.getElementById("save").addEventListener("click", ev => {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
if (form.reportValidity()) {
|
||||||
|
let data = {};
|
||||||
|
for (const e of new FormData(form))
|
||||||
|
data[e[0]] = e[1];
|
||||||
|
|
||||||
let data = {};
|
if (!slot.data)
|
||||||
for (const e of new FormData(form))
|
slot.data = {};
|
||||||
data[e[0]] = e[1];
|
|
||||||
|
|
||||||
if (!slot.data)
|
for (const k of ["text", "type", "image"]) {
|
||||||
slot.data = {};
|
slot.data[k] = data[k];
|
||||||
|
delete data[k];
|
||||||
|
}
|
||||||
|
|
||||||
for (const k of ["text", "type", "image"]) {
|
slot.data.options = data;
|
||||||
slot.data[k] = data[k];
|
|
||||||
delete data[k];
|
socket.emit("setSlot", {name: slot.name, data: slot.data, position: slot.position});
|
||||||
}
|
}
|
||||||
|
|
||||||
slot.data.options = data;
|
|
||||||
|
|
||||||
socket.emit("setSlot", {name: slot.name, data: slot.data, position: slot.position});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("delete").addEventListener("click", ev => {
|
document.getElementById("delete").addEventListener("click", ev => {
|
||||||
|
|
Loading…
Reference in a new issue