Last active
December 19, 2018 10:25
-
-
Save jelhan/c0377e10c5736f9583282895d41ad268 to your computer and use it in GitHub Desktop.
table with filter and pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { computed } from '@ember/object'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
items: [ | |
{ firstName: 'Max', lastName: 'Mustermann', email: '[email protected]' }, | |
{ firstName: 'Sven', lastName: 'Adam', email: '[email protected]' }, | |
{ firstName: 'Karl', lastName: 'Käfer', email: '[email protected]' }, | |
], | |
filteredItems: computed('filterFirstName', 'filterLastName', 'filterEmail', 'items.[]', function() { | |
return this.items.filter((item) => { | |
return (!this.filterFirstName || item.firstName.includes(this.filterFirstName)) && | |
(!this.filterLastName || item.lastName.includes(this.filterLastName)) && | |
(!this.filterEmail || item.email.includes(this.filterEmail)); | |
}); | |
}), | |
pagedItems: computed('filteredItems.[]', function() { | |
return this.filteredItems.slice(0, 2); | |
}), | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2", | |
"ember-truth-helpers": "2.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment