Skip to content

Commit

Permalink
Finish up conversion and convert TBody
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Garrett committed Apr 11, 2019
1 parent cdb62d5 commit a443e40
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 127 deletions.
37 changes: 37 additions & 0 deletions addon/-private/utils/default-to.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { computed } from '@ember/object';

let VALUES = new WeakMap();

function valuesFor(obj) {
if (!VALUES.has(obj)) {
VALUES.set(obj, Object.create(null));
}

return VALUES.get(obj);
}

export default function defaultTo(defaultValue) {
return computed({
get(key) {
let values = valuesFor(this);

if (!(key in values)) {
values[key] = typeof defaultValue === 'function' ? defaultValue() : defaultValue;
}

return defaultValue;
},

set(key, value) {
let values = valuesFor(this);

if (value === undefined) {
values[key] = typeof defaultValue === 'function' ? defaultValue() : defaultValue;
} else {
values[key] = value;
}

return values[key];
},
});
}
9 changes: 4 additions & 5 deletions addon/components/ember-table/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,22 @@ export default Component.extend({
}
}

super.willDestroyElement(...arguments);
this._super(...arguments);
},

tableStyle: computed('tableWidth', function() {
return htmlSafe(`width: ${this.get('tableWidth')}px;`);
}),


api: computed(function() {
return {
columns: null,
registerColumnTree: this.registerColumnTree,
registerColumnTree: this.registerColumnTree.bind(this),
tableId: this.elementId,
};
}),

registerColumnTree() {
registerColumnTree(columnTree) {
this.set('api.columnTree', columnTree);
}
},
});
Loading

0 comments on commit a443e40

Please sign in to comment.