diff --git a/wherehows-web/app/controllers/application.ts b/wherehows-web/app/controllers/application.ts index 45a20a7661..ab25654664 100644 --- a/wherehows-web/app/controllers/application.ts +++ b/wherehows-web/app/controllers/application.ts @@ -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() { diff --git a/wherehows-web/app/controllers/search.ts b/wherehows-web/app/controllers/search.ts index 1ebc3c68ea..a308a246b5 100644 --- a/wherehows-web/app/controllers/search.ts +++ b/wherehows-web/app/controllers/search.ts @@ -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; diff --git a/wherehows-web/app/routes/application.js b/wherehows-web/app/routes/application.js index 9d4a23364b..a000ba3b3f 100644 --- a/wherehows-web/app/routes/application.js +++ b/wherehows-web/app/routes/application.js @@ -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; diff --git a/wherehows-web/app/routes/search.ts b/wherehows-web/app/routes/search.ts index 4d5cde321a..66dd45507b 100644 --- a/wherehows-web/app/routes/search.ts +++ b/wherehows-web/app/routes/search.ts @@ -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() { diff --git a/wherehows-web/app/typings/app/controllers.d.ts b/wherehows-web/app/typings/app/controllers.d.ts new file mode 100644 index 0000000000..363f9f2841 --- /dev/null +++ b/wherehows-web/app/typings/app/controllers.d.ts @@ -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; + } +}