Skip to content

Commit c170ec4

Browse files
shwstppryadvr
authored andcommitted
offering: update offering form should allow domain option (#305)
Fixes: #301 Fixes: #302 Fixes: #303 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 604ea21 commit c170ec4

1 file changed

Lines changed: 27 additions & 20 deletions

File tree

‎ui/src/views/offering/UpdateOfferingAccess.vue‎

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
layout="vertical">
2525

2626
<a-form-item :label="$t('ispublic')" v-show="this.isAdmin()">
27-
<a-switch v-decorator="['ispublic', {initialValue: this.isPublic}]" :defaultChecked="this.offeringIsPublic" @change="val => { this.offeringIsPublic = val }" />
27+
<a-switch v-decorator="['ispublic', { initialValue: this.offeringIsPublic }]" :checked="this.offeringIsPublic" @change="val => { this.offeringIsPublic = val }" />
2828
</a-form-item>
2929

3030
<a-form-item :label="$t('domainid')" v-if="!this.offeringIsPublic">
@@ -36,15 +36,16 @@
3636
required: true,
3737
message: 'Please select option'
3838
}
39-
]
39+
],
40+
initialValue: this.selectedDomains
4041
}]"
4142
showSearch
4243
optionFilterProp="children"
4344
:filterOption="(input, option) => {
4445
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
4546
}"
4647
:loading="domainLoading"
47-
:placeholder="this.$t('label.domain')">
48+
:placeholder="this.apiParams.domainid.description">
4849
<a-select-option v-for="(opt, optIndex) in this.domains" :key="optIndex">
4950
{{ opt.name || opt.description }}
5051
</a-select-option>
@@ -73,7 +74,7 @@
7374
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
7475
}"
7576
:loading="zoneLoading"
76-
:placeholder="this.$t('zone')">
77+
:placeholder="this.apiParams.zoneid.description">
7778
<a-select-option v-for="(opt, optIndex) in this.zones" :key="optIndex">
7879
{{ opt.name || opt.description }}
7980
</a-select-option>
@@ -103,7 +104,6 @@ export default {
103104
},
104105
data () {
105106
return {
106-
offeringType: '',
107107
selectedDomains: [],
108108
selectedZones: [],
109109
offeringIsPublic: false,
@@ -116,16 +116,6 @@ export default {
116116
},
117117
beforeCreate () {
118118
this.form = this.$form.createForm(this)
119-
},
120-
created () {
121-
this.zones = [
122-
{
123-
id: 'all',
124-
name: this.$t('label.all.zone')
125-
}
126-
]
127-
},
128-
mounted () {
129119
switch (this.$route.meta.name) {
130120
case 'computeoffering':
131121
this.offeringType = 'ServiceOffering'
@@ -142,6 +132,21 @@ export default {
142132
default:
143133
this.offeringType = this.$route.meta.name
144134
}
135+
this.apiParams = {}
136+
this.apiParamsConfig = this.$store.getters.apis['update' + this.offeringType] || {}
137+
this.apiParamsConfig.params.forEach(param => {
138+
this.apiParams[param.name] = param
139+
})
140+
},
141+
created () {
142+
this.zones = [
143+
{
144+
id: 'all',
145+
name: this.$t('label.all.zone')
146+
}
147+
]
148+
},
149+
mounted () {
145150
this.fetchData()
146151
},
147152
methods: {
@@ -186,7 +191,7 @@ export default {
186191
for (var i = 0; i < offeringDomainIds.length; i++) {
187192
for (var j = 0; j < this.domains.length; j++) {
188193
if (offeringDomainIds[i] === this.domains[j].id) {
189-
this.selectedDomains = this.selectedDomains.concat(j)
194+
this.selectedDomains.push(j)
190195
}
191196
}
192197
}
@@ -195,9 +200,11 @@ export default {
195200
this.offeringIsPublic = true
196201
}
197202
}
198-
this.form.setFieldsValue({
199-
domainid: this.selectedDomains
200-
})
203+
if ('domainid' in this.form.fieldsStore.fieldsMeta) {
204+
this.form.setFieldsValue({
205+
domainid: this.selectedDomains
206+
})
207+
}
201208
},
202209
updateZoneSelection () {
203210
var offeringZoneIds = this.resource.zoneid
@@ -207,7 +214,7 @@ export default {
207214
for (var i = 0; i < offeringZoneIds.length; i++) {
208215
for (var j = 0; j < this.zones.length; j++) {
209216
if (offeringZoneIds[i] === this.zones[j].id) {
210-
this.selectedZones = this.selectedZones.concat(j)
217+
this.selectedZones.push(j)
211218
}
212219
}
213220
}

0 commit comments

Comments
 (0)