Reset value of interface interface when type gets changed (#4125)

This commit is contained in:
Nitwel
2021-02-17 17:03:38 +01:00
committed by GitHub
parent 274e3950b7
commit 84c52feb71

View File

@@ -12,7 +12,7 @@
</template>
<script lang="ts">
import { defineComponent, computed, PropType, inject, ref } from '@vue/composition-api';
import { defineComponent, computed, PropType, inject, ref, watch } from '@vue/composition-api';
import i18n from '@/lang';
import { getInterfaces } from '@/interfaces';
import { types } from '@/types';
@@ -28,7 +28,7 @@ export default defineComponent({
default: null,
},
},
setup(props) {
setup(props, { emit }) {
const interfaces = getInterfaces();
const values = inject('values', ref<Record<string, any>>({}));
@@ -38,6 +38,13 @@ export default defineComponent({
return values.value[props.typeField];
});
watch(
() => values.value[props.typeField],
() => {
emit('input', null);
}
);
const items = computed(() => {
return interfaces.value
.filter((inter) => inter.relational !== true && inter.system !== true)
@@ -50,7 +57,7 @@ export default defineComponent({
});
});
return { items, selectedType };
return { items, selectedType, values };
},
});
</script>