This repository was archived by the owner on Jun 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +25
-12
lines changed Expand file tree Collapse file tree 4 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -53,10 +53,8 @@ import {
53
53
EmailInput ,
54
54
FormValidation ,
55
55
PasswordInput ,
56
- TextAreaInput ,
57
56
CheckboxInput ,
58
57
RadioInput ,
59
- InputBase ,
60
58
email ,
61
59
pattern ,
62
60
ColorInput ,
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ import DynamicInput from '../dynamic-input/DynamicInput.vue';
51
51
52
52
import { InputBase , FormControl } from ' ../../core/models' ;
53
53
import { dynamicFormsSymbol } from ' ../../useApi' ;
54
+ import { removeEmpty } from ' ../../core/utils/helpers' ;
54
55
55
56
const props = {
56
57
form: {
@@ -145,9 +146,9 @@ export default defineComponent({
145
146
}
146
147
});
147
148
148
- function valueChange(changedValue : any ) {
149
+ function valueChange(changedValue ) {
149
150
Object .assign (formValues , changedValue );
150
- ctx .emit (' changed' , formValues );
151
+ ctx .emit (' changed' , removeEmpty ( formValues ) );
151
152
}
152
153
153
154
function mapControls(empty ? ) {
Original file line number Diff line number Diff line change @@ -25,12 +25,18 @@ export type InputType =
25
25
| UrlInput
26
26
| CustomInput ;
27
27
28
+ type ValidationError = {
29
+ text : string ;
30
+ // eslint-disable-next-line
31
+ value : any ;
32
+ } ;
33
+
28
34
type ValidationErrors = {
29
- [ key : string ] : any ;
35
+ [ key : string ] : ValidationError ;
30
36
} ;
31
37
32
38
interface ValidatorFn {
33
- ( control : FormControl < any > | undefined ) : ValidationErrors | null ;
39
+ ( control : FormControl | undefined ) : ValidationErrors | null ;
34
40
}
35
41
36
42
export interface FormValidation {
@@ -39,7 +45,7 @@ export interface FormValidation {
39
45
}
40
46
41
47
export interface InputBase {
42
- value : any ;
48
+ value : boolean | string ;
43
49
name : string ;
44
50
label : string ;
45
51
disabled ?: boolean ;
@@ -53,10 +59,6 @@ export type TextInput = InputBase & {
53
59
type : 'text' ;
54
60
} ;
55
61
56
- /* export interface EmailInput extends InputBase<string> {
57
- type: 'email';
58
- } */
59
-
60
62
export type NumberInput = InputBase & {
61
63
min ?: number ;
62
64
max ?: number ;
@@ -65,7 +67,7 @@ export type NumberInput = InputBase & {
65
67
type : 'number' ;
66
68
} ;
67
69
68
- export type SelectInput < T = any > = InputBase & {
70
+ export type SelectInput < T = boolean | string > = InputBase & {
69
71
type : 'select' ;
70
72
value : T ;
71
73
options ?: { key : string ; value : string ; disabled ?: boolean } [ ] ;
Original file line number Diff line number Diff line change
1
+ /* eslint-disable */
1
2
export const { assign, entries, values, keys } = Object ;
2
3
3
4
export const slugify = ( text : string ) : string =>
@@ -23,6 +24,17 @@ export const isEmpty = (entry: any) => {
23
24
}
24
25
} ;
25
26
27
+ export const removeEmpty = obj =>
28
+ Object . keys ( obj )
29
+ . filter ( k => obj [ k ] != null ) // Remove undef. and null.
30
+ . reduce (
31
+ ( newObj , k ) =>
32
+ typeof obj [ k ] === 'object'
33
+ ? { ...newObj , [ k ] : removeEmpty ( obj [ k ] ) } // Recurse.
34
+ : { ...newObj , [ k ] : obj [ k ] } , // Copy value.
35
+ { } ,
36
+ ) ;
37
+
26
38
export const mockAsync = ( success , timeout , value ) => {
27
39
return new Promise ( ( resolve , reject ) => {
28
40
setTimeout ( ( ) => {
You can’t perform that action at this time.
0 commit comments