diff --git a/Model/Action/Dom/Click.js b/Model/Action/Dom/Click.js new file mode 100644 index 0000000..e6dc1a3 --- /dev/null +++ b/Model/Action/Dom/Click.js @@ -0,0 +1,25 @@ +/** + * Click dom element. + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {string} id Action element + * + * @since 1.0.0 + */ +export function domClickAction (action, callback, id) +{ + "use strict"; + + const click = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); + + if (!click) { + return; + } + + for (const i of click) { + i.click(); + } + + callback(); +}; \ No newline at end of file diff --git a/Model/Action/Dom/FormSubmit.js b/Model/Action/Dom/FormSubmit.js new file mode 100644 index 0000000..a5cfb2b --- /dev/null +++ b/Model/Action/Dom/FormSubmit.js @@ -0,0 +1,27 @@ +/** + * Click dom element. + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {string} id Action element + * + * @since 1.0.0 + */ +export function formSubmitAction (action, callback, id) +{ + "use strict"; + + const submit = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); + + if (!submit) { + return; + } + + const formManager = window.omsApp.uiManager.getFormManager(); + + for (const i of submit) { + formManager.submit(formManager.get(i.id)); + } + + callback(); +}; \ No newline at end of file diff --git a/Views/FormView.js b/Views/FormView.js index 9b35618..af3a0e1 100644 --- a/Views/FormView.js +++ b/Views/FormView.js @@ -430,7 +430,7 @@ export class FormView for (const key in data) { if (data.hasOwnProperty(key)) { - formData.append(key, data[key].constructor === Array ? JSON.stringify(data[key]) : data[key]); + formData.append(key, data[key] !== null && data[key].constructor === Array ? JSON.stringify(data[key]) : data[key]); } }