Facets: Docs and a little cleanup

This commit is contained in:
Ignacio Bona 2018-09-14 16:58:45 -07:00
parent 3459b8174a
commit d6393ece00
5 changed files with 26 additions and 3 deletions

View File

@ -44,6 +44,9 @@ export default class Application extends Controller {
@service('banners')
banners: BannerService;
/**
* Keyword of the current search to pass it down to the search bar
*/
keyword: string;
constructor() {

View File

@ -20,8 +20,7 @@ export default class SearchController extends Controller {
category = 'datasets';
/**
* Dataset Platform to restrict search results to
* @type {DatasetPlatform}
* Encoded facets state in a restli fashion
*/
facets: string;

View File

@ -181,6 +181,13 @@ export default Route.extend(ApplicationRouteMixin, {
});
},
/**
* To make keyword accesible to the search bar
* we need to read it from the search query parameters
* and pass it down to the controller.
* @param {*} controller
* @param {*} model
*/
setupController(controller, model) {
const keyword = this.paramsFor('search').keyword;
controller.set('keyword', keyword);
@ -188,6 +195,10 @@ export default Route.extend(ApplicationRouteMixin, {
},
actions: {
/**
* Make sure we keep the keywork updated, so if we return
* home, the search term clears
*/
willTransition() {
const controller = this.controllerFor('application');
const keyword = this.paramsFor('search').keyword;

View File

@ -20,9 +20,11 @@ export default class SearchRoute extends Route.extend(AuthenticatedRouteMixin) {
return result || {};
}
/**
* Add spinner when model is loading
*/
@action
loading(transition: any) {
// @ts-ignore
let controller = this.controllerFor('search');
controller.set('searchLoading', true);
transition.promise.finally(function() {

View File

@ -0,0 +1,8 @@
import SearchController from 'wherehows-web/controllers/search';
declare module '@ember/controller' {
// eslint-disable-next-line typescript/interface-name-prefix
interface Registry {
search: SearchController;
}
}