|
@@ -76,8 +76,9 @@ const Cell = ({children, options, record, field, selected, model, models={}, onC
|
|
let Formatter = React.Fragment
|
|
let Formatter = React.Fragment
|
|
|
|
|
|
const viewOrEdit = (!record.constructor.inputs || record.constructor.inputs.some(input => input.name === field.name)) && selected ? 'edit' : 'view'
|
|
const viewOrEdit = (!record.constructor.inputs || record.constructor.inputs.some(input => input.name === field.name)) && selected ? 'edit' : 'view'
|
|
- if (field.type.name in options[viewOrEdit].formatters){
|
|
|
|
- Formatter = options[viewOrEdit].formatters[field.type.name]
|
|
|
|
|
|
+ const typeName = field.type.name || field.type.ofType.name
|
|
|
|
+ if (typeName in options[viewOrEdit].formatters){
|
|
|
|
+ Formatter = options[viewOrEdit].formatters[typeName]
|
|
}
|
|
}
|
|
if (field.name in options[viewOrEdit].fields){
|
|
if (field.name in options[viewOrEdit].fields){
|
|
Formatter = options[viewOrEdit].fields[field.name]
|
|
Formatter = options[viewOrEdit].fields[field.name]
|
|
@@ -93,7 +94,7 @@ const Cell = ({children, options, record, field, selected, model, models={}, onC
|
|
|
|
|
|
return(
|
|
return(
|
|
<div className='Cell' onClick={onClick}>
|
|
<div className='Cell' onClick={onClick}>
|
|
- <Formatter options={options} model={model} models={models} {...props} field={field}>
|
|
|
|
|
|
+ <Formatter record={record} options={options} model={model} models={models} {...props} field={field}>
|
|
{Formatter === React.Fragment ? (children && children.toString()) : children}
|
|
{Formatter === React.Fragment ? (children && children.toString()) : children}
|
|
</Formatter>
|
|
</Formatter>
|
|
</div>
|
|
</div>
|
|
@@ -239,7 +240,7 @@ const ModelView = ({model, models={}, options, components:Components={Search, Co
|
|
skip={skip}
|
|
skip={skip}
|
|
count={count}
|
|
count={count}
|
|
records={records}
|
|
records={records}
|
|
- gridHeight={500}
|
|
|
|
|
|
+ gridHeight={700}
|
|
rowHeight={50}
|
|
rowHeight={50}
|
|
onScroll={(skip, limit) => {
|
|
onScroll={(skip, limit) => {
|
|
limit = undefined;
|
|
limit = undefined;
|
|
@@ -325,7 +326,19 @@ const defaultAdminOptions =
|
|
Object: ({children, options, model, models, ...props}) => {
|
|
Object: ({children, options, model, models, ...props}) => {
|
|
return model.fields[0].name === '_id' ? <ObjectShortEdit children={children} model={model} {...props}/> : <EditForm models={models} record={children} options={options} />
|
|
return model.fields[0].name === '_id' ? <ObjectShortEdit children={children} model={model} {...props}/> : <EditForm models={models} record={children} options={options} />
|
|
},
|
|
},
|
|
- Array: ({children}) => <>{children.map(child => <ObjectShortView children={child} />)}</>
|
|
|
|
|
|
+ Array: ({children, onChange, ...props}) => {
|
|
|
|
+ debugger;
|
|
|
|
+ return (<>{children.map((child, i) =>
|
|
|
|
+ <Cell {...props} children={child} selected
|
|
|
|
+ onChange={data => {
|
|
|
|
+ const copy = [...children]
|
|
|
|
+ debugger;
|
|
|
|
+ copy[i] = (data && data.target && data.target.value) || data
|
|
|
|
+ onChange(copy)
|
|
|
|
+ }}
|
|
|
|
+ />)}
|
|
|
|
+ </>)
|
|
|
|
+ }
|
|
},
|
|
},
|
|
fields:{
|
|
fields:{
|
|
createdAt: ({children}) => <input value={new Date(+children).toISOString()} />,
|
|
createdAt: ({children}) => <input value={new Date(+children).toISOString()} />,
|