@@ -28,7 +28,7 @@ const messages = defineMessages({
28
28
const View = ( { data, id, path, properties } ) => {
29
29
// console.log(props);
30
30
const schema = data ?. schema ;
31
- const sortable_fields = data ?. sortable || [ ] ;
31
+ // const sortable_fields = data?.sortable || [];
32
32
const filterable_fields = data ?. filterable || [ ] ;
33
33
const intl = useIntl ( ) ;
34
34
const includesFilter = ( rows , ids , filterValue ) => {
@@ -166,108 +166,114 @@ const View = ({ data, id, path, properties }) => {
166
166
) ;
167
167
168
168
return (
169
- < div className = "cms-ui" style = { { marginTop : '1em' } } >
170
- < Table celled { ...getTableProps ( ) } >
171
- < Table . Header >
172
- { headerGroups . map ( ( headerGroup , key ) => (
173
- < Table . Row key = { key } { ...headerGroup . getHeaderGroupProps ( ) } >
174
- { headerGroup . headers . map ( ( column ) => (
175
- < Table . HeaderCell
176
- { ...column . getHeaderProps ( column . getSortByToggleProps ( ) ) }
177
- className = "wide one"
178
- style = { { maxWidth : '40px' , verticalAlign : 'top' } }
179
- >
180
- { column . render ( 'Header' ) }
181
- { column . defaultCanSort && (
182
- < span class = "sort" >
183
- { column . isSorted ? (
184
- column . isSortedDesc ? (
185
- < Icon name = { sortUp } />
169
+ < div className = "block dataTableBlock" >
170
+ < div className = "cms-ui" style = { { marginTop : '1em' } } >
171
+ < Table celled { ...getTableProps ( ) } >
172
+ < Table . Header >
173
+ { headerGroups . map ( ( headerGroup , key ) => (
174
+ < Table . Row key = { key } { ...headerGroup . getHeaderGroupProps ( ) } >
175
+ { headerGroup . headers . map ( ( column ) => (
176
+ < Table . HeaderCell
177
+ { ...column . getHeaderProps ( column . getSortByToggleProps ( ) ) }
178
+ className = "wide one"
179
+ style = { { maxWidth : '40px' , verticalAlign : 'top' } }
180
+ >
181
+ { column . render ( 'Header' ) }
182
+ { column . defaultCanSort && (
183
+ < span class = "sort" >
184
+ { column . isSorted ? (
185
+ column . isSortedDesc ? (
186
+ < Icon name = { sortUp } />
187
+ ) : (
188
+ < Icon name = { sortDown } />
189
+ )
186
190
) : (
187
- < Icon name = { sortDown } />
188
- )
189
- ) : (
190
- < Icon name = { sortDown } color = "#D3D3D3" />
191
- ) }
192
- </ span >
193
- ) }
194
- < div > { column . canFilter ? column . render ( 'Filter' ) : null } </ div >
195
- </ Table . HeaderCell >
196
- ) ) }
197
- </ Table . Row >
198
- ) ) }
199
- </ Table . Header >
200
- < Table . Body { ...getTableBodyProps ( ) } >
201
- { page . map ( ( row , i ) => {
202
- prepareRow ( row ) ;
203
- return (
204
- < Table . Row { ...row . getRowProps ( ) } >
205
- { row . cells . map ( ( cell ) => {
206
- return (
207
- < Table . Cell { ...cell . getCellProps ( ) } >
208
- { cell . render ( 'Cell' ) }
209
- </ Table . Cell >
210
- ) ;
211
- } ) }
191
+ < Icon name = { sortDown } color = "#D3D3D3" />
192
+ ) }
193
+ </ span >
194
+ ) }
195
+ < div >
196
+ { column . canFilter ? column . render ( 'Filter' ) : null }
197
+ </ div >
198
+ </ Table . HeaderCell >
199
+ ) ) }
212
200
</ Table . Row >
213
- ) ;
214
- } ) }
215
- </ Table . Body >
216
- </ Table >
201
+ ) ) }
202
+ </ Table . Header >
203
+ < Table . Body { ...getTableBodyProps ( ) } >
204
+ { page . map ( ( row , i ) => {
205
+ prepareRow ( row ) ;
206
+ return (
207
+ < Table . Row { ...row . getRowProps ( ) } >
208
+ { row . cells . map ( ( cell ) => {
209
+ return (
210
+ < Table . Cell { ...cell . getCellProps ( ) } >
211
+ { cell . render ( 'Cell' ) }
212
+ </ Table . Cell >
213
+ ) ;
214
+ } ) }
215
+ </ Table . Row >
216
+ ) ;
217
+ } ) }
218
+ </ Table . Body >
219
+ </ Table >
217
220
218
- { data ?. items && (
219
- < div className = "pagination-wrapper react-table-pagination cms-ui" >
220
- { data . items . length > 10 && (
221
- < >
222
- < Pagination
223
- activePage = { pageIndex + 1 }
224
- totalPages = { pageCount }
225
- onPageChange = { ( e , { activePage } ) => {
226
- gotoPage ( activePage - 1 ) ;
227
- } }
228
- firstItem = { null }
229
- lastItem = { null }
230
- prevItem = { {
231
- content : < Icon name = { paginationLeftSVG } size = "18px" /> ,
232
- icon : true ,
233
- 'aria-disabled' : pageIndex + 1 === 1 ,
234
- className : pageIndex + 1 === 1 ? 'disabled' : null ,
235
- } }
236
- nextItem = { {
237
- content : < Icon name = { paginationRightSVG } size = "18px" /> ,
238
- icon : true ,
239
- 'aria-disabled' : pageIndex + 1 === pageCount ,
240
- className : pageIndex + 1 === pageCount ? 'disabled' : null ,
241
- } }
242
- > </ Pagination >
243
- < select
244
- style = { { maxWidth : '7rem' } }
245
- value = { pageSize }
246
- onChange = { ( e ) => {
247
- setPageSize ( Number ( e . target . value ) ) ;
248
- } }
221
+ { data ?. items && (
222
+ < div className = "pagination-wrapper react-table-pagination cms-ui" >
223
+ { data . items . length > 10 && (
224
+ < >
225
+ < Pagination
226
+ activePage = { pageIndex + 1 }
227
+ totalPages = { pageCount }
228
+ onPageChange = { ( e , { activePage } ) => {
229
+ gotoPage ( activePage - 1 ) ;
230
+ } }
231
+ firstItem = { null }
232
+ lastItem = { null }
233
+ prevItem = { {
234
+ content : < Icon name = { paginationLeftSVG } size = "18px" /> ,
235
+ icon : true ,
236
+ 'aria-disabled' : pageIndex + 1 === 1 ,
237
+ className : pageIndex + 1 === 1 ? 'disabled' : null ,
238
+ } }
239
+ nextItem = { {
240
+ content : < Icon name = { paginationRightSVG } size = "18px" /> ,
241
+ icon : true ,
242
+ 'aria-disabled' : pageIndex + 1 === pageCount ,
243
+ className : pageIndex + 1 === pageCount ? 'disabled' : null ,
244
+ } }
245
+ > </ Pagination >
246
+ < select
247
+ style = { { maxWidth : '7rem' } }
248
+ value = { pageSize }
249
+ onChange = { ( e ) => {
250
+ setPageSize ( Number ( e . target . value ) ) ;
251
+ } }
252
+ >
253
+ { [ 10 , 25 , 50 , 100 ]
254
+ . filter ( ( v ) => data . items . length * 2 > v )
255
+ . map ( ( pageSize ) => (
256
+ < option key = { pageSize } value = { pageSize } >
257
+ { intl . formatMessage ( messages . page_size , { pageSize } ) }
258
+ </ option >
259
+ ) ) }
260
+ </ select >
261
+ </ >
262
+ ) }
263
+ < div className = "actions" >
264
+ < CSVLink
265
+ className = "ui button"
266
+ filename = { schema . title ? `${ schema . title } .csv` : 'export.csv' }
267
+ separator = ";"
268
+ headers = { csv_columns }
269
+ data = { data ?. items || [ ] }
249
270
>
250
- { [ 10 , 25 , 50 , 100 ] . map ( ( pageSize ) => (
251
- < option key = { pageSize } value = { pageSize } >
252
- { intl . formatMessage ( messages . page_size , { pageSize } ) }
253
- </ option >
254
- ) ) }
255
- </ select >
256
- </ >
257
- ) }
258
- < div className = "actions" >
259
- < CSVLink
260
- className = "ui button"
261
- filename = { schema . title ? `${ schema . title } .csv` : 'export.csv' }
262
- separator = ";"
263
- headers = { csv_columns }
264
- data = { data ?. items || [ ] }
265
- >
266
- { intl . formatMessage ( messages . export_csv_file ) }
267
- </ CSVLink >
271
+ { intl . formatMessage ( messages . export_csv_file ) }
272
+ </ CSVLink >
273
+ </ div >
268
274
</ div >
269
- </ div >
270
- ) }
275
+ ) }
276
+ </ div >
271
277
</ div >
272
278
) ;
273
279
} ;
0 commit comments