Skip to content

Commit 3347bd0

Browse files
davidjumanirp-
authored andcommitted
ui: show VR offering when provider is VR (#4988)
* ui: show VR offering when provider is VR * send serviceofferingid not index
1 parent 1ef2fdd commit 3347bd0

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

ui/src/components/CheckBoxSelectPair.vue

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<a-form-item class="pair-select-container" :label="selectLabel" v-if="this.checked">
2424
<a-select
2525
v-decorator="[selectDecorator, {
26-
initialValue: this.getSelectInitialValue()
26+
initialValue: selectedOption ? selectedOption : this.getSelectInitialValue()
2727
}]"
2828
showSearch
2929
optionFilterProp="children"
@@ -80,23 +80,16 @@ export default {
8080
return array !== null && array !== undefined && Array.isArray(array) && array.length > 0
8181
},
8282
getSelectInitialValue () {
83-
if (this.arrayHasItems(this.selectOptions)) {
84-
for (var i = 0; i < this.selectOptions.length; i++) {
85-
if (this.selectOptions[i].enabled !== false) {
86-
return this.selectOptions[i].name
87-
}
88-
}
89-
}
90-
return ''
83+
const provider = this.selectOptions?.filter(x => x.enabled)?.[0]?.name || ''
84+
this.handleSelectChange(provider)
85+
return provider
9186
},
9287
handleCheckChange (e) {
9388
this.checked = e.target.checked
94-
if (this.checked && this.arrayHasItems(this.selectOptions)) {
95-
this.selectedOption = this.selectOptions[0].name
96-
}
9789
this.$emit('handle-checkpair-change', this.resourceKey, this.checked, '')
9890
},
9991
handleSelectChange (val) {
92+
this.selectedOption = val
10093
this.$emit('handle-checkpair-change', this.resourceKey, this.checked, val)
10194
}
10295
}

ui/src/views/offering/AddNetworkOffering.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
message: `${this.$t('message.error.select')}`
229229
}
230230
],
231-
initialValue: 0
231+
initialValue: this.serviceOfferings.length > 0 ? this.serviceOfferings[0].id : ''
232232
}]"
233233
showSearch
234234
optionFilterProp="children"
@@ -237,7 +237,7 @@
237237
}"
238238
:loading="serviceOfferingLoading"
239239
:placeholder="this.$t('label.serviceofferingid')">
240-
<a-select-option v-for="(opt, optIndex) in this.serviceOfferings" :key="optIndex">
240+
<a-select-option v-for="(opt) in this.serviceOfferings" :key="opt.id">
241241
{{ opt.name || opt.description }}
242242
</a-select-option>
243243
</a-select>

0 commit comments

Comments
 (0)