mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
Added basic search to members list
This commit is contained in:
parent
bb2c5426bc
commit
49942f5604
@ -1,4 +1,5 @@
|
||||
import Controller from '@ember/controller';
|
||||
import {computed} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
|
||||
@ -8,12 +9,30 @@ export default Controller.extend({
|
||||
|
||||
meta: null,
|
||||
members: null,
|
||||
searchText: '',
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
this.set('members', this.store.peekAll('member'));
|
||||
},
|
||||
|
||||
filteredMembers: computed('members.@each.{name,email}', 'searchText', function () {
|
||||
let {members, searchText} = this;
|
||||
searchText = searchText.toLowerCase();
|
||||
|
||||
let filtered = members.filter((member) => {
|
||||
if (!searchText) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let {name, email} = member;
|
||||
return name.toLowerCase().indexOf(searchText) >= 0
|
||||
|| email.toLowerCase().indexOf(searchText) >= 0;
|
||||
});
|
||||
|
||||
return filtered;
|
||||
}),
|
||||
|
||||
fetchMembers: task(function* () {
|
||||
let newFetchDate = new Date();
|
||||
let results;
|
||||
|
@ -13,13 +13,19 @@
|
||||
(Loading...)
|
||||
{{/if}}
|
||||
</h2>
|
||||
<div>
|
||||
<GhTextInput
|
||||
placeholder="Search..."
|
||||
@value={{this.searchText}}
|
||||
@input={{action (mut this.searchText) value="target.value"}} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if this.members}}
|
||||
{{#if this.filteredMembers}}
|
||||
{{!-- members list, styles taken from .apps-grid --}}
|
||||
<div class="flex flex-row flex-wrap items-start ba br3 b--whitegrey mt2 mb10">
|
||||
<VerticalCollection
|
||||
@items={{this.members}}
|
||||
@items={{this.filteredMembers}}
|
||||
@key="id"
|
||||
@containerSelector=".gh-main"
|
||||
@estimateHeight=76
|
||||
|
Loading…
Reference in New Issue
Block a user