Skip to content

Commit bc3c54a

Browse files
author
Simon Eldevig
committed
fix: resolve issues with objects and arrays
It was possible to change property name on object and arrays.
1 parent 788c82e commit bc3c54a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/components/RecursiveCollapse.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="d-flex align-items-center justify-content-between" :class="{'mb-3' : !isSubChild}">
88
<div v-if="isSubChild">
99
<h1 v-show="!editPropertyName" class="h3">{{ propertyName }}</h1>
10-
<MazInput v-show="editPropertyName" ref="propertyName" v-model="newPropertyName" placeholder="Property name" size="sm" @change="updateModel" @blur="editPropertyName = false" />
10+
<MazInput v-show="editPropertyName" ref="propertyName" v-model="newPropertyName" placeholder="Property name" size="sm" @change="updateModel" @blur="closePropEditor" />
1111
</div>
1212
<div v-else class="d-flex justify-content-between w-100">
1313
<h1 class="h3">{{ id }}</h1>
@@ -143,8 +143,10 @@ export default class RecursiveCollapse extends Vue {
143143
}
144144
145145
setCollapseState () {
146-
this.isOpen = !this.isOpen;
147-
localStorage.setItem(this.data.id, this.isOpen.toString());
146+
if (!this.editPropertyName) {
147+
this.isOpen = !this.isOpen;
148+
localStorage.setItem(this.data.id, this.isOpen.toString());
149+
}
148150
}
149151
150152
editPropName (): void {
@@ -211,6 +213,12 @@ export default class RecursiveCollapse extends Vue {
211213
});
212214
}
213215
216+
closePropEditor (): void {
217+
setTimeout(() => {
218+
this.editPropertyName = false;
219+
}, 100);
220+
}
221+
214222
deleteProp (): void {
215223
this.$store.dispatch('deleteModelProperty', {
216224
id: this.dataModel.id

src/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const renameObjectKey = (oldObject: BaseDTO, oldKey: string, newKey: string): Ba
99
acc[val] = oldObject[val];
1010
}
1111

12-
if (oldObject[val] && (oldObject[val].type === 'array' || oldObject[val].type === 'object')) {
12+
if (oldObject[val] && acc[val] && (oldObject[val].type === 'array' || oldObject[val].type === 'object')) {
1313
const clonedObject = Vue.prototype.$lodash.cloneDeep(acc[val].value);
1414
acc[val].value = renameObjectKey(clonedObject, oldKey, newKey);
1515
}

0 commit comments

Comments
 (0)