@dative-gpi/foundation-shared-components 1.0.115 → 1.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/FSDialogForm.vue +22 -2
- package/components/FSDialogFormBody.vue +28 -15
- package/components/FSForm.vue +10 -8
- package/package.json +4 -4
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
#body
|
|
12
12
|
>
|
|
13
13
|
<FSDialogFormBody
|
|
14
|
+
ref="bodyRef"
|
|
14
15
|
v-bind="$attrs"
|
|
15
16
|
:subtitle="$props.subtitle"
|
|
16
17
|
:validation="$props.validation"
|
|
17
18
|
@click:cancelButton="$emit('update:modelValue', false)"
|
|
18
19
|
@click:submitButton="$emit('click:submitButton')"
|
|
19
20
|
@click:validateButton="onValidate"
|
|
21
|
+
@update:isValidForm="isValidForm = $event"
|
|
20
22
|
>
|
|
21
23
|
<template
|
|
22
24
|
v-for="(_, name) in $slots"
|
|
@@ -33,8 +35,8 @@
|
|
|
33
35
|
</template>
|
|
34
36
|
|
|
35
37
|
<script lang="ts">
|
|
36
|
-
import type { PropType} from "vue";
|
|
37
|
-
import { defineComponent } from "vue";
|
|
38
|
+
import type { PropType } from "vue";
|
|
39
|
+
import { defineComponent, ref } from "vue";
|
|
38
40
|
|
|
39
41
|
import FSDialogFormBody from "./FSDialogFormBody.vue";
|
|
40
42
|
import FSDialog from "./FSDialog.vue";
|
|
@@ -74,6 +76,8 @@ export default defineComponent({
|
|
|
74
76
|
},
|
|
75
77
|
emits: ["update:modelValue", "click:validateButton", "click:submitButton"],
|
|
76
78
|
setup(props, { emit }) {
|
|
79
|
+
const bodyRef = ref<typeof FSDialogFormBody | null>(null);
|
|
80
|
+
const isValidForm = ref(false);
|
|
77
81
|
|
|
78
82
|
const onClose = () => {
|
|
79
83
|
if (props.validation) {
|
|
@@ -87,8 +91,24 @@ export default defineComponent({
|
|
|
87
91
|
emit("update:modelValue", false);
|
|
88
92
|
};
|
|
89
93
|
|
|
94
|
+
const resetFormValidation = () => {
|
|
95
|
+
if (bodyRef.value) {
|
|
96
|
+
bodyRef.value.resetFormValidation();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const validateForm = async () => {
|
|
101
|
+
if (bodyRef.value) {
|
|
102
|
+
return await bodyRef.value.validateForm();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
90
106
|
return {
|
|
107
|
+
resetFormValidation,
|
|
108
|
+
validateForm,
|
|
109
|
+
isValidForm,
|
|
91
110
|
onValidate,
|
|
111
|
+
bodyRef,
|
|
92
112
|
onClose
|
|
93
113
|
};
|
|
94
114
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
ref="formRef"
|
|
7
7
|
:variant="$props.variant"
|
|
8
8
|
@submit="onSubmit"
|
|
9
|
-
v-model="
|
|
9
|
+
v-model="isValidForm"
|
|
10
10
|
>
|
|
11
11
|
<FSCol
|
|
12
12
|
gap="24px"
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
</template>
|
|
90
90
|
|
|
91
91
|
<script lang="ts">
|
|
92
|
-
import { computed, defineComponent, type PropType, ref } from "vue";
|
|
92
|
+
import { computed, defineComponent, type PropType, ref, watch } from "vue";
|
|
93
93
|
|
|
94
94
|
import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
|
|
95
95
|
import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
@@ -114,11 +114,6 @@ export default defineComponent({
|
|
|
114
114
|
required: false,
|
|
115
115
|
default: "submit"
|
|
116
116
|
},
|
|
117
|
-
modelValue: {
|
|
118
|
-
type: Boolean,
|
|
119
|
-
required: false,
|
|
120
|
-
default: false
|
|
121
|
-
},
|
|
122
117
|
subtitle: {
|
|
123
118
|
type: String as PropType<string | null>,
|
|
124
119
|
required: false,
|
|
@@ -225,13 +220,13 @@ export default defineComponent({
|
|
|
225
220
|
default: true
|
|
226
221
|
}
|
|
227
222
|
},
|
|
228
|
-
emits: ["click:cancelButton", "click:submitButton", "click:validateButton"],
|
|
223
|
+
emits: ["click:cancelButton", "click:submitButton", "click:validateButton", "update:isValidForm"],
|
|
229
224
|
setup(props, { emit }) {
|
|
230
225
|
const { isMobileSized } = useBreakpoints();
|
|
231
226
|
const { $tr } = useTranslationsProvider();
|
|
232
227
|
|
|
233
|
-
const formRef = ref<
|
|
234
|
-
const
|
|
228
|
+
const formRef = ref<typeof FSForm | null>(null);
|
|
229
|
+
const isValidForm = ref(null);
|
|
235
230
|
|
|
236
231
|
const maxHeight = computed(() => {
|
|
237
232
|
const other = 24 + 24 // Paddings
|
|
@@ -253,8 +248,20 @@ export default defineComponent({
|
|
|
253
248
|
return props.validateButtonLabel ?? $tr("button.validate", "Done");
|
|
254
249
|
});
|
|
255
250
|
|
|
251
|
+
const resetFormValidation = () => {
|
|
252
|
+
if (formRef.value) {
|
|
253
|
+
formRef.value.resetValidation();
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const validateForm = async () => {
|
|
258
|
+
if (formRef.value) {
|
|
259
|
+
return await formRef.value.validate();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
256
263
|
const onSubmit = () => {
|
|
257
|
-
if (
|
|
264
|
+
if (isValidForm.value) {
|
|
258
265
|
emit("click:submitButton");
|
|
259
266
|
}
|
|
260
267
|
};
|
|
@@ -262,17 +269,23 @@ export default defineComponent({
|
|
|
262
269
|
const onValidate = () => {
|
|
263
270
|
emit("click:validateButton");
|
|
264
271
|
};
|
|
272
|
+
|
|
273
|
+
watch(() => isValidForm.value, () => {
|
|
274
|
+
emit("update:isValidForm", isValidForm.value);
|
|
275
|
+
}, { immediate: true });
|
|
265
276
|
|
|
266
277
|
return {
|
|
278
|
+
resetFormValidation,
|
|
267
279
|
validateLabel,
|
|
280
|
+
validateForm,
|
|
281
|
+
isValidForm,
|
|
268
282
|
cancelLabel,
|
|
269
283
|
submitLabel,
|
|
284
|
+
onValidate,
|
|
270
285
|
ColorEnum,
|
|
271
286
|
maxHeight,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
onValidate,
|
|
275
|
-
onSubmit
|
|
287
|
+
onSubmit,
|
|
288
|
+
formRef
|
|
276
289
|
};
|
|
277
290
|
}
|
|
278
291
|
});
|
package/components/FSForm.vue
CHANGED
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
<script lang="ts">
|
|
14
14
|
import type { PropType} from "vue";
|
|
15
|
+
|
|
16
|
+
import type VForm from "vuetify/lib/components/VForm";
|
|
17
|
+
|
|
15
18
|
import { computed, defineComponent, provide, ref } from "vue";
|
|
16
19
|
|
|
17
20
|
export default defineComponent({
|
|
@@ -30,7 +33,7 @@ export default defineComponent({
|
|
|
30
33
|
},
|
|
31
34
|
emits: ["update:modelValue", "submit"],
|
|
32
35
|
setup(props, { emit }) {
|
|
33
|
-
const formRef = ref<
|
|
36
|
+
const formRef = ref<typeof VForm | null>(null);
|
|
34
37
|
const submitted = ref(false);
|
|
35
38
|
|
|
36
39
|
const validateOn = computed((): "submit" | "input" => {
|
|
@@ -44,25 +47,24 @@ export default defineComponent({
|
|
|
44
47
|
event.stopImmediatePropagation();
|
|
45
48
|
event.preventDefault();
|
|
46
49
|
submitted.value = true;
|
|
47
|
-
await
|
|
48
|
-
emit("update:modelValue", !!(
|
|
49
|
-
emit("submit", !!(
|
|
50
|
+
await formRef.value.validate();
|
|
51
|
+
emit("update:modelValue", !!(formRef.value.isValid ?? true));
|
|
52
|
+
emit("submit", !!(formRef.value.isValid ?? true));
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
const validate = async () => {
|
|
53
56
|
submitted.value = true;
|
|
54
|
-
await
|
|
55
|
-
emit("update:modelValue", !!((formRef.value as any).isValid ?? true));
|
|
57
|
+
return await formRef.value.validate();
|
|
56
58
|
};
|
|
57
59
|
|
|
58
60
|
const reset = () => {
|
|
59
61
|
submitted.value = false;
|
|
60
|
-
|
|
62
|
+
formRef.value.reset();
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
const resetValidation = () => {
|
|
64
66
|
submitted.value = false;
|
|
65
|
-
|
|
67
|
+
formRef.value.resetValidation();
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
provide("validateOn", validateOn);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.116",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "1.0.
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "1.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "1.0.116",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "1.0.116"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sass": "1.71.1",
|
|
36
36
|
"sass-loader": "13.3.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "3c68bcc5adea7b444e566b7363d680b64a7f6b21"
|
|
39
39
|
}
|