mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-15 16:58:42 +00:00
fix form bugs and add actions for click and submit
This commit is contained in:
parent
43c763d405
commit
6f08f7f81a
25
Model/Action/Dom/Click.js
Normal file
25
Model/Action/Dom/Click.js
Normal file
|
|
@ -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();
|
||||||
|
};
|
||||||
27
Model/Action/Dom/FormSubmit.js
Normal file
27
Model/Action/Dom/FormSubmit.js
Normal file
|
|
@ -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();
|
||||||
|
};
|
||||||
|
|
@ -430,7 +430,7 @@ export class FormView
|
||||||
|
|
||||||
for (const key in data) {
|
for (const key in data) {
|
||||||
if (data.hasOwnProperty(key)) {
|
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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user