Skip to content

Commit de2deba

Browse files
committed
SearchBox for Questions
1 parent ad1f5f4 commit de2deba

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
import Controller from '@ember/controller';
2+
import { task, timeout } from 'ember-concurrency';
23

34
export default Controller.extend({
45
queryParams: ['page', 'limit'],
56
page: 1,
6-
limit: 10
7+
limit: 10,
8+
searchString: '',
9+
searchTask: task(function * () {
10+
yield timeout(250)
11+
const questions = yield this.get('store').query('question', {
12+
include: 'user',
13+
page: {
14+
number: this.get('page'),
15+
limit: this.get('limit')
16+
},
17+
filter: {
18+
title: {
19+
$iLike: `%${this.get('searchString')}%`
20+
}
21+
}
22+
})
23+
this.set('page', 1)
24+
this.set('questions', questions)
25+
}).restartable()
726

827
});

app/pods/questions/index/template.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<button>+ Add Question</button>
66
{{/link-to}}
77
</div>
8+
{{input type="text" class="form-control" placeholder="Filter By Question Name" key-up=(perform searchTask) value=searchString}}
89
</div>
910
{{#each questions as |question|}}
1011
<div class="row">

0 commit comments

Comments
 (0)