Skip to content

Commit 69285a6

Browse files
UI: Fix selection of domain filters in the SearchView component (#10386)
1 parent 07564b7 commit 69285a6

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

ui/src/components/view/SearchView.vue

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ export default {
249249
this.fetchDynamicFieldData(fieldname, event.target.value)
250250
},
251251
onSelectFieldChange (fieldname) {
252-
if (fieldname === 'domainid') {
252+
const fetchAccountOptions = fieldname === 'domainid' && this.fields.some((field) => field.name === 'account')
253+
if (fetchAccountOptions) {
253254
this.fetchDynamicFieldData('account')
254255
}
255256
},
@@ -711,10 +712,6 @@ export default {
711712
if (Array.isArray(arrayField)) {
712713
this.fillFormFieldValues()
713714
}
714-
if (networkIndex > -1) {
715-
this.fields[networkIndex].loading = false
716-
}
717-
this.fillFormFieldValues()
718715
})
719716
},
720717
initFormFieldData () {
@@ -782,7 +779,7 @@ export default {
782779
params.domainid = this.form.domainid
783780
}
784781
api('listAccounts', params).then(json => {
785-
var account = json.listaccountsresponse.account
782+
let account = json?.listaccountsresponse?.account || []
786783
if (this.form.domainid) {
787784
account = account.filter(a => a.domainid === this.form.domainid)
788785
}
@@ -1323,14 +1320,22 @@ export default {
13231320
this.searchQuery = value
13241321
this.$emit('search', { searchQuery: this.searchQuery })
13251322
},
1326-
onClear () {
1323+
async onClear () {
13271324
this.formRef.value.resetFields()
13281325
this.form = reactive({})
13291326
this.isFiltered = false
13301327
this.inputKey = null
13311328
this.inputValue = null
13321329
this.searchQuery = null
13331330
this.paramsFilter = {}
1331+
1332+
const refreshAccountOptions = ['account', 'domainid'].every((field) => {
1333+
return this.fields.some((searchViewField) => searchViewField.name === field)
1334+
})
1335+
if (refreshAccountOptions) {
1336+
await this.fetchDynamicFieldData('account')
1337+
}
1338+
13341339
this.$emit('search', this.paramsFilter)
13351340
},
13361341
handleSubmit () {

0 commit comments

Comments
 (0)