Skip to content

Commit d34fdf3

Browse files
[DEV] update boolean field more. working on getting conditional stuff working with when function and starting some callbacks
1 parent c1d6191 commit d34fdf3

File tree

7 files changed

+232
-250
lines changed

7 files changed

+232
-250
lines changed

src/plugin/VStepperForm.vue

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
:key="field.name"
1919
>
2020
<input
21-
v-if="field.type === 'hidden'"
21+
v-if="field.type === 'hidden' || !field.type"
2222
v-model="modelValue[field.name]"
23+
:name="field.name"
2324
type="hidden"
2425
/>
2526

@@ -30,6 +31,7 @@
3031
v-model="modelValue[field.name]"
3132
:field="field"
3233
:settings="settings"
34+
@update:modelValue="callback()"
3335
/>
3436

3537
<Fields.VSFCheckbox
@@ -51,6 +53,7 @@
5153
v-model="modelValue[field.name]"
5254
:field="field"
5355
:settings="settings"
56+
@update:modelValue="callback()"
5457
/>
5558

5659
<Fields.VSFFileInput
@@ -67,28 +70,12 @@
6770
:settings="settings"
6871
/>
6972

70-
<!-- <v-radio-group
71-
v-if="field.type === 'radio'"
72-
v-model="modelValue[field.name]"
73-
:inline="field.inline"
74-
>
75-
<template #label>
76-
{{ field.label }} <span
77-
v-if="field.required"
78-
class="text-error ms-1"
79-
>*</span>
80-
</template>
81-
<v-radio
82-
v-for="option in field.options"
83-
:key="option.value"
84-
:density="field.density || stepperSettings.density"
85-
:label="option.label"
86-
:value="option.value"></v-radio>
87-
</v-radio-group> -->
88-
89-
90-
91-
73+
<!-- TODO: Select Field -->
74+
<!-- TODO: Color Picker Field -->
75+
<!-- TODO: User Select Field -->
76+
<!-- TODO: Autocomplete Field -->
77+
<!-- TODO: Date Field -->
78+
<!-- TODO: Combobox Field (tbd) -->
9279

9380
<Fields.VSFSwitch
9481
v-if="field.type === 'switch'"
@@ -114,6 +101,7 @@ import {
114101
import componentEmits from './utils/emits';
115102
import * as Fields from './components/index';
116103
import { globalOptions } from '@/plugin/';
104+
// import { watchDeep } from '@vueuse/core';
117105
118106
119107
@@ -126,6 +114,8 @@ const injectedOptions = inject(globalOptions, {});
126114
127115
// -------------------------------------------------- Props //
128116
const props = withDefaults(defineProps<Props>(), { ...AllProps });
117+
118+
const { fields } = toRefs(props);
129119
// console.log('AllProps', props);
130120
// console.log('props', AllProps);
131121
const stepperSettings = reactive({ ...attrs, ...props, ...injectedOptions });
@@ -144,7 +134,35 @@ const settings = ref({
144134
const modelValue = defineModel<any>();
145135
146136
137+
onMounted(() => {
138+
callback();
139+
});
140+
141+
142+
143+
// watch(() => fields.value, () => {
144+
// console.log('xxxxxxxxxxxxx fields update', fields.value);
145+
// }), {
146+
// deep: true,
147+
// };
148+
149+
// watchDeep(fields.value, () => {
150+
// console.log('xxxxxxxxxxxxx fields update', fields.value);
151+
// });
152+
153+
154+
function callback() {
155+
Object.values(fields.value).forEach((field) => {
156+
if (field.when) {
157+
const response = field.when(modelValue.value);
158+
const fieldIdx = fields.value.findIndex((f) => f.name === field.name);
147159
160+
if (fields.value[fieldIdx]) {
161+
fields.value[fieldIdx].disabled = response;
162+
}
163+
}
164+
});
165+
}
148166
149167
console.log({
150168
emit,

0 commit comments

Comments
 (0)