Skip to content

Commit

Permalink
Add scalarCol option for table view
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Mar 7, 2024
1 parent 1b05184 commit 4f90de5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Added basic support for `TypedArray`s and `Set` values in `struct`, `signature` and `table` views
- Added `'only'` value for `darkmode` option of `Widget` & `App`, which forces to use dark mode with no option for a user to switch to light mode
- Added `scalarCol` option for `table` view to display the row value as the first cell
- Modified the badge view to enable passing all options via config, in addition to data
- Fixed the highlighting of Jora assertions
- Fixed displaying supported syntaxes in view's showcase for `source` view
Expand Down
23 changes: 11 additions & 12 deletions src/views/table/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function(host) {
const isScalar = host.queryFn(isScalarAssertion);

host.view.define('table', function(el, config, data, context) {
let { cols, rowConfig, limit } = config;
let { cols, rowConfig, limit, scalarCol = false } = config;
let renderRowConfig;

if (isSet(data)) {
Expand Down Expand Up @@ -158,7 +158,6 @@ export default function(host) {
} else {
const colNames = new Set();
const colsMap = cols && typeof cols === 'object' ? cols : {};
let scalarCol = false;

cols = [];

Expand All @@ -180,16 +179,6 @@ export default function(host) {
}
}

if (scalarCol) {
cols.push({
header: '[value]',
view: 'table-cell',
sorting: '$ ascN',
scalarAsStruct: true,
colSpan: `=${isScalarAssertion} ? #.cols.size() : 1`
});
}

for (const name of colNames) {
cols.push(
hasOwnProperty.call(colsMap, name)
Expand All @@ -199,6 +188,16 @@ export default function(host) {
}
}

if (scalarCol) {
cols.unshift({
header: '[value]',
view: 'table-cell',
sorting: '$ ascN',
scalarAsStruct: true,
colSpan: `=${isScalarAssertion} ? #.cols.size() : 1`
});
}

cols = cols.filter(col =>
!hasOwnProperty.call(col, 'when') || host.queryBool(col.when, data, context)
);
Expand Down

0 comments on commit 4f90de5

Please sign in to comment.