Skip to content

Instantly share code, notes, and snippets.

@mastastealth
Created June 20, 2017 18:26
Show Gist options
  • Save mastastealth/bc7c90192974d4ac318f7310d5bdee5d to your computer and use it in GitHub Desktop.
Save mastastealth/bc7c90192974d4ac318f7310d5bdee5d to your computer and use it in GitHub Desktop.
Reopen Test
import Ember from 'ember';
import Table from 'ember-light-table';
const { computed } = Ember;
export default Ember.Component.extend({
model: null,
columns: computed(function() {
return [{
label: 'Avatar',
valuePath: 'avatar',
width: '60px',
sortable: false,
cellComponent: 'user-avatar'
}, {
label: 'First Name',
valuePath: 'firstName',
width: '150px'
}, {
label: 'Last Name',
valuePath: 'lastName',
width: '150px'
}];
}),
table: computed('model', function() {
return new Table(this.get('columns'), this.get('model'));
})
});
// Reopen 1
Table.reopen({
sharedOptions: null
});
import TableHeaderMixin from 'ember-light-table/mixins/table-header';
TableHeaderMixin.reopen({
// Reopen 2
actions: {
foo(columnGroup) { Ember.logger.log('Bar'); }
}
});
import Cell from 'ember-light-table/components/cells/base';
Cell.reopen({
something: 'else'
});
import ColumnClass from 'ember-light-table/classes/Column';
ColumnClass.reopen({
showing: true
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
model() {
return Ember.RSVP.hash({
rows: [
{ firstName: 'Brian' },
{ firstName: 'Bob' },
{ firstName: 'Bill' }
]
});
}
});
<h1>Welcome to {{appName}}</h1>
{{my-table model=model.rows}}
{{#light-table table as |t|}}
{{t.head}}
{{#t.body as |body|}}
{{#body.expanded-row as |row|}}
Hello <b>{{row.firstName}}</b>
{{/body.expanded-row}}
{{#if isLoading}}
{{#body.loader}}
Loading...
{{/body.loader}}
{{/if}}
{{#if table.isEmpty}}
{{#body.no-data}}
No users found.
{{/body.no-data}}
{{/if}}
{{/t.body}}
{{t.foot}}
{{/light-table}}
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1",
"ember-light-table": "1.8.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment