Merge branch '37-full-text-search-top-bar' of github.com:Tirokk/Nitro-Web into 37-full-text-search-top-bar

This commit is contained in:
Matt Rider 2019-03-05 07:06:43 -03:00
commit 1ac2c15947
4 changed files with 24 additions and 7 deletions

View File

@ -4,6 +4,10 @@ import Vue from 'vue'
import Styleguide from '@human-connection/styleguide' import Styleguide from '@human-connection/styleguide'
Vue.use(Styleguide) Vue.use(Styleguide)
import Vue from 'vue'
import Styleguide from '@human-connection/styleguide'
Vue.use(Styleguide)
describe('SearchInput.vue', () => { describe('SearchInput.vue', () => {
let wrapper let wrapper
const mocks = { $t: () => {} } const mocks = { $t: () => {} }

View File

@ -30,8 +30,9 @@
:icon-right="isActive ? 'close' : null" :icon-right="isActive ? 'close' : null"
:filter="item => item" :filter="item => item"
:options="results" :options="results"
:auto-reset-search="!searchValue"
:placeholder="$t('search.placeholder')" :placeholder="$t('search.placeholder')"
@keypress.enter.prevent.stop.self="onEnter" @enter="onEnter"
@focus.capture.native="onFocus" @focus.capture.native="onFocus"
@blur.capture.native="onBlur" @blur.capture.native="onBlur"
@keyup.delete.native="onDelete" @keyup.delete.native="onDelete"
@ -162,25 +163,32 @@ export default {
}, },
onFocus(e) { onFocus(e) {
clearTimeout(this.searchProcess) clearTimeout(this.searchProcess)
//this.$nextTick(() => {
// this.searchValue = this.lastSearchTerm
//})
this.isOpen = true this.isOpen = true
}, },
onBlur(e) { onBlur(e) {
this.searchValue = this.lastSearchTerm
this.$nextTick(() => {
this.searchValue = this.lastSearchTerm
})
this.isOpen = false this.isOpen = false
clearTimeout(this.searchProcess) clearTimeout(this.searchProcess)
this.searchValue = this.lastSearchTerm
}, },
onDelete(e) { onDelete(e) {
clearTimeout(this.searchProcess) clearTimeout(this.searchProcess)
const value = e.target ? e.target.value.trim() : '' const value = e.target ? e.target.value.trim() : ''
if (isEmpty(value)) { if (isEmpty(value)) {
this.clear() this.clear()
} else {
this.handleInput(e)
} }
}, },
/** /**
* TODO: on enter we should go to a dedicated seach page!? * TODO: on enter we should go to a dedicated seach page!?
*/ */
onEnter(e) { onEnter(e) {
// console.log('res', this.unprocessedSearchInput)
// this.isOpen = false // this.isOpen = false
clearTimeout(this.searchProcess) clearTimeout(this.searchProcess)
if (!this.pending) { if (!this.pending) {
@ -189,11 +197,12 @@ export default {
} }
}, },
clear() { clear() {
this.$emit('clear')
clearTimeout(this.searchProcess) clearTimeout(this.searchProcess)
this.isOpen = false this.isOpen = false
this.searchValue = null this.unprocessedSearchInput = ''
this.lastSearchTerm = null this.lastSearchTerm = ''
this.$emit('clear') this.searchValue = ''
} }
} }
} }

View File

@ -36,7 +36,7 @@
} }
}, },
"dependencies": { "dependencies": {
"@human-connection/styleguide": "~0.5.2", "@human-connection/styleguide": "~0.5.5",
"@nuxtjs/apollo": "4.0.0-rc4", "@nuxtjs/apollo": "4.0.0-rc4",
"@nuxtjs/axios": "~5.3.6", "@nuxtjs/axios": "~5.3.6",
"@nuxtjs/dotenv": "~1.3.0", "@nuxtjs/dotenv": "~1.3.0",

View File

@ -70,6 +70,10 @@ export const actions = {
commit('SET_QUICK_RESULTS', res.data.findPosts || []) commit('SET_QUICK_RESULTS', res.data.findPosts || [])
commit('SET_QUICK_PENDING', false) commit('SET_QUICK_PENDING', false)
}) })
.catch(() => {
commit('SET_QUICK_RESULTS', [])
commit('SET_QUICK_PENDING', false)
})
return getters.quickResults return getters.quickResults
}, },
async quickClear({ commit }) { async quickClear({ commit }) {