Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions addon/-private/collapse-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ function closestLessThan(values, target) {
class CollapseTreeNode extends EmberObject {
_childNodes = null;

constructor() {
super(...arguments);
init() {
super.init(...arguments);

let value = get(this, 'value');
let parentValue = get(this, 'parent.value');
Expand Down Expand Up @@ -652,8 +652,8 @@ class CollapseTreeNode extends EmberObject {
order of magnitude of space and allocation costs this way.
*/
export default class CollapseTree extends EmberObject.extend(EmberArray) {
constructor() {
super(...arguments);
init() {
super.init(...arguments);

// Whenever the root node's length changes we need to propogate the change to
// users of the tree, and since the tree is meant to work like an array we should
Expand Down
8 changes: 4 additions & 4 deletions addon/-private/column-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class TableColumnMeta extends EmberObject {
class ColumnTreeNode extends EmberObject {
_subcolumnNodes = null;

constructor() {
super(...arguments);
init() {
super.init(...arguments);

let tree = get(this, 'tree');
let parent = get(this, 'parent');
Expand Down Expand Up @@ -530,8 +530,8 @@ class ColumnTreeNode extends EmberObject {
}

export default class ColumnTree extends EmberObject {
constructor() {
super(...arguments);
init() {
super.init(...arguments);

this.token = new Token();

Expand Down
9 changes: 6 additions & 3 deletions addon/components/-private/row-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const layout = hbs`{{yield api}}`;

@tagName('')
export default class RowWrapper extends Component {
layout = layout;

@argument
rowValue;

Expand All @@ -56,7 +54,12 @@ export default class RowWrapper extends Component {
@argument
checkboxSelectionMode;

_cells = emberA([]);
init() {
super.init(...arguments);

this.layout = layout;
this._cells = emberA([]);
}

destroy() {
this._cells.forEach(cell => cell.destroy());
Expand Down
8 changes: 6 additions & 2 deletions addon/components/ember-table/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ import layout from './template';
*/
@classNames('ember-table')
export default class EmberTable extends Component {
layout = layout;

@service
userAgent;

@attribute('data-test-ember-table')
dataTestEmberTable = true;

init() {
super.init(...arguments);

this.layout = layout;
}

didInsertElement() {
super.didInsertElement(...arguments);

Expand Down
36 changes: 18 additions & 18 deletions addon/components/ember-tbody/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import { assert } from '@ember/debug';
*/
@tagName('tbody')
export default class EmberTBody extends Component {
layout = layout;

/**
The API object passed in by the table
*/
Expand Down Expand Up @@ -211,29 +209,31 @@ export default class EmberTBody extends Component {
@type('string')
containerSelector = '';

/**
The map that contains row meta information for this table.
*/
rowMetaCache = new Map();

/**
A data structure that the table uses wrapping the `rows` object. It flattens
the tree structure of the nodes and allows us to treat it as a flat list of
items. This is much more convenient for most table operations in general.
*/
collapseTree = CollapseTree.create({
sendAction: this.sendAction.bind(this),
});

/**
Whether or not the table can select, is true if an `onSelect` action was
passed to the table.
*/
@bool('onSelect')
canSelect;

constructor() {
super(...arguments);
init() {
super.init(...arguments);

this.layout = layout;

/**
The map that contains row meta information for this table.
*/
this.rowMetaCache = new Map();

/**
A data structure that the table uses wrapping the `rows` object. It flattens
the tree structure of the nodes and allows us to treat it as a flat list of
items. This is much more convenient for most table operations in general.
*/
this.collapseTree = CollapseTree.create({
sendAction: this.sendAction.bind(this),
});

this._updateCollapseTree();

Expand Down
8 changes: 6 additions & 2 deletions addon/components/ember-td/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ import { SELECT_MODE } from '../../-private/collapse-tree';
*/
@tagName('td')
export default class EmberTd extends BaseTableCell {
layout = layout;

/**
The API object passed in by the table row
*/
Expand Down Expand Up @@ -94,6 +92,12 @@ export default class EmberTd extends BaseTableCell {
@readOnly('rowMeta.canCollapse')
canCollapse;

init() {
super.init(...arguments);

this.layout = layout;
}

@computed('rowMeta.depth')
get depthClass() {
return `depth-${this.get('rowMeta.depth')}`;
Expand Down
6 changes: 5 additions & 1 deletion addon/components/ember-tfoot/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import layout from './template';
*/
@tagName('tfoot')
export default class EmberTFoot extends EmberTBody {
layout = layout;
init() {
super.init(...arguments);

this.layout = layout;
}

@computed('wrappedRows.[]')
get wrappedRowArray() {
Expand Down
48 changes: 24 additions & 24 deletions addon/components/ember-thead/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import layout from './template';
*/
@tagName('thead')
export default class EmberTHead extends Component {
layout = layout;

/**
The API object passed in by the table
*/
Expand Down Expand Up @@ -151,28 +149,30 @@ export default class EmberTHead extends Component {
@type(optional(Action))
onResize = null;

/**
* A sensor object that sends events to this table component when table size changes. When table
* is resized, table width & height are updated and other computed properties depending on them
* also get updated.
*/
_tableResizeSensor = null;

/**
The map that contains column meta information for this table. Is meant to be
unique to this table, which is why it is created here. In order to prevent
memory leaks, we need to be able to clean the cache manually when the table
is destroyed or updated, which is why we use a Map instead of WeakMap
*/
columnMetaCache = new Map();

columnTree = ColumnTree.create({
sendAction: this.sendAction.bind(this),
columnMetaCache: this.columnMetaCache,
});

constructor() {
super(...arguments);
init() {
super.init(...arguments);

this.layout = layout;

/**
* A sensor object that sends events to this table component when table size changes. When table
* is resized, table width & height are updated and other computed properties depending on them
* also get updated.
*/
this._tableResizeSensor = null;

/**
The map that contains column meta information for this table. Is meant to be
unique to this table, which is why it is created here. In order to prevent
memory leaks, we need to be able to clean the cache manually when the table
is destroyed or updated, which is why we use a Map instead of WeakMap
*/
this.columnMetaCache = new Map();

this.columnTree = ColumnTree.create({
sendAction: this.sendAction.bind(this),
columnMetaCache: this.columnMetaCache,
});

this._updateApi();
this._updateColumnTree();
Expand Down
8 changes: 6 additions & 2 deletions addon/components/ember-tr/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ import { SELECT_MODE } from '../../-private/collapse-tree';
@tagName('tr')
@classNames('et-tr')
export default class EmberTr extends Component {
layout = layout;

/**
The API object passed in by the table body, header, or footer
*/
Expand Down Expand Up @@ -97,6 +95,12 @@ export default class EmberTr extends Component {
@readOnly('rowMeta.isGroupSelected')
isGroupSelected;

init() {
super.init(...arguments);

this.layout = layout;
}

@className
@computed('rowSelectionMode')
get isSelectable() {
Expand Down