diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 9e16f22..9b3e6b1 100644 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -313,7 +313,7 @@ export class Form { new NotificationMessage( NotificationLevel.ERROR, 'Failure', - 'Some failure happend' + 'Some failure happened' ), NotificationType.APP_NOTIFICATION ); }); @@ -353,7 +353,8 @@ export class Form { // todo: maybe allow multiple add buttons!!!! In order to do that do createForm.getAttribute('data-ui-form') and add this attribute to the add button instead of the pseudo form this.app.uiManager.getFormManager().get(createForm).injectSubmit(function () { - const subMain = document.getElementById(id).querySelector(document.getElementById(id).getAttribute('data-ui-content')); + const formElement = document.getElementById(id); + const subMain = formElement.querySelector(formElement.getAttribute('data-ui-content')); const newEle = subMain.getElementsByTagName('template')[0].content.cloneNode(true); // set internal value @@ -421,7 +422,8 @@ export class Form { const self = this; createForm.addEventListener('click', function () { - const subMain = document.getElementById(id).querySelector(document.getElementById(id).getAttribute('data-ui-content')); + const formElement = document.getElementById(id); + const subMain = formElement.querySelector(formElement.getAttribute('data-ui-content')); const newEle = subMain.getElementsByTagName('template')[1].content.cloneNode(true); const eleId = 'f' + Math.random().toString(36).substring(7); // todo: check if random id doesn't already exist @@ -466,21 +468,41 @@ export class Form { const self = this; update.addEventListener('click', function () { - const parent = this.closest(document.getElementById(id).getAttribute('data-ui-element')); - const values = parent.querySelectorAll('[data-tpl-value]'); - const text = parent.querySelectorAll('[data-tpl-text]'); - const subMain = parent.parentNode; + const formElement = document.getElementById(id); + const parents = []; + const selectors = formElement.getAttribute('data-ui-element').split(','), + selectorLength = selectors.length; - parent.style = "display: none"; // todo: replace with class instead of inline style + const subMain = formElement.querySelector( + formElement.getAttribute('data-ui-content') + ); - const newEle = subMain.getElementsByTagName('template')[1].content.cloneNode(true); - const eleId = 'f' + Math.random().toString(36).substring(7); - // todo: don't use random id use actual row id for data which needs to be updated + let values = []; + let text = []; + const newEle = []; - // root element is form even if it has a different tag than