Skip to content

Commit

Permalink
form bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed Sep 19, 2023
1 parent 7762df4 commit e126150
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
37 changes: 26 additions & 11 deletions UI/Component/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,16 @@ export class Form
jsOMS.preventAll(event);

const remove = self.forms[id].getRemove()[elementIndex];
const callback = function (response, xhr) {
const callback = function (xhr) {
if (xhr.status !== 200) {
self.app.notifyManager.send(
new NotificationMessage(
NotificationLevel.ERROR,
'Failure',
'Some failure happened'
), NotificationType.APP_NOTIFICATION
);

return;
}

Expand All @@ -213,24 +221,31 @@ export class Form
};

/** @var {Element} formElement Form element */
const formElement = self.forms[id].getFormElement();
const formElement = document.getElementById(id).getAttribute('action') !== null || document.getElementById(id).getAttribute('data-action') !== null
? self.forms[id].getFormElement()
: (
document.getElementById(id).getAttribute('data-update-form') !== null
? self.forms[document.getElementById(id).getAttribute('data-update-form')].getFormElement()
: (
document.getElementById(id).getAttribute('data-delete-form') !== null
? self.forms[document.getElementById(id).getAttribute('data-delete-form')].getFormElement()
: null
)
);

// Perform the element deletion.
// If the form has a remote endpoint this is called in advance
if (formElement !== null
&& ((formElement.tagName.toLowerCase() !== 'form' && formElement.getAttribute('data-method') !== null)
|| (formElement.tagName.toLowerCase() === 'form' && formElement.getAttribute('method') !== 'NONE'))
) {
if (formElement !== null) {
const deleteRequest = new Request(
formElement.hasAttribute('data-method-delete')
? formElement.getAttribute('data-method-delete')
formElement.hasAttribute('data-action-delete')
? formElement.getAttribute('data-action-delete')
: (formElement.tagName.toLowerCase() !== 'form'
? formElement.getAttribute('data-method')
: formElement.getAttribute('method')
? formElement.getAttribute('data-action')
: formElement.getAttribute('action')
),
RequestMethod.DELETE
);
deleteRequest.setSuccess(callback);
deleteRequest.setResultCallback(0, callback);
deleteRequest.send();
} else {
callback();
Expand Down
5 changes: 5 additions & 0 deletions UI/Component/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ export class Tab
activateTabUri (e)
{
const fragmentString = window.location.href.includes('#') ? HttpUri.parseUrl(window.location.href).fragment : '';

if (fragmentString === null || typeof fragmentString === 'undefined') {
return;
}

const fragments = fragmentString.split('&');
const fragLength = fragments.length;

Expand Down

0 comments on commit e126150

Please sign in to comment.