Skip to content

Commit

Permalink
Fix: Restored row ids
Browse files Browse the repository at this point in the history
  • Loading branch information
MauritsioRK committed Jul 10, 2020
1 parent 0151b3a commit 6ee1a3b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
8 changes: 6 additions & 2 deletions lib/public/components/Table/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ const content = (data, keys, params, model) => {

return h('tbody', data.map((entry) => {
const rowId = `row${entry[idKey]}`;
return h(`tr#${rowId}`, params(entry), Object.entries(keys)
.map(([key, value]) => row(value, entry[key], rowId, model)));
return h(`tr#${rowId}`, params(entry), Object.entries(keys).reduce((accumulator, [key, value]) => {
if (value.visible) {
accumulator.push(row(value, entry[key], rowId, model));
}
return accumulator;
}, []));
}));
};

Expand Down
11 changes: 7 additions & 4 deletions lib/public/components/Table/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ import { h } from '/js/src/index.js';
* @param {Object} keys The full collection of API keys and their corresponding header values
* @return {vnode} An array of rows containing all given header values with specific cell sizes
*/
const headers = (keys) => h('thead', h('tr', Object.values(keys).map((value) => {
const size = value.size || 'cell-m';
return h(`th.${size}`, { scope: 'col' }, value.name);
})));
const headers = (keys) => h('thead', h('tr', Object.values(keys).reduce((accumulator, value) => {
if (value.visible) {
const size = value.size || 'cell-m';
accumulator.push(h(`th.${size}`, { scope: 'col' }, value.name));
}
return accumulator;
}, [])));

export default headers;
24 changes: 4 additions & 20 deletions lib/public/components/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ import { h } from '/js/src/index.js';
import headers from './headers.js';
import content from './content.js';

/**
* Selectively removes the API keys based on their visibility value
* @param {Object} keys The full collection of API keys and their corresponding header values
* @returns {Object} A filtered collection of keys based on visibility
*/
const filterKeysByVisibility = (keys) => {
Object.entries(keys).forEach(([key, value]) => {
if (!value.visible) {
delete keys[key];
}
});
};

/**
* Renders the table
* @param {Array} data An object array, with every object representing a to be rendered row
Expand All @@ -36,12 +23,9 @@ const filterKeysByVisibility = (keys) => {
* @param {Object} model The global model object
* @returns {vnode} Return the total view of the table to rendered
*/
const table = (data, keys, params = () => null, model) => {
filterKeysByVisibility(keys);
return h('table.table.table-hover.shadow-level1', [
headers(keys),
content(data, keys, params, model),
]);
};
const table = (data, keys, params = () => null, model) => h('table.table.table-hover.shadow-level1', [
headers(keys),
content(data, keys, params, model),
]);

export default table;
5 changes: 5 additions & 0 deletions lib/public/views/Logs/ActiveColumns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import tagsFilter from '../../../components/Filters/tags.js';
* @return {Object} A collection of columns with parameters for the Log table
*/
const activeColumns = (model) => ({
id: {
name: 'Entry ID',
visible: false,
primary: true,
},
title: {
name: 'Title',
visible: true,
Expand Down

0 comments on commit 6ee1a3b

Please sign in to comment.