mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 17:58:41 +00:00
make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ...
This commit is contained in:
parent
ee62ccd539
commit
bd6c58ddff
|
|
@ -199,6 +199,8 @@ export class Form
|
||||||
if ((elementIndex = Array.from(self.forms[id].getRemove()).indexOf(event.target)) !== -1) {
|
if ((elementIndex = Array.from(self.forms[id].getRemove()).indexOf(event.target)) !== -1) {
|
||||||
// handle remove
|
// handle remove
|
||||||
|
|
||||||
|
jsOMS.preventAll(event);
|
||||||
|
|
||||||
const remove = self.forms[id].getRemove()[elementIndex];
|
const remove = self.forms[id].getRemove()[elementIndex];
|
||||||
const callback = function () {
|
const callback = function () {
|
||||||
/**
|
/**
|
||||||
|
|
@ -236,6 +238,8 @@ export class Form
|
||||||
} else if ((elementIndex = Array.from(self.forms[id].getAdd()).indexOf(event.target)) !== -1) {
|
} else if ((elementIndex = Array.from(self.forms[id].getAdd()).indexOf(event.target)) !== -1) {
|
||||||
// handle add
|
// handle add
|
||||||
|
|
||||||
|
jsOMS.preventAll(event);
|
||||||
|
|
||||||
if (!self.forms[id].isValid()) {
|
if (!self.forms[id].isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -357,12 +361,17 @@ export class Form
|
||||||
Form.setDataFromRemoteUrls(remoteUrls);
|
Form.setDataFromRemoteUrls(remoteUrls);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// submit to api
|
||||||
|
self.submit(self.forms[id], self.forms[id].getAdd()[elementIndex]);
|
||||||
|
|
||||||
// reset the form after adding an element
|
// reset the form after adding an element
|
||||||
self.forms[id].resetValues();
|
self.forms[id].resetValues();
|
||||||
}
|
}
|
||||||
} else if ((elementIndex = Array.from(self.forms[id].getSave()).indexOf(event.target)) !== -1) {
|
} else if ((elementIndex = Array.from(self.forms[id].getSave()).indexOf(event.target)) !== -1) {
|
||||||
// handle save button
|
// handle save button
|
||||||
|
|
||||||
|
jsOMS.preventAll(event);
|
||||||
|
|
||||||
const mainForm = document.querySelector('[data-update-form="' + id + '"');
|
const mainForm = document.querySelector('[data-update-form="' + id + '"');
|
||||||
if (mainForm === null) {
|
if (mainForm === null) {
|
||||||
// handle inline save
|
// handle inline save
|
||||||
|
|
@ -618,7 +627,7 @@ export class Form
|
||||||
// update text data in form (overwrite text)
|
// update text data in form (overwrite text)
|
||||||
Form.setDataInElement('text', updateElements, texts, remoteUrls);
|
Form.setDataInElement('text', updateElements, texts, remoteUrls);
|
||||||
|
|
||||||
// todo bind failure here, if failure do cancel, if success to remove edit template
|
// @todo: bind failure here, if failure do cancel, if success to remove edit template
|
||||||
self.forms[externalFormId].setSuccess(function () {
|
self.forms[externalFormId].setSuccess(function () {
|
||||||
// overwrite old values from remote response
|
// overwrite old values from remote response
|
||||||
Form.setDataFromRemoteUrls(remoteUrls);
|
Form.setDataFromRemoteUrls(remoteUrls);
|
||||||
|
|
@ -627,6 +636,9 @@ export class Form
|
||||||
// clear element id after saving
|
// clear element id after saving
|
||||||
externalFormElement.setAttribute('data-id', '');
|
externalFormElement.setAttribute('data-id', '');
|
||||||
|
|
||||||
|
// submit to api
|
||||||
|
self.submit(self.forms[externalFormId], self.forms[externalFormId].getSave()[elementIndex]);
|
||||||
|
|
||||||
// reset form values to default values after performing the update
|
// reset form values to default values after performing the update
|
||||||
self.forms[externalFormId].resetValues();
|
self.forms[externalFormId].resetValues();
|
||||||
|
|
||||||
|
|
@ -654,6 +666,8 @@ export class Form
|
||||||
// handle cancel
|
// handle cancel
|
||||||
// @todo currently only handling update cancel, what about add cancel?
|
// @todo currently only handling update cancel, what about add cancel?
|
||||||
|
|
||||||
|
jsOMS.preventAll(event);
|
||||||
|
|
||||||
const ele = document.getElementById(id);
|
const ele = document.getElementById(id);
|
||||||
if (ele.getAttribute('data-update-form') === null && ele.tagName.toLowerCase() !== 'form') {
|
if (ele.getAttribute('data-update-form') === null && ele.tagName.toLowerCase() !== 'form') {
|
||||||
// handle inline cancel
|
// handle inline cancel
|
||||||
|
|
@ -713,6 +727,7 @@ export class Form
|
||||||
} else if ((elementIndex = Array.from(self.forms[id].getUpdate()).indexOf(event.target)) !== -1) {
|
} else if ((elementIndex = Array.from(self.forms[id].getUpdate()).indexOf(event.target)) !== -1) {
|
||||||
// handle update
|
// handle update
|
||||||
// this doesn't handle setting new values but populating the update form
|
// this doesn't handle setting new values but populating the update form
|
||||||
|
jsOMS.preventAll(event);
|
||||||
|
|
||||||
if (document.getElementById(id).getAttribute('data-update-form') === null) {
|
if (document.getElementById(id).getAttribute('data-update-form') === null) {
|
||||||
// handle inline update
|
// handle inline update
|
||||||
|
|
@ -920,16 +935,20 @@ export class Form
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
let action = null;
|
let action = null;
|
||||||
|
|
||||||
if (button !== null) {
|
if (button !== null) {
|
||||||
action = button.getAttribute('formaction');
|
action = button.getAttribute('formaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let method = null;
|
||||||
|
if (button !== null) {
|
||||||
|
method = button.getAttribute('formmethod');
|
||||||
|
}
|
||||||
|
|
||||||
// Register normal form behavior
|
// Register normal form behavior
|
||||||
if (!this.app.eventManager.isAttached(form.getId())) {
|
if (!this.app.eventManager.isAttached(form.getId())) {
|
||||||
this.app.eventManager.attach(form.getId(), function ()
|
this.app.eventManager.attach(form.getId(), function ()
|
||||||
{
|
{
|
||||||
self.submitForm(form, action, container);
|
self.submitForm(form, action, method, container);
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -972,7 +991,7 @@ export class Form
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
submitForm (form, action = null, container = null)
|
submitForm (form, action = null, method = null, container = null)
|
||||||
{
|
{
|
||||||
const data = form.getData(container);
|
const data = form.getData(container);
|
||||||
|
|
||||||
|
|
@ -989,6 +1008,7 @@ export class Form
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avoid multiple submits
|
||||||
if (form.getMethod() !== RequestMethod.GET
|
if (form.getMethod() !== RequestMethod.GET
|
||||||
&& Math.abs(Date.now() - form.getLastSubmit()) < 500
|
&& Math.abs(Date.now() - form.getLastSubmit()) < 500
|
||||||
) {
|
) {
|
||||||
|
|
@ -1006,7 +1026,7 @@ export class Form
|
||||||
request.setData(data);
|
request.setData(data);
|
||||||
request.setType(RequestType.FORM_DATA); // @todo: consider to allow different request type
|
request.setType(RequestType.FORM_DATA); // @todo: consider to allow different request type
|
||||||
request.setUri(action !== null ? action : form.getAction());
|
request.setUri(action !== null ? action : form.getAction());
|
||||||
request.setMethod(form.getMethod());
|
request.setMethod(method !== null ? method : form.getMethod());
|
||||||
request.setSuccess(function (xhr)
|
request.setSuccess(function (xhr)
|
||||||
{
|
{
|
||||||
window.omsApp.logger.log(xhr.response);
|
window.omsApp.logger.log(xhr.response);
|
||||||
|
|
|
||||||
|
|
@ -111,15 +111,13 @@ export class GeneralUI
|
||||||
) {
|
) {
|
||||||
window.open(UriFactory.build(uri), '_blank');
|
window.open(UriFactory.build(uri), '_blank');
|
||||||
} else if (this.getAttribute('data-redirect') !== null) {
|
} else if (this.getAttribute('data-redirect') !== null) {
|
||||||
uri = window.omsApp.request.getRootPath() + uri;
|
uri = jsOMS.rtrim(window.omsApp.request.getRootPath(), '/') + '/' + jsOMS.ltrim(uri, '/');
|
||||||
window.location.assign(uri);
|
window.location.href = uri;
|
||||||
} else {
|
} else {
|
||||||
// window.location = UriFactory.build(uri);
|
// window.location = UriFactory.build(uri);
|
||||||
// @todo : consider to implement the line above again. why was it removed?
|
// @todo : consider to implement the line above again. why was it removed?
|
||||||
uri = window.omsApp.request.getRootPath() + uri;
|
uri = jsOMS.rtrim(window.omsApp.request.getRootPath(), '/') + '/' + jsOMS.ltrim(uri, '/');
|
||||||
|
window.location.href = uri;
|
||||||
window.location.assign(uri);
|
|
||||||
console.log('test');
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@todo: Commented out until ObserverMutation is implemented
|
@todo: Commented out until ObserverMutation is implemented
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user