diff --git a/app/pods/questions/index/controller.js b/app/pods/questions/index/controller.js index e7e64ff..fea1aee 100644 --- a/app/pods/questions/index/controller.js +++ b/app/pods/questions/index/controller.js @@ -1,13 +1,30 @@ import Controller from '@ember/controller'; +import { task, timeout } from 'ember-concurrency'; export default Controller.extend({ queryParams: ['page', 'limit'], page: 1, limit: 10, + searchString: '', + searchTask: task(function * () { + yield timeout(250) + + let searchStr = this.get('searchString').trim() + + const questions = yield this.get('store').query('question', { + include: 'user', + filter: { + title: { + $iLike: `%${this.get('searchString')}%` + } + } + }) + this.set('page', 1) + this.set('questions', questions) + }).restartable(), actions : { deleteQuestion(question) { question.destroyRecord() } } - }); diff --git a/app/pods/questions/index/template.hbs b/app/pods/questions/index/template.hbs index aa955ce..a37a2cb 100644 --- a/app/pods/questions/index/template.hbs +++ b/app/pods/questions/index/template.hbs @@ -1,11 +1,15 @@
Filter By Question Name:
{{input type="text" class="form-control" placeholder="Enter Question Name" key-up=(perform searchTask) value=searchString}} +