aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/mixins/QuestionnaireComponent.js
blob: 2ff275019af48dc57e9286fd24502f780c1d2e3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
export const QuestionnaireComponent = {
    emits: ['update:model-value'],
    props: {
        modelValue: Object
    },
    data () {
        return {
            val_clone: {...this.modelValue}
        };
    },
    methods: {
        setDefaultValues(value) {
            this.val_clone = Object.assign(value, this.modelValue);
        }
    },
    watch: {
        val_clone: {
            handler(current) {
                this.$emit('update:model-value', current);
            },
            deep: true
        },
        modelValue(new_val) {
            this.val_clone = new_val;
        }
    }
};