Skip to content

Commit

Permalink
chore: custom implementation of filtering, due to bug in joq with nul…
Browse files Browse the repository at this point in the history
…ls / numbers
  • Loading branch information
jelmerveen committed Jul 3, 2024
1 parent f9e7039 commit e3bfbc1
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 45 deletions.
1 change: 0 additions & 1 deletion dist/flightkit-v0.0.5/flightkit.min.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1150,33 +1150,30 @@
this.contents.sort([]);
}

if (this.filter.length) {
const filters = [];

for (const property of this.columnOrder) {
filters.push({
propertyName: property,
value: this.filter,
operator: 'like',
type: 'or', /** optional, defaults to "and" **/
ignoreCase: true /** optional, defaults to "false" **/
});
}
this.contents.filter(filters);
}
else {
this.contents.filter([]);
}

const tableHead = this.createHead();
tableElement.append(tableHead);

if (this._templates['caption']) {
tableElement.append(this._createElement('caption'));
}

const data = this.contents.execute();
const tableBody = this.createBody(data);
const orderedData = this.contents.execute();
let filteredData = [];
if (this.filter.length) {
for (const data of orderedData) {
let valuesInData = Object.values(data).join(" ").toLowerCase();

if (valuesInData.includes(this.filter)) {
filteredData.push(data);
}
}
}
else {
filteredData = orderedData;
}


const tableBody = this.createBody(filteredData);
tableElement.append(tableBody);

if (this._templates['tfoot']) {
Expand Down
1 change: 1 addition & 0 deletions dist/flightkit-v0.0.6/flightkit.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/cdn/ibiss-v0.0.6/avian.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/cdn/ibiss-v0.0.6/flightkit.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/cdn/ibiss-v0.0.6/htmx-ibiss-ui.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/cdn/ibiss-v0.0.6/rocket.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/js/flightkit.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions documentation/public/cdn/ibiss-v0.0.6/avian.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions documentation/public/cdn/ibiss-v0.0.6/flightkit.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions documentation/public/cdn/ibiss-v0.0.6/htmx-ibiss-ui.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions documentation/public/cdn/ibiss-v0.0.6/rocket.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion documentation/public/js/flightkit.min.js

Large diffs are not rendered by default.

37 changes: 17 additions & 20 deletions flightkit/components/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,33 +176,30 @@ export class FlightkitTable extends HTMLElement {
this.contents.sort([]);
}

if (this.filter.length) {
const filters = [];

for (const property of this.columnOrder) {
filters.push({
propertyName: property,
value: this.filter,
operator: 'like',
type: 'or', /** optional, defaults to "and" **/
ignoreCase: true /** optional, defaults to "false" **/
});
}
this.contents.filter(filters);
}
else {
this.contents.filter([]);
}

const tableHead = this.createHead();
tableElement.append(tableHead);

if (this._templates['caption']) {
tableElement.append(this._createElement('caption'));
}

const data = this.contents.execute();
const tableBody = this.createBody(data);
const orderedData = this.contents.execute();
let filteredData = []
if (this.filter.length) {
for (const data of orderedData) {
let valuesInData = Object.values(data).join(" ").toLowerCase();

if (valuesInData.includes(this.filter)) {
filteredData.push(data)
}
}
}
else {
filteredData = orderedData
}


const tableBody = this.createBody(filteredData);
tableElement.append(tableBody);

if (this._templates['tfoot']) {
Expand Down
21 changes: 21 additions & 0 deletions flightkit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
</head>

<body class="row gap-5 p-3">
<div>
<input type="text" id="table-filter" placeholder="filter">
<flk-table id="db-table"></flk-table>
</div>

<flk-tree-nav id="tree-nav" e-tree-click="clicky"></flk-tree-nav>
<div>

Expand Down Expand Up @@ -69,6 +74,22 @@
databasesNav.setContents(window.databaseSet);

databasesNav.init();
const dbTable = document.getElementById("db-table")
dbTable.setContents(window.databaseSet.database1.table1);
dbTable.init();

let timer;
document.getElementById('table-filter').addEventListener('keyup', (e) => {
if (timer) {
clearTimeout(timer)
}

timer = setTimeout(() => {
dbTable.filter = e.target.value;
dbTable.init();
})

})
};
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@pennions/ibiss",
"version": "0.0.5",
"version": "0.0.6",
"avian_version": "0.0.2",
"flightkit_version": "0.0.5",
"flightkit_version": "0.0.6",
"htmx_plugin_version": "0.0.1",
"rocketjs_version": "0.0.1",
"description": "Frontend library of Pennions",
Expand Down

0 comments on commit e3bfbc1

Please sign in to comment.