Skip to content

Commit 6654361

Browse files
bernardodemarcodhslove
authored andcommitted
UI: Fix selection of domain filters in the SearchView component (apache#10386)
1 parent a0c746f commit 6654361

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
@@ -248,7 +248,8 @@ export default {
248248
this.fetchDynamicFieldData(fieldname, event.target.value)
249249
},
250250
onSelectFieldChange (fieldname) {
251-
if (fieldname === 'domainid') {
251+
const fetchAccountOptions = fieldname === 'domainid' && this.fields.some((field) => field.name === 'account')
252+
if (fetchAccountOptions) {
252253
this.fetchDynamicFieldData('account')
253254
}
254255
},
@@ -716,10 +717,6 @@ export default {
716717
if (Array.isArray(arrayField)) {
717718
this.fillFormFieldValues()
718719
}
719-
if (networkIndex > -1) {
720-
this.fields[networkIndex].loading = false
721-
}
722-
this.fillFormFieldValues()
723720
})
724721
},
725722
initFormFieldData () {
@@ -787,7 +784,7 @@ export default {
787784
params.domainid = this.form.domainid
788785
}
789786
api('listAccounts', params).then(json => {
790-
var account = json.listaccountsresponse.account
787+
let account = json?.listaccountsresponse?.account || []
791788
if (this.form.domainid) {
792789
account = account.filter(a => a.domainid === this.form.domainid)
793790
}
@@ -1349,14 +1346,22 @@ export default {
13491346
this.searchQuery = value
13501347
this.$emit('search', { searchQuery: this.searchQuery })
13511348
},
1352-
onClear () {
1349+
async onClear () {
13531350
this.formRef.value.resetFields()
13541351
this.form = reactive({})
13551352
this.isFiltered = false
13561353
this.inputKey = null
13571354
this.inputValue = null
13581355
this.searchQuery = null
13591356
this.paramsFilter = {}
1357+
1358+
const refreshAccountOptions = ['account', 'domainid'].every((field) => {
1359+
return this.fields.some((searchViewField) => searchViewField.name === field)
1360+
})
1361+
if (refreshAccountOptions) {
1362+
await this.fetchDynamicFieldData('account')
1363+
}
1364+
13601365
this.$emit('search', this.paramsFilter)
13611366
},
13621367
handleSubmit () {

0 commit comments

Comments
 (0)