diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 25b4d20..fa2f4a2 100644 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -1,12 +1,12 @@ import { Logger } from '../../Log/Logger.js'; -import { FormView } from '../../Views/FormView.js'; +import { NotificationLevel } from '../../Message/Notification/NotificationLevel.js'; +import { NotificationMessage } from '../../Message/Notification/NotificationMessage.js'; +import { NotificationType } from '../../Message/Notification/NotificationType.js'; import { Request } from '../../Message/Request/Request.js'; import { RequestMethod } from '../../Message/Request/RequestMethod.js'; import { Response } from '../../Message/Response/Response.js'; import { ResponseType } from '../../Message/Response/ResponseType.js'; -import { NotificationMessage } from '../../Message/Notification/NotificationMessage.js'; -import { NotificationLevel } from '../../Message/Notification/NotificationLevel.js'; -import { NotificationType } from '../../Message/Notification/NotificationType.js'; +import { FormView } from '../../Views/FormView.js'; /** * Form manager class. @@ -152,10 +152,22 @@ export class Form { this.bindAddInline(addable[i], id); } + const save = this.forms[id].getSave(); + length = save === null ? 0 : save.length; + for (let i = 0; i < length; ++i) { + this.bindSaveInline(save[i], id); + } + if (document.getElementById(id).getAttribute('data-ui-form') !== null) { this.bindAddExternal(id); } + const cancel = this.forms[id].getCancel(); + length = cancel === null ? 0 : cancel.length; + for (let i = 0; i < length; ++i) { + this.bindCancelInline(cancel[i], id); + } + const update = this.forms[id].getUpdate(); length = update === null ? 0 : update.length; for (let i = 0; i < length; ++i) { @@ -505,25 +517,25 @@ export class Form { values = values.concat(Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-value]'))); text = text.concat(Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-text]'))); - parents[i].style = 'display: none'; // todo: replace with class instead of inline style + jsOMS.addClass(parents[i], 'hidden'); newEle.push(subMain.getElementsByTagName('template')[selectorLength + i].content.cloneNode(true)); - // todo: don't use random id use actual row id for data which needs to be updated - const eleId = 'f' + Math.random().toString(36).substring(7); + if (newEle[i].firstElementChild.id === null) { + // todo: don't use random id use actual row id for data which needs to be updated + const eleId = 'f' + Math.random().toString(36).substring(7); - // root element is form even if it has a different tag than