diff --git a/UI/Component/Table.js b/UI/Component/Table.js index e0994d9..cb6a37a 100644 --- a/UI/Component/Table.js +++ b/UI/Component/Table.js @@ -299,63 +299,7 @@ export class Table { filtering.addEventListener('click', function (event) { - jsOMS.preventAll(event); - const tpl = document.getElementById('table-filter-tpl'); - - if (tpl === null || document.getElementById(tpl.content.firstElementChild.id) !== null) { - return; - } - - const posY = event.pageY + document.body.scrollTop + document.documentElement.scrollTop + tpl.parentNode.scrollTop - tpl.parentNode.getBoundingClientRect().top; - const posX = event.pageX + document.body.scrollLeft + document.documentElement.scrollLeft + tpl.parentNode.scrollLeft - tpl.parentNode.getBoundingClientRect().left; - - const output = document.importNode(tpl.content, true); - output.firstElementChild.setAttribute('style', 'position: absolute; top: ' + posY + 'px; left: ' + posX + 'px;') - output.firstElementChild.setAttribute('data-ui', this.closest('table').id); - output.firstElementChild.setAttribute('data-ui-column', this.closest('td').cellIndex); - - // todo: set existing filtering option in ui here - - output.firstElementChild.querySelectorAll('button[type="submit"], input[type="submit"]')[0].addEventListener('click', function (event) { - jsOMS.preventAll(event); - - const input = document.getElementById('table-filter').querySelectorAll('input, select'); - const length = input.length; - - let filter = []; - - for (let i = 0; i < length; ++i) { - filter.push(input[i].value); - } - - const table = document.getElementById(document.getElementById('table-filter').getAttribute('data-ui')); - - table.querySelectorAll('thead td')[ - document.getElementById('table-filter').getAttribute('data-ui-column') - ].setAttribute('data-filter', JSON.stringify(filter)); - - /** - * @todo Orange-Management/jsOMS#88 - * If a filter is active it should be highlighted/marked in the table - * - * @todo Orange-Management/jsOMS#89 - * Filter locally and if a data-src is defined a remote filtering endpoint should be used. - */ - - document.getElementById('table-filter').parentNode.removeChild(document.getElementById('table-filter')); - - if (table.getAttribute('data-src') !== null) { - Table.getRemoteData(table); - return; - } - }); - - output.firstElementChild.querySelectorAll('button[type="reset"], input[type="reset"]')[0].addEventListener('click', function (event) { - document.getElementById('table-filter').parentNode.removeChild(document.getElementById('table-filter')); - }); - - tpl.parentNode.appendChild(output); }); }; diff --git a/Uri/UriFactory.js b/Uri/UriFactory.js index fe85a84..1232e3a 100644 --- a/Uri/UriFactory.js +++ b/Uri/UriFactory.js @@ -129,7 +129,7 @@ export class UriFactory // @todo: there is a bug for uris which have a parameter without a value and a fragment e.g. ?debug#something. // The fragment is ignored in such a case. const parsed = HttpUri.parseUrl(url); - const pars = []; + const pars = []; if (url.includes('?')) { // unique queries diff --git a/Utils/StringUtils.js b/Utils/StringUtils.js index d7a73b0..881c8c5 100644 --- a/Utils/StringUtils.js +++ b/Utils/StringUtils.js @@ -22,7 +22,7 @@ * * @since 1.0.0 */ - jsOMS.trim = function(str, char = ' ') + jsOMS.trim = function (str, char = ' ') { return jsOMS.ltrim(jsOMS.rtrim(str, char), char); }; @@ -37,7 +37,7 @@ * * @since 1.0.0 */ - jsOMS.rtrim = function(str, char = ' ') + jsOMS.rtrim = function (str, char = ' ') { return str.replace(new RegExp("[" + char + "]*$"), ''); }; @@ -52,7 +52,7 @@ * * @since 1.0.0 */ - jsOMS.ltrim = function(str, char = ' ') + jsOMS.ltrim = function (str, char = ' ') { return str.replace(new RegExp("^[" + char + "]*"), ''); }; @@ -73,7 +73,7 @@ * * @since 1.0.0 */ - jsOMS.htmlspecialchars_encode = function(str) + jsOMS.htmlspecialchars_encode = function (str) { let escaped = str; const length = jsOMS.htmlspecialchars.length; @@ -97,7 +97,7 @@ * * @since 1.0.0 */ - jsOMS.htmlspecialchars_decode = function(str) + jsOMS.htmlspecialchars_decode = function (str) { let decoded = str; const length = jsOMS.htmlspecialchars.length; @@ -141,7 +141,7 @@ * * @since 1.0.0 */ - jsOMS.substr_count = function(str, substr) { + jsOMS.substr_count = function (str, substr) { str += ''; substr += ''; diff --git a/Utils/oLib.js b/Utils/oLib.js index 91b84ba..8e1bdc0 100644 --- a/Utils/oLib.js +++ b/Utils/oLib.js @@ -24,7 +24,7 @@ * * @since 1.0.0 */ - jsOMS.triggerEvent = function(element, eventName) + jsOMS.triggerEvent = function (element, eventName) { if (document.createEvent) { event = document.createEvent('HTMLEvents'); @@ -52,7 +52,7 @@ * * @since 1.0.0 */ - jsOMS.getArray = function(path, data, delim = '/') + jsOMS.getArray = function (path, data, delim = '/') { const pathParts = jsOMS.ltrim(path, delim).split(delim); let current = data; @@ -84,7 +84,7 @@ * * @since 1.0.0 */ - jsOMS.trim = function(str, char = ' ') + jsOMS.trim = function (str, char = ' ') { return jsOMS.ltrim(jsOMS.rtrim(str, char), char); }; @@ -101,7 +101,7 @@ * * @since 1.0.0 */ - jsOMS.rtrim = function(str, char = ' ') + jsOMS.rtrim = function (str, char = ' ') { return str.replace(new RegExp("[" + char + "]*$"), ''); }; @@ -118,7 +118,7 @@ * * @since 1.0.0 */ - jsOMS.ltrim = function(str, char = ' ') + jsOMS.ltrim = function (str, char = ' ') { return str.replace(new RegExp("^[" + char + "]*"), ''); }; @@ -139,7 +139,7 @@ * * @since 1.0.0 */ - jsOMS.htmlspecialchars_encode = function(str) + jsOMS.htmlspecialchars_encode = function (str) { let escaped = str; const length = jsOMS.htmlspecialchars.length; @@ -163,7 +163,7 @@ * * @since 1.0.0 */ - jsOMS.htmlspecialchars_decode = function(str) + jsOMS.htmlspecialchars_decode = function (str) { let decoded = str; const length = jsOMS.htmlspecialchars.length; @@ -190,7 +190,7 @@ * * @since 1.0.0 */ - jsOMS.substr_count = function(str, substr) { + jsOMS.substr_count = function (str, substr) { str += ''; substr += ''; diff --git a/Views/TableView.js b/Views/TableView.js index 52227a2..895f28d 100644 --- a/Views/TableView.js +++ b/Views/TableView.js @@ -130,7 +130,7 @@ export class TableView getFilter() { return document.querySelectorAll( - '#' + this.id + ' thead .filter' + '#' + this.id + ' .filter' ); }; diff --git a/composer.json b/composer.json index eefd947..1417b9a 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ } ], "require-dev": { - "squizlabs/php_codesniffer": ">=3.5", + "squizlabs/php_codesniffer": ">=3.6", "phpstan/phpstan": ">=0.12.18" } }