From 5bcee265a60611f7fff317ae06a27120d6cae210 Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Sun, 29 Aug 2021 10:02:19 +0530 Subject: [PATCH] fix: show empty state for search results, es6 --- components/app/Lunr.vue | 29 ++++++++++++++++++----------- components/app/Search.vue | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/components/app/Lunr.vue b/components/app/Lunr.vue index 7dd60e2e2..e827e8f25 100644 --- a/components/app/Lunr.vue +++ b/components/app/Lunr.vue @@ -30,6 +30,15 @@ {{ key }} +
+ manage_search + + {{ $t("state.nothing_found") }} "{{ search }}" + +
@@ -138,16 +147,14 @@ export default { async output(search) { const that = this if ((await this.idx) && (await this.idx.search)) { - return this.idx.search(`${search}*`).map(function (valu) { - return that.input[+valu.ref] - }, that) + return this.idx + .search(`${search}*`) + .map(({ ref }) => that.input[+ref], that) } if (this.idx.then) - return this.idx.then((index) => { - return index.search(`${search}*`).map(function (valu) { - return that.input[+valu.ref] - }, that) - }) + return this.idx.then((index) => + index.search(`${search}*`).map(({ ref }) => that.input[+ref], that) + ) // no index return this.input }, @@ -158,7 +165,7 @@ export default { // if (this.log) console.log("feilds from ", first) const stopWords = this.stopWords - const documents = this.input.map(function (val, i) { + const documents = this.input.map((val, i) => { const doc = {} const seen = [] function replacer(key, value) { @@ -170,7 +177,7 @@ export default { } return value } - Object.keys(val).forEach(function (key) { + Object.keys(val).forEach((key) => { doc[key] = JSON.stringify(val[key], replacer) }) return { __id: i, ...val } @@ -211,7 +218,7 @@ export default { hex32(val) { val &= 0xffffffff const hex = val.toString(16).toUpperCase() - return ("00000000" + hex).slice(-8) + return `00000000${hex}`.slice(-8) }, }, } diff --git a/components/app/Search.vue b/components/app/Search.vue index df82cfc90..e51c9a1b9 100644 --- a/components/app/Search.vue +++ b/components/app/Search.vue @@ -102,11 +102,11 @@ export default defineComponent({ }, methods: { hideModal() { + this.search = "" this.$emit("hide-modal") }, runAction(command) { invokeAction(command, "path_from_invokeAction") - this.search = "" this.hideModal() }, },