From cbacbec7249985b15745cd2e8633a203473a354e Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 14 Mar 2020 07:21:22 +0100 Subject: [PATCH] feat: search on a new search page --- .../SearchableInput/SearchableInput.vue | 21 +++-- webapp/pages/search/search-results.vue | 89 +++++++++++++++++++ webapp/store/search.js | 17 ++++ 3 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 webapp/pages/search/search-results.vue create mode 100644 webapp/store/search.js diff --git a/webapp/components/generic/SearchableInput/SearchableInput.vue b/webapp/components/generic/SearchableInput/SearchableInput.vue index 3260ff082..8c29366da 100644 --- a/webapp/components/generic/SearchableInput/SearchableInput.vue +++ b/webapp/components/generic/SearchableInput/SearchableInput.vue @@ -99,14 +99,21 @@ export default { this.$emit('query', this.value) }, this.delay) }, - /** - * TODO: on enter we should go to a dedicated search page!? - */ onEnter(event) { - clearTimeout(this.searchProcess) - if (!this.loading) { - this.previousSearchTerm = this.unprocessedSearchInput - this.$emit('query', this.unprocessedSearchInput) + if (this.$router.history.current.path === '/search/search-results') { + this.$store.commit('search/SET_VALUE', { + searchValue: this.unprocessedSearchInput, + }) + + this.$router.replace({ + path: '/search/search-results', + query: { item: this.unprocessedSearchInput }, + }) + } else { + this.$router.replace({ + path: '/search/search-results', + query: { item: this.unprocessedSearchInput }, + }) } }, onDelete(event) { diff --git a/webapp/pages/search/search-results.vue b/webapp/pages/search/search-results.vue new file mode 100644 index 000000000..abfe8c1e4 --- /dev/null +++ b/webapp/pages/search/search-results.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/webapp/store/search.js b/webapp/store/search.js new file mode 100644 index 000000000..a10649de1 --- /dev/null +++ b/webapp/store/search.js @@ -0,0 +1,17 @@ +export const state = () => { + return { + searchValue: '', + } +} + +export const mutations = { + SET_VALUE(state, ctx) { + state.searchValue = ctx.searchValue || '' + }, +} + +export const getters = { + searchValue(state) { + return state.searchValue + }, +}