From a038d97a36d33e8aa1f2a42384b77689fbdb96a5 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 11 Oct 2024 19:17:41 +0000 Subject: [PATCH] bug fixes --- Autoloader.js | 4 ++-- Message/Notification/App/AppNotification.js | 5 ++++- UI/Component/Form.js | 8 ++++++-- UI/Component/SmartTextInput.js | 14 +++++++++++--- UI/Component/Table.js | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Autoloader.js b/Autoloader.js index c00c347..65d4d32 100755 --- a/Autoloader.js +++ b/Autoloader.js @@ -3,7 +3,7 @@ import { AssetManager } from './Asset/AssetManager.js'; /** * Autoloader. * - * The autoloader is responsible for defining namespaces and dynamically loading javascript + * The autoloader is responsible for defining namespaces and dynamically loading js * files that are not yet included. The intention is to provide a similar functionality as * include, import etc. Contrary to it's name the autoloader is not able to truly autoload * referenced classes. @@ -55,7 +55,7 @@ Autoloader.defineNamespace = function (namespace) }; /** - * Collect all loaded javascript files + * Collect all loaded JS files * * @return {void} * diff --git a/Message/Notification/App/AppNotification.js b/Message/Notification/App/AppNotification.js index 3c52786..4424fb2 100755 --- a/Message/Notification/App/AppNotification.js +++ b/Message/Notification/App/AppNotification.js @@ -108,7 +108,10 @@ export class AppNotification const logs = document.getElementsByClassName('log-msg'); const lastElementAdded = logs[logs.length - 1]; - window.navigator.vibrate(msg.vibrate ? 200 : 0); + + if (typeof window.navigator.vibrate !== 'undefined') { + window.navigator.vibrate(msg.vibrate ? 200 : 0); + } if (msg.isSticky) { return; diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 9e8527a..d708ab7 100755 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -1207,7 +1207,11 @@ export class Form let statusCode = null; let responseData = null; - if (xhr.getResponseHeader('content-type').includes('application/octet-stream')) { + const contentType = xhr.getResponseHeader('content-type'); + + if (contentType !== null + && contentType.includes('application/octet-stream') + ) { responseData = new Blob([xhr.response], { type: 'application/octet-stream' }); const doc = document.createElement('a'); doc.style = 'display: none'; @@ -1231,7 +1235,7 @@ export class Form doc.click(); window.URL.revokeObjectURL(url); document.body.removeChild(doc); - } else if (xhr.getResponseHeader('content-type').includes('text/html')) { + } else if (contentType.includes('text/html')) { // window.location = UriFactory.build(uri); responseData = xhr.response; diff --git a/UI/Component/SmartTextInput.js b/UI/Component/SmartTextInput.js index 9c45dc7..5178554 100644 --- a/UI/Component/SmartTextInput.js +++ b/UI/Component/SmartTextInput.js @@ -108,7 +108,7 @@ export class SmartTextInput } }); - // @bug This is never getting run?! + // @bug This never runs?! this.dataList.addEventListener('keydown', function (e) { jsOMS.preventAll(e); @@ -136,7 +136,11 @@ export class SmartTextInput this.dataList.addEventListener('click', function (e) { self.clearDataListSelection(self); - self.addToResultList(self, self.elementContainer === '' ? e.target : e.target.closest('.' + self.elementContainer)); + self.addToResultList( + self, self.elementContainer === '' + ? e.target + : e.target.closest('.' + self.elementContainer) + ); self.dataList.classList.add('vh'); }); }; @@ -280,13 +284,17 @@ export class SmartTextInput * This can add the selected dropdown elements to a table, badge list etc. depending on the template structure. * * @param {SmartTextInput} self This reference - * @param {Element} e Element + * @param {Element} e Element * * @return {void} * * @since 1.0.0 */ addToResultList (self, e) { + // @bug There is sometimes a situation when text is in the input field and you then want to switch + // to a different drop down element. When you click on that drop down element, it doesn't fill into the input text + // you then have to click it over and over until it works + // https://github.com/Karaka-Management/jsOMS/issues/142 const data = JSON.parse(e.getAttribute('data-data')); if (self.inputField.getAttribute('data-autocomplete') === 'true') { diff --git a/UI/Component/Table.js b/UI/Component/Table.js index b166e70..db99d37 100755 --- a/UI/Component/Table.js +++ b/UI/Component/Table.js @@ -154,7 +154,7 @@ export class Table /** * @todo Karaka/jsOMS#90 * Implement export - * Either create download in javascript from this data or make round trip to server who then sends the data. + * Either create download in JS from this data or make round trip to server who then sends the data. * The export should be possible (if available) in json, csv, excel, word, pdf, ... * If no endpoint is specified or reachable the client side should create a json or csv export. */