8
8
} from '@plone/volto/components/manage/Widgets/SelectStyling' ;
9
9
import { Input , Pagination , Table } from 'semantic-ui-react' ;
10
10
import { usePagination , useTable } from 'react-table' ;
11
-
11
+ import { useSelector } from 'react-redux' ;
12
12
import { Icon } from '@plone/volto/components' ;
13
13
import React from 'react' ;
14
14
import { compose } from 'redux' ;
@@ -20,13 +20,15 @@ import paginationLeftSVG from '@plone/volto/icons/left-key.svg';
20
20
import paginationRightSVG from '@plone/volto/icons/right-key.svg' ;
21
21
import plusSVG from '@plone/volto/icons/circle-plus.svg' ;
22
22
import { useIntl } from 'react-intl' ;
23
-
23
+ import DatetimeWidget from '@plone/volto/components/manage/Widgets/DatetimeWidget' ;
24
+ import moment from 'moment' ;
24
25
const FieldEditor = ( props ) => {
25
26
const {
26
27
fieldSchema,
27
28
value,
28
29
onChange,
29
30
onChangeSelect,
31
+ onChangeDate,
30
32
onBlur,
31
33
reactSelect,
32
34
} = props ;
@@ -88,6 +90,17 @@ const FieldEditor = (props) => {
88
90
/>
89
91
) ;
90
92
}
93
+ if ( type === 'date' ) {
94
+ return (
95
+ < DatetimeWidget
96
+ id = { `field-${ id } ` }
97
+ title = "date"
98
+ value = { value || defaultValue }
99
+ onChange = { onChangeDate }
100
+ onBlur = { onBlur }
101
+ />
102
+ ) ;
103
+ }
91
104
return (
92
105
< Input
93
106
id = { `field-${ id } ` }
@@ -113,6 +126,9 @@ const EditableCell = ({
113
126
state : { pageIndex, pageSize } ,
114
127
} ) => {
115
128
const fieldSchema = { ...schema ?. properties ?. [ id ] , id : id } ;
129
+ const locale = useSelector ( ( state ) => state . intl . locale ) ;
130
+ moment . locale ( locale ) ;
131
+
116
132
const [ value , setValue ] = React . useState ( initialValue ) ;
117
133
const onChange = ( e ) => {
118
134
setValue ( e . target . value ) ;
@@ -126,6 +142,12 @@ const EditableCell = ({
126
142
}
127
143
} ;
128
144
145
+ const onChangeDate = ( e , dateValue ) => {
146
+ // console.log(dateValue);
147
+ setValue ( dateValue ) ;
148
+
149
+ } ;
150
+
129
151
const onBlur = ( ) => {
130
152
updateCell ( index , id , value ) ;
131
153
} ;
@@ -140,6 +162,7 @@ const EditableCell = ({
140
162
value = { value }
141
163
onChange = { onChange }
142
164
onChangeSelect = { onChangeSelect }
165
+ onChangeDate = { onChangeDate }
143
166
onBlur = { onBlur }
144
167
reactSelect = { reactSelect }
145
168
/>
@@ -158,7 +181,7 @@ const EditableCell = ({
158
181
setSelectedRow ( index ) ;
159
182
} }
160
183
>
161
- { ! fieldSchema . isMulti ? (
184
+ { fieldSchema . type === 'date' && value ? ( moment ( value ) . format ( 'LLL' ) ) : ! fieldSchema . isMulti ? (
162
185
value || < > </ >
163
186
) : value ? (
164
187
value . join ( ', ' )
0 commit comments