@@ -173,13 +173,6 @@ export default {
173173 this .deployasistemplate = json .listtemplatesresponse .template [0 ].deployasis
174174 })
175175 },
176- filterOrReadOnlyDetails () {
177- for (var i = 0 ; i < this .details .length ; i++ ) {
178- if (! this .allowEditOfDetail (this .details [i].name )) {
179- this .details .splice (i, 1 )
180- }
181- }
182- },
183176 allowEditOfDetail (name ) {
184177 if (this .resource .readonlydetails ) {
185178 if (this .resource .readonlydetails .split (' ,' ).map (item => item .trim ()).includes (name)) {
@@ -211,6 +204,27 @@ export default {
211204 (this .resource .domainid === this .$store .getters .userInfo .domainid && this .resource .account === this .$store .getters .userInfo .account ) ||
212205 this .resource .project && this .resource .projectid === this .$store .getters .project .id
213206 },
207+ getDetailsParam (details ) {
208+ var params = {}
209+ var filteredDetails = details
210+ if (this .resource .readonlydetails && filteredDetails) {
211+ filteredDetails = []
212+ var readOnlyDetailNames = this .resource .readonlydetails .split (' ,' ).map (item => item .trim ())
213+ for (var detail of this .details ) {
214+ if (! readOnlyDetailNames .includes (detail .name )) {
215+ filteredDetails .push (detail)
216+ }
217+ }
218+ }
219+ if (filteredDetails .length === 0 ) {
220+ params .cleanupdetails = true
221+ } else {
222+ filteredDetails .forEach (function (item , index ) {
223+ params[' details[0].' + item .name ] = item .value
224+ })
225+ }
226+ return params
227+ },
214228 runApi () {
215229 var apiName = ' '
216230 if (this .resourceType === ' UserVm' ) {
@@ -226,14 +240,8 @@ export default {
226240 return
227241 }
228242
229- const params = { id: this .resource .id }
230- if (this .details .length === 0 ) {
231- params .cleanupdetails = true
232- } else {
233- this .details .forEach (function (item , index ) {
234- params[' details[0].' + item .name ] = item .value
235- })
236- }
243+ var params = { id: this .resource .id }
244+ params = Object .assign (params, this .getDetailsParam (this .details ))
237245 this .loading = true
238246 api (apiName, params).then (json => {
239247 var details = {}
@@ -259,18 +267,19 @@ export default {
259267 this .error = this .$t (' message.error.provide.setting' )
260268 return
261269 }
270+ if (! this .allowEditOfDetail (this .newKey )) {
271+ this .error = this .$t (' error.unable.to.proceed' )
272+ return
273+ }
262274 this .error = false
263275 this .details .push ({ name: this .newKey , value: this .newValue })
264- this .filterOrReadOnlyDetails ()
265276 this .runApi ()
266277 },
267278 updateDetail (index ) {
268- this .filterOrReadOnlyDetails ()
269279 this .runApi ()
270280 },
271281 deleteDetail (index ) {
272282 this .details .splice (index, 1 )
273- this .filterOrReadOnlyDetails ()
274283 this .runApi ()
275284 },
276285 onShowAddDetail () {
0 commit comments