Skip to content

Commit

Permalink
Merge pull request #38 from pennions/feat/flightkit-table-hide-rows
Browse files Browse the repository at this point in the history
feat(flightkit): Table now is able to hide rows based on values in a column
  • Loading branch information
jelmerveen authored Oct 10, 2024
2 parents 66546b4 + 931fad2 commit 1401aed
Show file tree
Hide file tree
Showing 44 changed files with 121 additions and 56 deletions.
1 change: 0 additions & 1 deletion dist/flightkit-v0.0.18/flightkit.min.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,11 @@
_selectedIds = new Set(); /** used to sync selections */
_templates = {}; /** html templates to use for columns and caption/tfoot */
_templateClasses = {};
_hideValues = [];
_hideColumn = "";

static get observedAttributes() {
return ['contents', 'columns', 'order', 'filter', 'selection-property', 'templates', 'annotations'];
return ['contents', 'columns', 'order', 'filter', 'selection-property', 'templates', 'annotations', 'hide'];
};

get columnOrder() {
Expand Down Expand Up @@ -582,6 +584,7 @@
this.setColumnOrder(this.getAttribute('columns'));
this.filter = this.getAttribute('filter') || '';
this.setAnnotations(this.getAttribute('annotations'));
this.setHiddenRows(this.getAttribute('hide'));

const presetOrder = this.getAttribute('order');
if (presetOrder) {
Expand Down Expand Up @@ -639,6 +642,10 @@
this.setAnnotations(newValue);
break;
}
case "hide": {
this.setHiddenRows(newValue);
break;
}
}
/** in Vue3 this is not triggered. You need to set a :key property and handle that */
this.createHtml();
Expand Down Expand Up @@ -817,6 +824,19 @@
}
}

/** signature: column|value1,value2,value3 */
setHiddenRows(hideRows) {
if (hideRows) {
const parts = hideRows.split("|");
this._hideColumn = parts[0];
this._hideValues = parts[1].split(',');
}
else {
this._hideValues = [];
this._hideColumn = "";
}
}

analyzeData(value) {
/** reset */
this.properties = new Set();
Expand Down Expand Up @@ -1035,6 +1055,9 @@
createBody(data) {
const tableBody = document.createElement('tbody');
for (const rowContent of data) {
/** check if we should hide this row */
if (rowContent[this._hideColumn] && this._hideValues.includes(rowContent[this._hideColumn].toString())) continue;

const tableRow = this.createRow(rowContent);
tableBody.append(tableRow);
}
Expand Down
1 change: 1 addition & 0 deletions dist/flightkit-v0.0.19/flightkit.min.js

Large diffs are not rendered by default.

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

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

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

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

Loading

0 comments on commit 1401aed

Please sign in to comment.