config_tools: fix vmNameChange event never called issue

fix vmNameChange event never called issue

Tracked-On: #6691
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
Weiyi Feng 2022-06-06 16:13:24 +08:00 committed by acrnsi-robot
parent 12b6faf375
commit 92bc8034be
2 changed files with 53 additions and 43 deletions

View File

@ -304,7 +304,7 @@ export default {
}, },
vmNameChange(newname, oldname) { vmNameChange(newname, oldname) {
let hvdata = this.scenario.hv let hvdata = this.scenario.hv
if (hvdata.FEATURES.hasOwnProperty('IVSHMEM')) { if (hvdata.hasOwnProperty('FEATURES') && hvdata.FEATURES.hasOwnProperty('IVSHMEM')) {
for (let key in hvdata.FEATURES.IVSHMEM.IVSHMEM_REGION) { for (let key in hvdata.FEATURES.IVSHMEM.IVSHMEM_REGION) {
let region = hvdata.FEATURES.IVSHMEM.IVSHMEM_REGION[key] let region = hvdata.FEATURES.IVSHMEM.IVSHMEM_REGION[key]
for (let key1 in region.IVSHMEM_VMS.IVSHMEM_VM) { for (let key1 in region.IVSHMEM_VMS.IVSHMEM_VM) {
@ -382,7 +382,9 @@ export default {
} }
let errorFlag = false let errorFlag = false
errorFlag = this.confirmVmName() errorFlag = this.confirmVmName()
if (errorFlag) {return} if (errorFlag) {
return
}
this.assignVMID() this.assignVMID()
let msg = [ let msg = [
"scenario xml saved\n", "scenario xml saved\n",

View File

@ -67,6 +67,7 @@ export default {
}, },
data() { data() {
return { return {
vmNameCache: '',
currentFormMode: 'BasicConfigType', currentFormMode: 'BasicConfigType',
formProps: { formProps: {
"inline": false, "inline": false,
@ -123,14 +124,21 @@ export default {
dataChange({newValue, oldValue}) { dataChange({newValue, oldValue}) {
let newID = newValue.hasOwnProperty('@id') ? newValue['@id'] : -1; let newID = newValue.hasOwnProperty('@id') ? newValue['@id'] : -1;
let oldID = oldValue.hasOwnProperty('@id') ? oldValue['@id'] : -1; let oldID = oldValue.hasOwnProperty('@id') ? oldValue['@id'] : -1;
if (newID === oldID) {
if (oldValue.name !== newValue.name) {
this.$emit('vmNameChange', newValue.name, oldValue.name)
}
this.$emit('scenarioConfigFormDataUpdate', newID, newValue) if (newID === oldID) {
// skip hv settings
if (newID !== -1) {
if (this.vmNameCache !== newValue.name) {
this.$emit('vmNameChange', newValue.name, this.vmNameCache)
this.vmNameCache = newValue.name;
}
}
this.$emit('scenarioConfigFormDataUpdate', newID, newValue)
} else {
if (newID !== -1) {
this.vmNameCache = newValue.name
}
} }
// this.$emit('update:scenarioData', this.formData)
} }
} }
} }