diff --git a/CHANGELOG.md b/CHANGELOG.md index edf6702c..6f7318b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/views/table/table.js b/src/views/table/table.js index c3e9d348..e0ba087e 100644 --- a/src/views/table/table.js +++ b/src/views/table/table.js @@ -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)) { @@ -158,7 +158,6 @@ export default function(host) { } else { const colNames = new Set(); const colsMap = cols && typeof cols === 'object' ? cols : {}; - let scalarCol = false; cols = []; @@ -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) @@ -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) );