|
@@ -1,4 +1,4 @@
|
|
|
-import React, {useState, useEffect, useMemo, useRef} from 'react';
|
|
|
+import React, {useState, useEffect, useMemo, useRef, Fragment} from 'react';
|
|
|
import logo from './logo.svg';
|
|
|
import './App.css';
|
|
|
import Select from 'react-select/async'
|
|
@@ -82,6 +82,7 @@ const EditForm = ({record, models={}, model, options=defaultAdminOptions, Compon
|
|
|
}
|
|
|
|
|
|
const Row = ({top, selected, children}) => {
|
|
|
+ console.log('row')
|
|
|
return (
|
|
|
<>
|
|
|
<div className={`Row ${selected ? 'selected' : ''}` } >
|
|
@@ -174,9 +175,9 @@ const getModelByField = (field, models={}) => {
|
|
|
if (field.type.kind === 'LIST') return models[field.type.ofType.name]
|
|
|
}
|
|
|
|
|
|
-const VirtualScroll = ({options, gridHeight, count, rowHeight, components:Components={Row, Cell}, onScroll, records, skip, models={}}) => {
|
|
|
+const VirtualScroll = ({options, gridHeight, count, rowHeight, onScroll, records, skip, models={}}) => {
|
|
|
const limit = gridHeight/rowHeight
|
|
|
- const {Row, Cell} = Components
|
|
|
+ //const {Row, Cell} = Components
|
|
|
|
|
|
const [edit, setEdit] = useState({field: null, record: null})
|
|
|
|
|
@@ -184,6 +185,8 @@ const VirtualScroll = ({options, gridHeight, count, rowHeight, components:Compon
|
|
|
|
|
|
const fields = records && records[0] && records[0].constructor.fields
|
|
|
|
|
|
+ //console.log(Fragment, Row)
|
|
|
+
|
|
|
|
|
|
return (
|
|
|
<>
|
|
@@ -191,7 +194,7 @@ const VirtualScroll = ({options, gridHeight, count, rowHeight, components:Compon
|
|
|
style={{maxHeight: gridHeight, height: gridHeight}} >
|
|
|
<div className='GridContent'
|
|
|
style={{height: count*rowHeight, minHeight: count*rowHeight, maxHeight: count*rowHeight}} >
|
|
|
- {records && records.map((record,i) =><React.Fragment key={i}>
|
|
|
+ {records && records.map((record,i) =><Fragment key={i}>
|
|
|
{edit.record && edit.record._id === record._id ? <EditForm model={record.constructor} models={models} record={record} options={options}/>:
|
|
|
<Row options={options}>
|
|
|
{fields.map(field =>
|
|
@@ -200,7 +203,7 @@ const VirtualScroll = ({options, gridHeight, count, rowHeight, components:Compon
|
|
|
{record[field.name]}
|
|
|
</Cell>)}
|
|
|
</Row>}
|
|
|
- </React.Fragment>
|
|
|
+ </Fragment>
|
|
|
)}
|
|
|
</div>
|
|
|
</div>
|
|
@@ -245,6 +248,8 @@ const ModelView = ({model, models={}, options, components:Components={Search, Co
|
|
|
}
|
|
|
},[search, model])
|
|
|
|
|
|
+ console.log(Components)
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<Components.Search options={options} value={search} onChange={({target: {value}}) => setSearch(value)}/>
|