Skip to content

Commit a53ecac

Browse files
author
Hoang Nguyen
authored
ui: Fill out the search filter form field after performing a filter (#4855)
* Fill out the search filter form field after performing a filter * fix button reset not work when refresh page
1 parent 83b568e commit a53ecac

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

ui/src/components/view/SearchView.vue

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
<a-select
5454
allowClear
5555
v-if="field.type==='list'"
56-
v-decorator="[field.name]"
56+
v-decorator="[field.name, {
57+
initialValue: fieldValues[field.name] || null
58+
}]"
5759
:loading="field.loading">
5860
<a-select-option
5961
v-for="(opt, idx) in field.opts"
@@ -62,7 +64,9 @@
6264
</a-select>
6365
<a-input
6466
v-else-if="field.type==='input'"
65-
v-decorator="[field.name]" />
67+
v-decorator="[field.name, {
68+
initialValue: fieldValues[field.name] || null
69+
}]" />
6670
<div v-else-if="field.type==='tag'">
6771
<div>
6872
<a-input-group
@@ -135,7 +139,8 @@ export default {
135139
visibleFilter: false,
136140
fields: [],
137141
inputKey: null,
138-
inputValue: null
142+
inputValue: null,
143+
fieldValues: {}
139144
}
140145
},
141146
beforeCreate () {
@@ -275,7 +280,6 @@ export default {
275280
}
276281
if (clusterIndex > -1) {
277282
const cluster = response.filter(item => item.type === 'clusterid')
278-
console.log(cluster)
279283
if (cluster && cluster.length > 0) {
280284
this.fields[clusterIndex].opts = cluster[0].data
281285
}
@@ -294,8 +298,20 @@ export default {
294298
if (clusterIndex > -1) {
295299
this.fields[clusterIndex].loading = false
296300
}
301+
this.fillFormFieldValues()
297302
})
298303
},
304+
fillFormFieldValues () {
305+
this.fieldValues = {}
306+
if (Object.keys(this.$route.query).length > 0) {
307+
this.fieldValues = this.$route.query
308+
}
309+
if (this.$route.meta.params) {
310+
Object.assign(this.fieldValues, this.$route.meta.params)
311+
}
312+
this.inputKey = this.fieldValues['tags[0].key'] || null
313+
this.inputValue = this.fieldValues['tags[0].value'] || null
314+
},
299315
fetchZones () {
300316
return new Promise((resolve, reject) => {
301317
api('listZones', { listAll: true }).then(json => {

ui/src/views/AutogenView.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ export default {
608608
609609
params.page = this.page
610610
params.pagesize = this.pageSize
611+
this.searchParams = params
611612
api(this.apiName, params).then(json => {
612613
var responseName
613614
var objectName

0 commit comments

Comments
 (0)