From 65f067f0873c2cad7a474831ef7666adff0f8662 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 16 Feb 2019 01:28:41 +0100 Subject: [PATCH] Improve data collection --- Model/Action/Dom/GetValue.js | 12 ++++++++---- Model/Action/Event/Prevent.js | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 Model/Action/Event/Prevent.js diff --git a/Model/Action/Dom/GetValue.js b/Model/Action/Dom/GetValue.js index eddfe51..e3cef9e 100644 --- a/Model/Action/Dom/GetValue.js +++ b/Model/Action/Dom/GetValue.js @@ -1,5 +1,5 @@ /** - * Set message. + * Get value from dom. * * @param {Object} action Action data * @param {function} callback Callback @@ -12,7 +12,7 @@ const domGetValue = function (action, callback, id) "use strict"; const e = action.base === 'self' ? (action.selector === '' || typeof action.selector === 'undefined' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); - let value = []; + let value = {}; for (let i in e) { /** global: HTMLElement */ @@ -20,10 +20,14 @@ const domGetValue = function (action, callback, id) continue; } - let eId = (typeof e[i].name !== 'undefined' && e[i].name !== '') ? e[i].name : e[i].id; + let eId = (typeof e[i].getAttribute('name') !== 'undefined' && e[i].getAttribute('name') !== '' && e[i].getAttribute('name') !== null) ? e[i].getAttribute('name') : e[i].getAttribute('id'); if (e[i].tagName === 'INPUT' || e[i].tagName === 'SELECTS' || e[i].tagName === 'BUTTON') { - value[eId] = e[i].value; + value[eId] = e[i].getAttribute('value'); + } else if (e[i].tagName === 'FORM') { + // todo: this is messy. if form should be handled somewhere else not in loop since it overwrites all other values... will there very be other values in case of a form selector? if yes than this will cause a bug! + value = window.omsApp.uiManager.getFormManager().get(eId).getData(); + break; } else { value[eId] = e[i].getAttribute('data-id'); } diff --git a/Model/Action/Event/Prevent.js b/Model/Action/Event/Prevent.js new file mode 100644 index 0000000..53ca316 --- /dev/null +++ b/Model/Action/Event/Prevent.js @@ -0,0 +1,17 @@ +/** + * Prevent UI action. + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {string} id Action element + * + * @since 1.0.0 + */ +const preventEvent = function (action, callback, id) +{ + "use strict"; + + jsOMS.preventAll(action.data); + + callback(); +}; \ No newline at end of file