mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 17:58:41 +00:00
Fix form submit/data bugs
This commit is contained in:
parent
46b87aa55a
commit
b9b339d39a
|
|
@ -130,7 +130,13 @@
|
|||
*/
|
||||
bindExport(exports)
|
||||
{
|
||||
exports.getExport().addEventListener('click', function (event)
|
||||
const button = exports.getExport();
|
||||
|
||||
if (typeof button === 'undefined' || button === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
button.addEventListener('click', function (event)
|
||||
{
|
||||
console.log(exports.serialize());
|
||||
// todo: either create download in javascript from this data or make roundtrip to server who then sends the data
|
||||
|
|
|
|||
|
|
@ -176,7 +176,8 @@
|
|||
buttons = form.getElementsByTagName('button'),
|
||||
canvas = form.getElementsByTagName('canvas'),
|
||||
external = document.querySelectorAll('[form=' + this.id + ']'),
|
||||
special = document.querySelectorAll('[data-form=' + this.id + '] [data-name]'),
|
||||
special = form.querySelectorAll('[data-name]'),
|
||||
specialExt = document.querySelectorAll('[data-form=' + this.id + '] [data-name]'),
|
||||
inputLength = inputs.length;
|
||||
|
||||
// todo: handle trigger element. check which element triggered the submit and pass it's name+value
|
||||
|
|
@ -192,15 +193,14 @@
|
|||
// todo: handle radio here as well
|
||||
}
|
||||
|
||||
return this.getUniqueFormElements(
|
||||
Array.prototype.slice.call(inputs).concat(
|
||||
Array.prototype.slice.call(selects),
|
||||
Array.prototype.slice.call(textareas),
|
||||
Array.prototype.slice.call(buttons),
|
||||
Array.prototype.slice.call(external),
|
||||
Array.prototype.slice.call(special)
|
||||
)
|
||||
);
|
||||
return Array.prototype.slice.call(inputs).concat(
|
||||
Array.prototype.slice.call(selects),
|
||||
Array.prototype.slice.call(textareas),
|
||||
Array.prototype.slice.call(buttons),
|
||||
Array.prototype.slice.call(external),
|
||||
Array.prototype.slice.call(special),
|
||||
Array.prototype.slice.call(specialExt)
|
||||
).filter(function(val) { return val; });
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -247,8 +247,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
// handle array data (e.g. table rows with same name)
|
||||
const id = jsOMS.Views.FormView.getElementId(elements[i]);
|
||||
if (id === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// handle array data (e.g. table rows with same name)
|
||||
if (data.hasOwnProperty(id)) {
|
||||
if (data[id].constructor !== Array) {
|
||||
data[id] = [data[id]];
|
||||
|
|
@ -335,7 +339,7 @@
|
|||
return e.getAttribute('type');
|
||||
}
|
||||
|
||||
throw Error("Invalid id");
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user