File tree 5 files changed +48
-8
lines changed
5 files changed +48
-8
lines changed Original file line number Diff line number Diff line change 22
22
max: undefined ,
23
23
min: undefined ,
24
24
name: sch .name ,
25
+ range: undefined ,
25
26
type: sch .type ,
26
27
option: ' ' ,
27
28
immutable: sch .name === ' id'
47
48
// float: 'Float',
48
49
number: ' Number' ,
49
50
string: ' String' ,
50
- // timestamp: 'Timestamp',
51
+ timestamp: ' Timestamp' ,
51
52
uuid: ' UUID'
52
53
};
53
54
103
104
/>
104
105
</section >
105
106
</div >
106
- <div class =" flex gap-x-2" v-for =" (sch, idx) in fields" :key =" idx" >
107
+ <div class =" grid grid-cols-4 gap-x-2" v-for =" (sch, idx) in fields" :key =" idx" >
107
108
<section class =" form-control mt-2" >
108
109
<FormInput
109
110
:disabled =" true"
158
159
/>
159
160
</section >
160
161
<!-- ================== -->
162
+ <!-- ======== TIMESTAMP -->
163
+ <!-- ================== -->
164
+ <section
165
+ v-show =" sch.value.type === 'timestamp'"
166
+ class =" form-control mt-2 col-span-2"
167
+ >
168
+ <CalendarPicker
169
+ :disabled =" isDisabled"
170
+ :name =" `schema[${idx}].range`"
171
+ />
172
+ </section >
161
173
</div >
162
174
<section class =" mt-10" >
163
175
<Button :disabled =" isDisabled" size =" sm" @click =" handleClose" >
Original file line number Diff line number Diff line change 3
3
import useModelData from ' ~~/stores/useModelData' ;
4
4
import ModalCreateModelData from ' ~~/components/modal/createModelData.vue' ;
5
5
import ModalConfirm from ' ~~/components/modal/confirm.vue' ;
6
+ import format from ' date-fns/format' ;
7
+
8
+ type Schema = {
9
+ name: string ;
10
+ type: string ;
11
+ }
6
12
7
13
defineProps <{
8
- schema: { name : string ; type : string } [];
14
+ schema: Schema [];
9
15
}>();
10
16
11
17
const modelData = useModelData ();
25
31
select .clear ();
26
32
},
27
33
});
34
+
35
+ const render = (model : { schema: any }, schema : Schema ) => {
36
+ if (schema .type === ' timestamp' ) {
37
+ const parsedDate = Date .parse (model .schema [schema .name ]);
38
+ return format (parsedDate , ' MMMM d, yyy' );
39
+ }
40
+
41
+ return model .schema [schema .name ];
42
+ };
28
43
</script >
29
44
30
45
<template >
72
87
</tr >
73
88
</thead >
74
89
<tbody >
75
- <TableLoader v-if =" modelData.isLoading" :colspan =" 4 " />
90
+ <TableLoader v-if =" modelData.isLoading" :colspan =" schema.length + 2 " />
76
91
<tr v-for =" md in modelData.list" v-else :key =" md.id" >
77
92
<td colspan =" 2" >
78
93
<input
86
101
v-for =" sch in schema"
87
102
class =" font-normal normal-case text-base"
88
103
>
89
- {{ md.schema[sch.name as any] }}
104
+ {{ render(md, sch) }}
90
105
</td >
91
106
</tr >
92
107
</tbody >
Original file line number Diff line number Diff line change 6
6
7
7
<template >
8
8
<tr >
9
- <td :colspan =" colspan" >
10
- <div class =" flex h-full w-full" >
9
+ <td rowspan = " 4 " :colspan =" colspan" >
10
+ <figure class =" flex mt-32 w-full" >
11
11
<LoaderSpinner />
12
- </div >
12
+ </figure >
13
13
</td >
14
14
</tr >
15
15
</template >
Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ type FakeSchema = {
7
7
min ?: number ;
8
8
name : string ;
9
9
option : string ;
10
+ range : {
11
+ start : string ;
12
+ end : string ;
13
+ } ;
10
14
type : string ;
11
15
} ;
12
16
Original file line number Diff line number Diff line change @@ -79,6 +79,10 @@ type FakeSchema = {
79
79
min ?: number ;
80
80
name : string ;
81
81
option : string ;
82
+ range : {
83
+ start : string ;
84
+ end : string ;
85
+ } ;
82
86
type : string ;
83
87
} ;
84
88
@@ -94,6 +98,11 @@ function setValue(schema: FakeSchema) {
94
98
return uuidv4 ( ) ;
95
99
case 'boolean' :
96
100
return faker . datatype . boolean ( ) ;
101
+ case 'timestamp' :
102
+ return faker . date . between ( {
103
+ from : schema . range . start ,
104
+ to : schema . range . end
105
+ } )
97
106
}
98
107
}
99
108
You can’t perform that action at this time.
0 commit comments