Update the search

This commit is contained in:
Angelina Filippova 2020-02-25 18:57:38 +03:00
parent b6d678b423
commit 12b708404b
2 changed files with 9 additions and 5 deletions

View file

@ -257,10 +257,11 @@ const wrapValues = (settings, currentState) => {
export const formSearchObject = description => { export const formSearchObject = description => {
return description.reduce((acc, setting) => { return description.reduce((acc, setting) => {
const searchArray = _.compact([setting.key, setting.label, setting.description]).map(el => el.toLowerCase())
if (setting.children) { if (setting.children) {
const updatedAcc = { ...acc, [setting.key]: _.compact([setting.key, setting.label, setting.description]) } const updatedAcc = { ...acc, [setting.key]: searchArray }
return { ...updatedAcc, ...formSearchObject(setting.children) } return { ...updatedAcc, ...formSearchObject(setting.children) }
} }
return { ...acc, [setting.key]: _.compact([setting.key, setting.label, setting.description]) } return { ...acc, [setting.key]: searchArray }
}, {}) }, {})
} }

View file

@ -29,7 +29,8 @@
:trigger-on-focus="false" :trigger-on-focus="false"
placeholder="Search" placeholder="Search"
prefix-icon="el-icon-search" prefix-icon="el-icon-search"
class="settings-search-input"/> class="settings-search-input"
@select="handleSearchSelect"/>
</div> </div>
</div> </div>
<el-tabs v-model="activeTab" tab-position="left"> <el-tabs v-model="activeTab" tab-position="left">
@ -279,10 +280,12 @@ export default {
message: i18n.t('settings.restartSuccess') message: i18n.t('settings.restartSuccess')
}) })
}, },
handleSearchSelect() {
},
querySearch(queryString, cb) { querySearch(queryString, cb) {
const results = Object.keys(this.searchData) const results = Object.keys(this.searchData)
.filter(key => this.searchData[key].find(a => a.includes(queryString))) .filter(key => this.searchData[key].find(el => el.includes(queryString.toLowerCase())))
.map(el => { return { value: el } }) .map(key => { return { value: this.searchData[key][1] } })
cb(results) cb(results)
} }
} }