Skip to content

Commit cfc3609

Browse files
[DEV] testing and fixing props
1 parent 37ac221 commit cfc3609

File tree

6 files changed

+45
-11
lines changed

6 files changed

+45
-11
lines changed

src/plugin/components/fields/VSFCheckbox/VSFCheckbox.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
</v-label>
4949

5050
<div
51+
:id="field?.id"
5152
:class="{
5253
'v-selection-control-group': !field.inline,
5354
}"
@@ -62,8 +63,9 @@
6263
:validate-on-model-update="false"
6364
>
6465
<v-checkbox
65-
v-model="modelValue"
6666
v-bind="boundSettings"
67+
:id="option.id"
68+
v-model="modelValue"
6769
:error="errorMessage ? errorMessage?.length > 0 : false"
6870
:error-messages="errorMessage"
6971
:label="option.label"

src/plugin/components/fields/VSFRadio/VSFRadio.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
/>
2020
</v-label>
2121

22-
<div :style="checkboxContainerStyle">
22+
<div
23+
:id="field?.groupId"
24+
:style="checkboxContainerStyle"
25+
>
2326
<v-radio-group
2427
v-model="modelValue"
2528
:append-icon="field?.appendIcon"
@@ -45,7 +48,8 @@
4548
>
4649
<v-radio
4750
v-bind="boundSettings"
48-
:error="errorMessage ? errorMessage?.length > 0 : false"
51+
:id="undefined"
52+
:error="hasErrors"
4953
:error-messages="errorMessage"
5054
:label="option.label"
5155
:style="radioStyle"

src/plugin/components/fields/VSFRadio/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface RadioGroupProps {
1111
error?: VRadioGroup['error'];
1212
errorMessages?: VRadioGroup['errorMessages'];
1313
hideDetails?: VRadioGroup['hideDetails'];
14+
groupId?: VRadioGroup['id'];
1415
maxErrors?: VRadioGroup['maxErrors'];
1516
maxWidth?: VRadioGroup['maxWidth'];
1617
minWidth?: VRadioGroup['minWidth'];

src/plugin/components/fields/VuetifyField/VuetifyField.vue

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
:is="component"
1010
v-model="modelValue"
1111
v-bind="boundSettings"
12-
:error="errorMessage ? errorMessage?.length > 0 : false"
13-
:error-messages="errorMessage"
12+
:error="hasErrors"
13+
:error-messages="errorMessage || field.errorMessages"
1414
:items="fieldItems"
1515
@blur="onActions(validate, 'blur')"
1616
@change="onActions(validate, 'change')"
@@ -62,13 +62,28 @@ async function onActions(validate: FieldValidateResult, action: ValidateAction):
6262
}
6363
6464
const fieldItems = computed(() => field?.items ? field.items as any : undefined);
65+
const fieldType = computed(() => {
66+
if (field.type === 'color') {
67+
return 'text';
68+
}
69+
70+
return field.type;
71+
});
72+
const hasErrors = computed(() => {
73+
let err = field?.error;
74+
75+
err = field?.errorMessages ? field.errorMessages.length > 0 : err;
76+
77+
return err;
78+
});
6579
6680
// -------------------------------------------------- Bound Settings //
6781
const bindSettings = computed(() => ({
6882
...field,
6983
color: field.color || settings?.color,
7084
density: field.density || settings?.density,
7185
hideDetails: field.hideDetails || settings?.hideDetails,
86+
type: fieldType.value,
7287
variant: field.variant || settings?.variant,
7388
}));
7489

src/plugin/components/shared/PageContainer.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@
6060
/>
6161

6262
<!-- ================================================== Select -->
63-
<Fields.VSFSelect
63+
<!-- <Fields.VSFSelect
6464
v-if="field.type === 'select'"
6565
v-model="modelValue[field.name]"
6666
:field="field"
6767
:settings="settings"
6868
@validate="onValidate"
69-
/>
69+
/> -->
7070

7171
<!-- <Fields.VSFAutocomplete
7272
v-if="field.type === 'autocomplete'"
@@ -76,13 +76,13 @@
7676
@validate="onValidate"
7777
/> -->
7878

79-
<Fields.VSFCombobox
79+
<!-- <Fields.VSFCombobox
8080
v-if="field.type === 'combobox'"
8181
v-model="modelValue[field.name]"
8282
:field="field"
8383
:settings="settings"
8484
@validate="onValidate"
85-
/>
85+
/> -->
8686

8787
<!-- ================================================== Switch -->
8888
<Fields.VSFSwitch
@@ -94,13 +94,13 @@
9494
/>
9595

9696
<!-- ========================= Color Field -->
97-
<Fields.VSFColorField
97+
<!-- <Fields.VSFColorField
9898
v-if="field.type === 'color'"
9999
v-model="modelValue[field.name]"
100100
:field="field"
101101
:settings="settings"
102102
@validate="onValidate"
103-
/>
103+
/> -->
104104

105105

106106
<!-- ! ================================================== Vuetify Field -->
@@ -190,11 +190,13 @@ import type {
190190
} from '../../types/index';
191191
import {
192192
VAutocomplete,
193+
VCombobox,
193194
VFileInput,
194195
VSelect,
195196
VTextarea,
196197
VTextField,
197198
} from 'vuetify/components';
199+
import { VColorField } from '@wdns/vuetify-color-field';
198200
199201
200202
export interface FieldLabelProps {
@@ -223,6 +225,14 @@ function getComponent(fieldType: string): any {
223225
return markRaw(VAutocomplete);
224226
}
225227
228+
if (fieldType === 'color') {
229+
return markRaw(VColorField);
230+
}
231+
232+
if (fieldType === 'combobox') {
233+
return markRaw(VCombobox);
234+
}
235+
226236
if (fieldType === 'file') {
227237
return markRaw(VFileInput);
228238
}

src/plugin/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ export interface Field {
124124
density?: Props['density'];
125125
disabled?: boolean | ((value: any) => boolean);
126126
error?: boolean;
127+
errorMessages?: string | string[];
127128
hideDetails?: GlobalHideDetails;
128129
hidden?: boolean;
130+
id?: string;
129131
items?: readonly any[] | undefined;
130132
label?: string;
131133
name: string;

0 commit comments

Comments
 (0)