From 775739d751bff99cfad9b10ed90a7d8e986f6637 Mon Sep 17 00:00:00 2001 From: davidjumani Date: Sat, 20 Jun 2020 09:03:35 +0000 Subject: [PATCH] components: Fix show details in settings tab (#433) Fixes #393 Signed-off-by: Rohit Yadav --- ui/src/components/view/DetailSettings.vue | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ui/src/components/view/DetailSettings.vue b/ui/src/components/view/DetailSettings.vue index bb8e7366cd4..e97ca6cc3e8 100644 --- a/ui/src/components/view/DetailSettings.vue +++ b/ui/src/components/view/DetailSettings.vue @@ -136,17 +136,17 @@ export default { ) }, updateResource (resource) { + this.details = [] if (!resource) { return } this.resource = resource this.resourceType = this.$route.meta.resourceType - if (!resource.details) { - return + if (resource.details) { + this.details = Object.keys(this.resource.details).map(k => { + return { name: k, value: this.resource.details[k], edit: false } + }) } - this.details = Object.keys(this.resource.details).map(k => { - return { name: k, value: this.resource.details[k], edit: false } - }) api('listDetailOptions', { resourcetype: this.resourceType, resourceid: this.resource.id }).then(json => { this.detailOptions = json.listdetailoptionsresponse.detailoptions.details }) @@ -185,15 +185,19 @@ export default { } const params = { id: this.resource.id } - this.details.forEach(function (item, index) { - params['details[0].' + item.name] = item.value - }) + if (this.details.length === 0) { + params.cleanupdetails = true + } else { + this.details.forEach(function (item, index) { + params['details[0].' + item.name] = item.value + }) + } this.loading = true api(apiName, params).then(json => { var details = {} - if (this.resourceType === 'UserVm') { + if (this.resourceType === 'UserVm' && json.updatevirtualmachineresponse.virtualmachine.details) { details = json.updatevirtualmachineresponse.virtualmachine.details - } else if (this.resourceType === 'Template') { + } else if (this.resourceType === 'Template' && json.updatetemplateresponse.template.details) { details = json.updatetemplateresponse.template.details } this.details = Object.keys(details).map(k => {