Skip to content

Commit

Permalink
Merge pull request #41 from educorvi/feat/rewrite-side-branches/JSO-17
Browse files Browse the repository at this point in the history
fix data loading for arrays
  • Loading branch information
neferin12 authored Dec 3, 2024
2 parents e510b15 + 0ec8fd9 commit 7f5d2d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion vue-json-form/src/components/LayoutElements/Control.vue
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ watch(jsonElement, () => {
});
onMounted(() => {
formData.value[savePath] = defaultFormData.value[savePath];
// Coalescing is needed because if this field is an array item, the value is set by ArrayControl due to
// the computed scope
formData.value[savePath] =
defaultFormData.value[savePath] ?? formData.value[savePath];
});
onBeforeUnmount(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { generateUUID, VJF_ARRAY_ITEM_PREFIX } from '@/Commons';
import { BButton } from 'bootstrap-vue-next';
import { getComponent, useFormStructureStore } from '@/stores/formStructure';
import draggable from 'vuedraggable/src/vuedraggable';
import { ref, nextTick, onMounted, computed } from 'vue';
import { ref, nextTick, onMounted, computed, onBeforeMount } from 'vue';
import ArrayItem from '@/renderings/bootstrap/controls/Array/ArrayItem.vue';
import PlusIcon from '@/assets/icons/PlusIcon.vue';
Expand Down Expand Up @@ -93,8 +93,6 @@ function initArray() {
}
}
initArray();
const allowAddField = computed(() => {
if (!formData.value[savePath]) {
initArray();
Expand All @@ -111,6 +109,8 @@ const allowRemoveField = computed(() => {
}
return formData.value[savePath].length > (jsonElement.minItems || 0);
});
onBeforeMount(initArray);
</script>

<template>
Expand Down

0 comments on commit 7f5d2d9

Please sign in to comment.