bug fixes and template adjustments

This commit is contained in:
Dennis Eichhorn 2021-07-31 17:20:50 +02:00
parent c8a180fa8a
commit 15db183a81
6 changed files with 17 additions and 73 deletions

View File

@ -299,63 +299,7 @@ export class Table
{ {
filtering.addEventListener('click', function (event) 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);
}); });
}; };

View File

@ -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. // @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. // The fragment is ignored in such a case.
const parsed = HttpUri.parseUrl(url); const parsed = HttpUri.parseUrl(url);
const pars = []; const pars = [];
if (url.includes('?')) { if (url.includes('?')) {
// unique queries // unique queries

View File

@ -22,7 +22,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.trim = function(str, char = ' ') jsOMS.trim = function (str, char = ' ')
{ {
return jsOMS.ltrim(jsOMS.rtrim(str, char), char); return jsOMS.ltrim(jsOMS.rtrim(str, char), char);
}; };
@ -37,7 +37,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.rtrim = function(str, char = ' ') jsOMS.rtrim = function (str, char = ' ')
{ {
return str.replace(new RegExp("[" + char + "]*$"), ''); return str.replace(new RegExp("[" + char + "]*$"), '');
}; };
@ -52,7 +52,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.ltrim = function(str, char = ' ') jsOMS.ltrim = function (str, char = ' ')
{ {
return str.replace(new RegExp("^[" + char + "]*"), ''); return str.replace(new RegExp("^[" + char + "]*"), '');
}; };
@ -73,7 +73,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.htmlspecialchars_encode = function(str) jsOMS.htmlspecialchars_encode = function (str)
{ {
let escaped = str; let escaped = str;
const length = jsOMS.htmlspecialchars.length; const length = jsOMS.htmlspecialchars.length;
@ -97,7 +97,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.htmlspecialchars_decode = function(str) jsOMS.htmlspecialchars_decode = function (str)
{ {
let decoded = str; let decoded = str;
const length = jsOMS.htmlspecialchars.length; const length = jsOMS.htmlspecialchars.length;
@ -141,7 +141,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.substr_count = function(str, substr) { jsOMS.substr_count = function (str, substr) {
str += ''; str += '';
substr += ''; substr += '';

View File

@ -24,7 +24,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.triggerEvent = function(element, eventName) jsOMS.triggerEvent = function (element, eventName)
{ {
if (document.createEvent) { if (document.createEvent) {
event = document.createEvent('HTMLEvents'); event = document.createEvent('HTMLEvents');
@ -52,7 +52,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.getArray = function(path, data, delim = '/') jsOMS.getArray = function (path, data, delim = '/')
{ {
const pathParts = jsOMS.ltrim(path, delim).split(delim); const pathParts = jsOMS.ltrim(path, delim).split(delim);
let current = data; let current = data;
@ -84,7 +84,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.trim = function(str, char = ' ') jsOMS.trim = function (str, char = ' ')
{ {
return jsOMS.ltrim(jsOMS.rtrim(str, char), char); return jsOMS.ltrim(jsOMS.rtrim(str, char), char);
}; };
@ -101,7 +101,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.rtrim = function(str, char = ' ') jsOMS.rtrim = function (str, char = ' ')
{ {
return str.replace(new RegExp("[" + char + "]*$"), ''); return str.replace(new RegExp("[" + char + "]*$"), '');
}; };
@ -118,7 +118,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.ltrim = function(str, char = ' ') jsOMS.ltrim = function (str, char = ' ')
{ {
return str.replace(new RegExp("^[" + char + "]*"), ''); return str.replace(new RegExp("^[" + char + "]*"), '');
}; };
@ -139,7 +139,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.htmlspecialchars_encode = function(str) jsOMS.htmlspecialchars_encode = function (str)
{ {
let escaped = str; let escaped = str;
const length = jsOMS.htmlspecialchars.length; const length = jsOMS.htmlspecialchars.length;
@ -163,7 +163,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.htmlspecialchars_decode = function(str) jsOMS.htmlspecialchars_decode = function (str)
{ {
let decoded = str; let decoded = str;
const length = jsOMS.htmlspecialchars.length; const length = jsOMS.htmlspecialchars.length;
@ -190,7 +190,7 @@
* *
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.substr_count = function(str, substr) { jsOMS.substr_count = function (str, substr) {
str += ''; str += '';
substr += ''; substr += '';

View File

@ -130,7 +130,7 @@ export class TableView
getFilter() getFilter()
{ {
return document.querySelectorAll( return document.querySelectorAll(
'#' + this.id + ' thead .filter' '#' + this.id + ' .filter'
); );
}; };

View File

@ -8,7 +8,7 @@
} }
], ],
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": ">=3.5", "squizlabs/php_codesniffer": ">=3.6",
"phpstan/phpstan": ">=0.12.18" "phpstan/phpstan": ">=0.12.18"
} }
} }