Commit 424da58a authored by Yoran Hillion's avatar Yoran Hillion
Browse files

(formrenderer) : Quick and dirty form prefill

parent 1d4748fe
{
"name": "@vue-unistra/unistra-formbuilder",
"version": "2.0.6-test",
"version": "2.0.7-test",
"main": "dist/index.js",
"files": [
"dist/*",
......
<template>
<v-form ref="form"
lazy-validation
@submit.prevent="submitForm">
<usf-field v-for="(field, index) in root"
:key="field.id"
:field-id="field"
:field-index="index"
<v-form
ref="form"
lazy-validation
@submit.prevent="submitForm"
>
<usf-field
v-for="(field, index) in root"
:key="field.id"
:field-id="field"
:field-index="index"
/>
<v-btn block
:color="submitButtonColor"
:disabled="isSubmitButtonDisabled"
:type="submitButtonType">
<v-btn
block
:color="submitButtonColor"
:disabled="isSubmitButtonDisabled"
:type="submitButtonType"
>
{{ submitButtonText }}
</v-btn>
</v-form>
......@@ -57,6 +62,11 @@ export default {
default: () => ({}),
required: false,
},
submittedData: {
type: Object,
default: () => ({}),
required: false,
},
},
computed: {
...mapState('form', ['root']),
......@@ -93,6 +103,13 @@ export default {
this.$store.dispatch('user/update', value);
},
},
submittedData: {
deep: true,
immediate: true,
handler(value) {
this.$store.dispatch('submission/update', value);
},
},
},
};
</script>
......@@ -2,11 +2,16 @@ const resetState = ({ commit }) => {
commit('RESET_STATE');
};
const update = ({ commit }, payload) => {
commit('UPDATE', payload);
};
const updateValue = ({ commit }, payload) => {
commit('UPDATE_VALUE', payload);
};
export default {
resetState,
update,
updateValue,
};
......@@ -4,11 +4,16 @@ const RESET_STATE = (state) => {
Object.keys(state).forEach(key => delete state[key]);
};
const UPDATE = (state, payload) => {
Object.entries(payload).map(([key, value]) => Vue.set(state, key, value));
};
const UPDATE_VALUE = (state, payload) => {
Vue.set(state, payload.key, payload.value);
};
export default {
RESET_STATE,
UPDATE,
UPDATE_VALUE,
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment