From a9795ab64d13afba2b59f8795b8471b25272405b Mon Sep 17 00:00:00 2001 From: maxwondercorn Date: Sat, 30 Jul 2022 02:23:50 -0400 Subject: [PATCH 1/4] Add missing named parameters to templates --- addon/components/lt-body.hbs | 10 +++++----- addon/components/lt-foot.hbs | 2 +- addon/components/lt-head.hbs | 4 ++-- addon/components/lt-row.hbs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/addon/components/lt-body.hbs b/addon/components/lt-body.hbs index 11a286a4..347b134a 100644 --- a/addon/components/lt-body.hbs +++ b/addon/components/lt-body.hbs @@ -30,7 +30,7 @@ {{yield this.columns this.rows}} {{else}} {{#vertical-collection - this.rows + items=this.rows tagName="vertical-collection" estimateHeight=this.sharedOptions.estimatedRowHeight shouldRecycle=this.sharedOptions.shouldRecycle @@ -43,8 +43,8 @@ lastReached=(action "lastReached") as |row| }} {{lt.row - row - this.columns + row=row + columns=this.columns data-row-id=row.rowId table=this.table tableActions=this.tableActions @@ -120,8 +120,8 @@ ) as |row| }} {{lt.row - row - this.columns + row=row + columns=this.columns data-row-id=row.rowId table=this.table tableActions=this.tableActions diff --git a/addon/components/lt-foot.hbs b/addon/components/lt-foot.hbs index 6a3050ce..80437321 100644 --- a/addon/components/lt-foot.hbs +++ b/addon/components/lt-foot.hbs @@ -13,7 +13,7 @@ {{#each this.columns as |column|}} {{component (concat "light-table/columns/" column.type) - column + column=column table=this.table tableActions=this.tableActions extra=this.extra diff --git a/addon/components/lt-head.hbs b/addon/components/lt-head.hbs index 74f5ea08..7c1993d6 100644 --- a/addon/components/lt-head.hbs +++ b/addon/components/lt-head.hbs @@ -21,7 +21,7 @@ {{#each this.columnGroups as |column|}} {{component (concat "light-table/columns/" column.type) - column + column=column table=this.table tableActions=this.tableActions extra=this.extra @@ -40,7 +40,7 @@ {{#each this.subColumns as |column|}} {{component (concat "light-table/columns/" column.type) - column + column=column table=this.table rowspan=1 classNames="lt-sub-column" diff --git a/addon/components/lt-row.hbs b/addon/components/lt-row.hbs index f1b9c64f..9ca29a38 100644 --- a/addon/components/lt-row.hbs +++ b/addon/components/lt-row.hbs @@ -1,8 +1,8 @@ {{#each this.columns as |column|}} {{component (concat 'light-table/cells/' column.cellType) - column - this.row + column=column + row=this.row table=this.table rawValue=(get this.row column.valuePath) tableActions=this.tableActions From 2510c36dc78c0c26228c0e55640ab82d6670b2c6 Mon Sep 17 00:00:00 2001 From: maxwondercorn Date: Sat, 30 Jul 2022 02:33:19 -0400 Subject: [PATCH 2/4] Remove componet reopening for postional parameters --- addon/components/columns/base.js | 8 +------- addon/components/lt-row.js | 8 +------- tests/unit/classes/column-test.js | 9 --------- tests/unit/classes/row-test.js | 9 --------- 4 files changed, 2 insertions(+), 32 deletions(-) diff --git a/addon/components/columns/base.js b/addon/components/columns/base.js index 79837344..7e4db382 100644 --- a/addon/components/columns/base.js +++ b/addon/components/columns/base.js @@ -16,7 +16,7 @@ import cssStyleify from 'ember-light-table/utils/css-styleify'; * @class Base Column */ -const Column = Component.extend(DraggableColumnMixin, { +export default Component.extend(DraggableColumnMixin, { tagName: 'th', classNames: ['lt-column'], attributeBindings: ['style', 'colspan', 'rowspan'], @@ -129,9 +129,3 @@ const Column = Component.extend(DraggableColumnMixin, { }, }), }); - -Column.reopenClass({ - positionalParams: ['column'], -}); - -export default Column; diff --git a/addon/components/lt-row.js b/addon/components/lt-row.js index 4c78e802..6a290cb7 100644 --- a/addon/components/lt-row.js +++ b/addon/components/lt-row.js @@ -1,7 +1,7 @@ import Component from '@ember/component'; import { readOnly } from '@ember/object/computed'; -const Row = Component.extend({ +export default Component.extend({ tagName: 'tr', classNames: ['lt-row'], classNameBindings: [ @@ -24,9 +24,3 @@ const Row = Component.extend({ isSelected: readOnly('row.selected'), isExpanded: readOnly('row.expanded'), }); - -Row.reopenClass({ - positionalParams: ['row', 'columns'], -}); - -export default Row; diff --git a/tests/unit/classes/column-test.js b/tests/unit/classes/column-test.js index 5e36e015..88b8ba27 100644 --- a/tests/unit/classes/column-test.js +++ b/tests/unit/classes/column-test.js @@ -18,15 +18,6 @@ module('Unit | Classes | Column', function () { assert.equal(col.width, null); }); - test('reopen colum', function (assert) { - assert.equal(typeof Column.reopen, 'function', 'reopen is a function'); - assert.equal( - typeof Column.reopenClass, - 'function', - 'reopenClass is a function' - ); - }); - test('CP - isGroupColumn', function (assert) { let col = Column.create(); assert.ok(col); diff --git a/tests/unit/classes/row-test.js b/tests/unit/classes/row-test.js index f442ba08..313db659 100644 --- a/tests/unit/classes/row-test.js +++ b/tests/unit/classes/row-test.js @@ -8,13 +8,4 @@ module('Unit | Classes | Row', function () { assert.false(row.expanded); assert.false(row.selected); }); - - test('reopen row', function (assert) { - assert.equal(typeof Row.reopen, 'function', 'reopen is a function'); - assert.equal( - typeof Row.reopenClass, - 'function', - 'reopenClass is a function' - ); - }); }); From 908702cb033fbb50d82fb0a8d0c2f6d0894a7f86 Mon Sep 17 00:00:00 2001 From: maxwondercorn Date: Sat, 30 Jul 2022 02:53:14 -0400 Subject: [PATCH 3/4] Remove remaining postional parameter class reopens --- addon/components/cells/base.js | 8 +---- addon/components/light-table.js | 9 ++---- .../components/light-table-occlusion-test.js | 22 +++++++------- .../components/light-table-test.js | 30 +++++++++---------- .../components/light-table/cells/base-test.js | 13 ++++++-- tests/unit/classes/table-test.js | 9 ------ 6 files changed, 39 insertions(+), 52 deletions(-) diff --git a/addon/components/cells/base.js b/addon/components/cells/base.js index 5eee09e6..decb9979 100644 --- a/addon/components/cells/base.js +++ b/addon/components/cells/base.js @@ -13,7 +13,7 @@ import { htmlSafe } from '@ember/template'; * @class Base Cell */ -const Cell = Component.extend({ +export default Component.extend({ tagName: 'td', classNames: ['lt-cell'], attributeBindings: ['style'], @@ -92,9 +92,3 @@ const Cell = Component.extend({ return rawValue; }), }); - -Cell.reopenClass({ - positionalParams: ['column', 'row'], -}); - -export default Cell; diff --git a/addon/components/light-table.js b/addon/components/light-table.js index ec42a7a1..c912f775 100644 --- a/addon/components/light-table.js +++ b/addon/components/light-table.js @@ -36,7 +36,7 @@ function intersections(array1, array2) { * @main Components */ -const LightTable = Component.extend({ +export default Component.extend({ tagName: '', media: service(), @@ -289,6 +289,7 @@ const LightTable = Component.extend({ let table = this.table; + debugger assert( '[ember-light-table] table must be an instance of Table', table instanceof Table @@ -385,9 +386,3 @@ const LightTable = Component.extend({ }, }, }); - -LightTable.reopenClass({ - positionalParams: ['table'], -}); - -export default LightTable; diff --git a/tests/integration/components/light-table-occlusion-test.js b/tests/integration/components/light-table-occlusion-test.js index 498a6b05..c4e43b6a 100644 --- a/tests/integration/components/light-table-occlusion-test.js +++ b/tests/integration/components/light-table-occlusion-test.js @@ -32,7 +32,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { test('it renders', async function (assert) { this.set('table', Table.create()); await render( - hbs`{{light-table this.table height="40vh" occlusion=true estimatedRowHeight=30}}` + hbs`{{light-table table=this.table height="40vh" occlusion=true estimatedRowHeight=30}}` ); assert.dom('*').hasText(''); @@ -54,7 +54,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { }); await render(hbs` - {{#light-table this.table height='40vh' occlusion=true estimatedRowHeight=30 as |t|}} + {{#light-table table=this.table height='40vh' occlusion=true estimatedRowHeight=30 as |t|}} {{t.head fixed=true}} {{t.body onScrolledToBottom=this.onScrolledToBottom}} {{/light-table}} @@ -90,7 +90,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { ); await render(hbs` - {{#light-table this.table height='500px' id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} + {{#light-table table=this.table height='500px' id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} {{t.head fixed=true}} {{t.body}} {{/light-table}} @@ -99,7 +99,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { assert.dom('#lightTable_inline_head thead').doesNotExist(); await render(hbs` - {{#light-table this.table height='500px' id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} + {{#light-table table=this.table height='500px' id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} {{t.head fixed=false}} {{t.body}} {{/light-table}} @@ -119,7 +119,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { ); await render(hbs` - {{#light-table this.table height='500px' id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} + {{#light-table table=this.table height='500px' id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} {{t.body}} {{t.foot fixed=true}} {{/light-table}} @@ -128,7 +128,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { assert.dom('#lightTable_inline_foot tfoot').doesNotExist(); await render(hbs` - {{#light-table this.table height='500px' id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} + {{#light-table table=this.table height='500px' id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} {{t.body}} {{t.foot fixed=false}} {{/light-table}} @@ -149,7 +149,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { await render(hbs`
- {{#light-table this.table id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} + {{#light-table table=this.table id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} {{t.body}} {{t.foot fixed=this.fixed}} {{/light-table}} @@ -175,7 +175,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { await render(hbs`
- {{#light-table this.table id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} + {{#light-table table=this.table id='lightTable' occlusion=true estimatedRowHeight=30 as |t|}} {{t.head fixed=true}} {{t.body}} {{#t.foot fixed=true}} @@ -209,7 +209,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { ); await render(hbs` - {{#light-table this.table occlusion=true estimatedRowHeight=30 as |t|}} + {{#light-table table=this.table occlusion=true estimatedRowHeight=30 as |t|}} {{t.body rowComponent=(component "custom-row" classNames="custom-row")}} {{/light-table}} `); @@ -235,7 +235,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { this.set('table', Table.create({ columns: Columns, rows: users })); await render(hbs` - {{#light-table this.table height='500px' occlusion=true estimatedRowHeight=30 as |t|}} + {{#light-table table=this.table height='500px' occlusion=true estimatedRowHeight=30 as |t|}} {{t.body rowComponent=(component "custom-row" classNames="custom-row" current=this.current) }} @@ -307,7 +307,7 @@ module('Integration | Component | light table | occlusion', function (hooks) { }; await render(hbs` - {{#light-table this.table + {{#light-table table=this.table occlusion=true estimatedRowHeight=30 extra=(hash someData="someValue") diff --git a/tests/integration/components/light-table-test.js b/tests/integration/components/light-table-test.js index 831702fb..a84fd19c 100644 --- a/tests/integration/components/light-table-test.js +++ b/tests/integration/components/light-table-test.js @@ -28,7 +28,7 @@ module('Integration | Component | light table', function (hooks) { test('it renders', async function (assert) { this.set('table', Table.create()); - await render(hbs`{{light-table this.table}}`); + await render(hbs`{{light-table table=this.table}}`); assert.dom('*').hasText(''); }); @@ -49,7 +49,7 @@ module('Integration | Component | light table', function (hooks) { }); await render(hbs` - {{#light-table this.table height='40vh' as |t|}} + {{#light-table table=this.table height='40vh' as |t|}} {{t.head fixed=true}} {{t.body onScrolledToBottom=this.onScrolledToBottom}} {{/light-table}} @@ -90,12 +90,12 @@ module('Integration | Component | light table', function (hooks) { }); await render(hbs` - {{#light-table this.table height='40vh' id='table-1' as |t|}} + {{#light-table table=this.table height='40vh' id='table-1' as |t|}} {{t.head fixed=true}} {{t.body onScrolledToBottom=this.onScrolledToBottomTable1}} {{/light-table}} - {{#light-table this.table height='40vh' id='table-2' as |t|}} + {{#light-table table=this.table height='40vh' id='table-2' as |t|}} {{t.head fixed=true}} {{t.body onScrolledToBottom=this.onScrolledToBottomTable2}} {{/light-table}} @@ -129,7 +129,7 @@ module('Integration | Component | light table', function (hooks) { ); await render(hbs` - {{#light-table this.table height='500px' id='lightTable' as |t|}} + {{#light-table table=this.table height='500px' id='lightTable' as |t|}} {{t.head fixed=true}} {{t.body}} {{/light-table}} @@ -138,7 +138,7 @@ module('Integration | Component | light table', function (hooks) { assert.dom('#lightTable_inline_head thead').doesNotExist(); await render(hbs` - {{#light-table this.table height='500px' id='lightTable' as |t|}} + {{#light-table table=this.table height='500px' id='lightTable' as |t|}} {{t.head fixed=false}} {{t.body}} {{/light-table}} @@ -158,7 +158,7 @@ module('Integration | Component | light table', function (hooks) { ); await render(hbs` - {{#light-table this.table height='500px' id='lightTable' as |t|}} + {{#light-table table=this.table height='500px' id='lightTable' as |t|}} {{t.body}} {{t.foot fixed=true}} {{/light-table}} @@ -167,7 +167,7 @@ module('Integration | Component | light table', function (hooks) { assert.dom('#lightTable_inline_foot tfoot').doesNotExist(); await render(hbs` - {{#light-table this.table height='500px' id='lightTable' as |t|}} + {{#light-table table=this.table height='500px' id='lightTable' as |t|}} {{t.body}} {{t.foot fixed=false}} {{/light-table}} @@ -188,7 +188,7 @@ module('Integration | Component | light table', function (hooks) { await render(hbs`
- {{#light-table this.table id='lightTable' as |t|}} + {{#light-table table=this.table id='lightTable' as |t|}} {{t.body}} {{t.foot fixed=this.fixed}} {{/light-table}} @@ -214,7 +214,7 @@ module('Integration | Component | light table', function (hooks) { await render(hbs`
- {{#light-table this.table id='lightTable' as |t|}} + {{#light-table table=this.table id='lightTable' as |t|}} {{t.head fixed=true}} {{t.body}} {{#t.foot fixed=true}} @@ -248,7 +248,7 @@ module('Integration | Component | light table', function (hooks) { ); await render(hbs` - {{#light-table this.table as |t|}} + {{#light-table table=this.table as |t|}} {{t.body rowComponent=(component "custom-row" classNames="custom-row")}} {{/light-table}} `); @@ -274,7 +274,7 @@ module('Integration | Component | light table', function (hooks) { this.set('table', Table.create({ columns: Columns, rows: users })); await render(hbs` - {{#light-table this.table as |t|}} + {{#light-table table=this.table as |t|}} {{t.body rowComponent=(component "custom-row" classNames="custom-row" current=this.current) }} @@ -323,7 +323,7 @@ module('Integration | Component | light table', function (hooks) { }); await render(hbs` - {{#light-table this.table height='40vh' as |t|}} + {{#light-table table=this.table height='40vh' as |t|}} {{t.head fixed=true}} {{t.body useVirtualScrollbar=true @@ -374,7 +374,7 @@ module('Integration | Component | light table', function (hooks) { }; await render(hbs` - {{#light-table this.table + {{#light-table table=this.table extra=(hash someData="someValue") tableActions=(hash someAction=(action "someAction") @@ -399,7 +399,7 @@ module('Integration | Component | light table', function (hooks) { }); this.setProperties({ table }); await render(hbs` - {{#light-table this.table height='40vh' as |t|}} + {{#light-table table=this.table height='40vh' as |t|}} {{t.head fixed=true}} {{t.body}} {{/light-table}} diff --git a/tests/integration/components/light-table/cells/base-test.js b/tests/integration/components/light-table/cells/base-test.js index d39c14da..6a1645c2 100644 --- a/tests/integration/components/light-table/cells/base-test.js +++ b/tests/integration/components/light-table/cells/base-test.js @@ -29,7 +29,7 @@ module('Integration | Component | Cells | base', function (hooks) { this.set('row', Row.create()); await render(hbs` - {{light-table/cells/base this.column this.row rawValue=2}} + {{light-table/cells/base column=this.column row=this.row rawValue=2}} `); assert.dom('*').hasText('4'); @@ -47,7 +47,9 @@ module('Integration | Component | Cells | base', function (hooks) { this.set('row', Row.create({ content: { num: 2 } })); - await render(hbs`{{light-table/cells/base this.column this.row}}`); + await render( + hbs`{{light-table/cells/base column=this.column row=this.row}}` + ); assert.dom('*').hasText('4'); }); @@ -77,7 +79,12 @@ module('Integration | Component | Cells | base', function (hooks) { ); await render( - hbs`{{light-table/cells/base this.column this.row rawValue=(get this.row this.column.valuePath)}}` + hbs` + {{light-table/cells/base + column=this.column + row=this.row + rawValue=(get this.row this.column.valuePath)}} + ` ); assert.dom('*').hasText('4'); diff --git a/tests/unit/classes/table-test.js b/tests/unit/classes/table-test.js index 1b7c73df..85124510 100644 --- a/tests/unit/classes/table-test.js +++ b/tests/unit/classes/table-test.js @@ -66,15 +66,6 @@ module('Unit | Classes | Table', function () { assert.equal(table.get('columns.length'), 1); }); - test('reopen table', function (assert) { - assert.equal(typeof Table.reopen, 'function', 'reopen is a function'); - assert.equal( - typeof Table.reopenClass, - 'function', - 'reopenClass is a function' - ); - }); - test('CP - visibleColumnGroups', function (assert) { let table = Table.create(); let col = Column.create(); From 498ff8e16c9e3349446f76a456c5351774fcbc8f Mon Sep 17 00:00:00 2001 From: maxwondercorn Date: Sat, 30 Jul 2022 03:19:26 -0400 Subject: [PATCH 4/4] Remove debugger statement --- addon/components/light-table.js | 1 - 1 file changed, 1 deletion(-) diff --git a/addon/components/light-table.js b/addon/components/light-table.js index c912f775..8a4e4936 100644 --- a/addon/components/light-table.js +++ b/addon/components/light-table.js @@ -289,7 +289,6 @@ export default Component.extend({ let table = this.table; - debugger assert( '[ember-light-table] table must be an instance of Table', table instanceof Table