form bug fixes

This commit is contained in:
Dennis Eichhorn 2022-05-15 22:20:29 +02:00
parent 6c87d85a6d
commit 5252b76ef3
5 changed files with 31 additions and 9 deletions

View File

@ -320,9 +320,12 @@ export class Request
this.type = type;
this.requestHeader['Content-Type'] = this.setContentTypeBasedOnType(this.type);
/*
@todo: why was i doing this?
if (this.type === RequestType.FORM_DATA) {
delete this.requestHeader['Content-Type'];
}
*/
};
/**
@ -374,7 +377,16 @@ export class Request
const self = this;
if (this.xhr.readyState !== 1) {
this.xhr.open(this.method, UriFactory.build(this.uri));
if (this.type === RequestType.FORM_DATA) {
let url = this.uri;
for (let pair of this.data.entries()) {
url += '&' + pair[0] + '=' + pair[1];
}
this.xhr.open(this.method, UriFactory.build(url));
} else {
this.xhr.open(this.method, UriFactory.build(this.uri));
}
for (const p in this.requestHeader) {
if (Object.prototype.hasOwnProperty.call(this.requestHeader, p) && this.requestHeader[p] !== '') {
@ -409,7 +421,11 @@ export class Request
} else if (this.type === RequestType.URL_ENCODE) {
this.xhr.send(this.queryfy(this.data));
} else if (this.type === RequestType.FORM_DATA) {
this.xhr.send(this.data);
if (this.method === RequestMethod.GET) {
this.xhr.send();
} else {
this.xhr.send(this.data);
}
}
};
};

View File

@ -796,7 +796,9 @@ export class Form
// define remote response behavior
self.forms[externalFormId].setSuccess(function (response) {
if (response.get('status') !== 'undefined' && response.get('status') !== NotificationLevel.HIDDEN) {
if (response.get('status') !== 'undefined'
&& response.get('status') !== NotificationLevel.HIDDEN
) {
self.app.notifyManager.send(
new NotificationMessage(response.get('status'), response.get('title'), response.get('message')), NotificationType.APP_NOTIFICATION
);
@ -810,7 +812,9 @@ export class Form
Form.setDataFromRemoteUrls(remoteUrls);
});
}
} else if ((elementIndex = Array.from(self.forms[id].getSubmit()).indexOf(event.target)) !== -1) {
} else if ((elementIndex = Array.from(self.forms[id].getSubmit()).indexOf(event.target)) !== -1
|| (elementIndex = Array.from(self.forms[id].getSubmit()).indexOf(event.target.parentNode)) !== -1
) {
jsOMS.preventAll(event);
self.submit(self.forms[id], self.forms[id].getSubmit()[elementIndex]);
}

View File

@ -293,7 +293,7 @@ export class Table
{
sorting.addEventListener('click', function (event)
{
if (this.firstElementChild.tagName.toLowerCase() === 'a') {
if (this.firstElementChild === null || this.firstElementChild.tagName.toLowerCase() === 'a') {
// page is getting reloaded
return;
}

View File

@ -81,9 +81,8 @@ export class GeneralUI
if (input !== null) {
input.click();
return;
}
return;
}
jsOMS.preventAll(event);
@ -92,7 +91,10 @@ export class GeneralUI
let uri = this.getAttribute('data-href');
uri = uri === null ? this.getAttribute('href') : uri;
if (this.getAttribute('target') === '_blank' || this.getAttribute(['data-target']) === '_blank' || event.button === 1) {
if (this.getAttribute('target') === '_blank'
|| this.getAttribute(['data-target']) === '_blank'
|| event.button === 1
) {
window.open(UriFactory.build(uri), '_blank');
} else {
window.location = UriFactory.build(uri);

View File

@ -203,7 +203,7 @@ export class UriFactory
}
}
let parsed = uri.replace(new RegExp('\{[\/#\?%@\.\$\!][a-zA-Z0-9\-\#\.]*\}', 'g'), function (match) {
let parsed = uri.replace(new RegExp('\{[\/#\?%@\.\$\!][a-zA-Z0-9_\\-#\.]*\}', 'g'), function (match) {
match = match.substr(1, match.length - 2);
if (toMatch !== null && Object.prototype.hasOwnProperty.call(toMatch, match)) {