@@ -2,15 +2,13 @@ import i18n from '@dhis2/d2-i18n'
22import { Button } from '@dhis2/ui'
33import { getInstance as getD2 } from 'd2'
44import FormBuilder from 'd2-ui/lib/forms/FormBuilder.component.js'
5- import { Table , Column , Cell } from 'fixed-data-table'
65import CircularProgress from 'material-ui/CircularProgress'
76import { RadioButtonGroup , RadioButton } from 'material-ui/RadioButton'
87import PropTypes from 'prop-types'
98import React , { Component } from 'react'
109import Checkbox from '../form-fields/check-box.jsx'
1110import settingsActions from '../settingsActions.js'
1211import settingsStore from '../settingsStore.js'
13- import 'fixed-data-table/dist/fixed-data-table.css'
1412
1513class MetadataSettings extends Component {
1614 constructor ( props , context ) {
@@ -185,17 +183,39 @@ class MetadataSettings extends Component {
185183 top : '-7px' ,
186184 float : 'left' ,
187185 } ,
186+ tableContainerVisible : { display : 'block' } ,
187+ tableContainerHidden : { display : 'none' } ,
188+ table : {
189+ width : '670px' ,
190+ borderCollapse : 'collapse' ,
191+ marginTop : '10px' ,
192+ fontFamily : 'Arial, sans-serif' ,
193+ textAlign : 'left' ,
194+ } ,
195+ theadRow : { backgroundColor : '#f4f4f4' } ,
196+ th : {
197+ border : '1px solid #ddd' ,
198+ padding : '12px' ,
199+ fontWeight : 'bold' ,
200+ } ,
201+ thVersion : { width : '135px' } ,
202+ thWhen : { width : '205px' } ,
203+ thType : { width : '145px' } ,
204+ thLastSync : { width : '185px' } ,
205+ tbodyRowEven : { height : '50px' , backgroundColor : '#fff' } ,
206+ tbodyRowOdd : { height : '50px' , backgroundColor : '#f9f9f9' } ,
207+ td : { border : '1px solid #ddd' , padding : '10px' } ,
188208 }
189209
190- const fieldGetter =
191- ( field , filter = ( x ) => x ) =>
192- // eslint-disable-next-line react/display-name, react/prop-types
193- ( { rowIndex, ...props } ) =>
194- (
195- < Cell { ...props } >
196- { filter ( this . state . metadataVersions [ rowIndex ] [ field ] ) }
197- </ Cell >
198- )
210+ // const fieldGetter =
211+ // (field, filter = (x) => x) =>
212+ // // eslint-disable-next-line react/display-name, react/prop-types
213+ // ({ rowIndex, ...props }) =>
214+ // (
215+ // <Cell {...props}>
216+ // {filter(this.state.metadataVersions[rowIndex][field])}
217+ // </Cell>
218+ // )
199219
200220 const dateFmt = ( str ) => new Date ( str ) . toLocaleString ( )
201221
@@ -298,34 +318,61 @@ class MetadataSettings extends Component {
298318 : styles . hidden
299319 }
300320 >
301- < Table
302- rowHeight = { 50 }
303- rowsCount = { this . state . metadataVersions . length }
304- width = { 670 }
305- maxHeight = { 50 * 6 }
306- headerHeight = { 50 }
307- >
308- < Column
309- header = { < Cell > Version</ Cell > }
310- cell = { fieldGetter ( 'name' ) }
311- width = { 135 }
312- />
313- < Column
314- header = { < Cell > When</ Cell > }
315- cell = { fieldGetter ( 'created' , dateFmt ) }
316- width = { 205 }
317- />
318- < Column
319- header = { < Cell > Type</ Cell > }
320- cell = { fieldGetter ( 'type' ) }
321- width = { 145 }
322- />
323- < Column
324- header = { < Cell > Last Sync</ Cell > }
325- cell = { fieldGetter ( 'importdate' ) }
326- width = { 185 }
327- />
328- </ Table >
321+ < table style = { styles . table } >
322+ < thead >
323+ < tr style = { styles . theadRow } >
324+ < th
325+ style = { {
326+ ...styles . th ,
327+ ...styles . thVersion ,
328+ } }
329+ >
330+ Version
331+ </ th >
332+ < th style = { { ...styles . th , ...styles . thWhen } } >
333+ When
334+ </ th >
335+ < th style = { { ...styles . th , ...styles . thType } } >
336+ Type
337+ </ th >
338+ < th
339+ style = { {
340+ ...styles . th ,
341+ ...styles . thLastSync ,
342+ } }
343+ >
344+ Last Sync
345+ </ th >
346+ </ tr >
347+ </ thead >
348+ < tbody >
349+ { this . state . metadataVersions . map (
350+ ( version , index ) => (
351+ < tr
352+ key = { index }
353+ style = {
354+ index % 2 === 0
355+ ? styles . tbodyRowEven
356+ : styles . tbodyRowOdd
357+ }
358+ >
359+ < td style = { styles . td } >
360+ { version . name }
361+ </ td >
362+ < td style = { styles . td } >
363+ { dateFmt ( version . created ) }
364+ </ td >
365+ < td style = { styles . td } >
366+ { version . type }
367+ </ td >
368+ < td style = { styles . td } >
369+ { version . importdate }
370+ </ td >
371+ </ tr >
372+ )
373+ ) }
374+ </ tbody >
375+ </ table >
329376 </ div >
330377
331378 < div
@@ -335,29 +382,61 @@ class MetadataSettings extends Component {
335382 : styles . visible
336383 }
337384 >
338- < Table
339- rowHeight = { 50 }
340- rowsCount = { this . state . metadataVersions . length }
341- width = { 670 }
342- maxHeight = { 50 * 6 }
343- headerHeight = { 50 }
344- >
345- < Column
346- header = { < Cell > Version</ Cell > }
347- cell = { fieldGetter ( 'name' ) }
348- width = { 190 }
349- />
350- < Column
351- header = { < Cell > When</ Cell > }
352- cell = { fieldGetter ( 'created' ) }
353- width = { 280 }
354- />
355- < Column
356- header = { < Cell > Type</ Cell > }
357- cell = { fieldGetter ( 'type' ) }
358- width = { 200 }
359- />
360- </ Table >
385+ < table style = { styles . table } >
386+ < thead >
387+ < tr style = { styles . theadRow } >
388+ < th
389+ style = { {
390+ ...styles . th ,
391+ ...styles . thVersion ,
392+ } }
393+ >
394+ Version
395+ </ th >
396+ < th style = { { ...styles . th , ...styles . thWhen } } >
397+ When
398+ </ th >
399+ < th style = { { ...styles . th , ...styles . thType } } >
400+ Type
401+ </ th >
402+ < th
403+ style = { {
404+ ...styles . th ,
405+ ...styles . thLastSync ,
406+ } }
407+ >
408+ Last Sync
409+ </ th >
410+ </ tr >
411+ </ thead >
412+ < tbody >
413+ { this . state . metadataVersions . map (
414+ ( version , index ) => (
415+ < tr
416+ key = { index }
417+ style = {
418+ index % 2 === 0
419+ ? styles . tbodyRowEven
420+ : styles . tbodyRowOdd
421+ }
422+ >
423+ < td style = { styles . td } >
424+ { version . name }
425+ </ td >
426+ < td style = { styles . td } >
427+ { dateFmt ( version . created ) }
428+ </ td >
429+ < td style = { styles . td } >
430+ { version . type }
431+ </ td >
432+ < td style = { styles . td } >
433+ { version . importdate }
434+ </ td >
435+ </ tr >
436+ )
437+ ) }
438+ </ tbody >
439+ </ table >
361440 </ div >
362441
363442 < div
0 commit comments