ui: Search view - Fixes the color style of the filter icon (#4917)

* fixes the color style of the filter icon

* fixes for router leave/enter
This commit is contained in:
Hoang Nguyen 2021-04-13 19:40:39 +07:00 committed by GitHub
parent 87d73b98ee
commit 6200ac8431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,7 @@
slot="addonBefore" slot="addonBefore"
trigger="click" trigger="click"
v-model="visibleFilter"> v-model="visibleFilter">
<template slot="content"> <template slot="content" v-if="visibleFilter">
<a-form <a-form
style="min-width: 170px" style="min-width: 170px"
:form="form" :form="form"
@ -104,7 +104,7 @@
class="filter-button" class="filter-button"
size="small" size="small"
@click="() => { searchQuery = null }"> @click="() => { searchQuery = null }">
<a-icon type="filter" :theme="Object.keys(searchParams).length > 0 ? 'twoTone' : 'outlined'" /> <a-icon type="filter" :theme="isFiltered ? 'twoTone' : 'outlined'" />
</a-button> </a-button>
</a-popover> </a-popover>
</a-input-search> </a-input-search>
@ -140,7 +140,8 @@ export default {
fields: [], fields: [],
inputKey: null, inputKey: null,
inputValue: null, inputValue: null,
fieldValues: {} fieldValues: {},
isFiltered: false
} }
}, },
beforeCreate () { beforeCreate () {
@ -157,6 +158,13 @@ export default {
if (to && to.query && 'q' in to.query) { if (to && to.query && 'q' in to.query) {
this.searchQuery = to.query.q this.searchQuery = to.query.q
} }
this.isFiltered = false
this.searchFilters.some(item => {
if (this.searchParams[item]) {
this.isFiltered = true
return true
}
})
} }
}, },
mounted () { mounted () {
@ -417,6 +425,7 @@ export default {
field[item] = undefined field[item] = undefined
this.form.setFieldsValue(field) this.form.setFieldsValue(field)
}) })
this.isFiltered = false
this.inputKey = null this.inputKey = null
this.inputValue = null this.inputValue = null
this.searchQuery = null this.searchQuery = null
@ -430,6 +439,7 @@ export default {
if (err) { if (err) {
return return
} }
this.isFiltered = true
for (const key in values) { for (const key in values) {
const input = values[key] const input = values[key]
if (input === '' || input === null || input === undefined) { if (input === '' || input === null || input === undefined) {