Skip to content

Commit

Permalink
fix(ObjectEditor): Remove new object creator (too buggy)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheExGenesis committed Apr 14, 2022
1 parent 92e6136 commit 57e96f7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -490,40 +490,56 @@ export function ObjectEditorSelector({ currentUid, setCurrentUid, style }: any)

const [currentInputUid, setCurrentInputUid] = React.useState(currentUid || '');

useEffectOnce(() => {
React.useEffect(() => {
window.unigraph.getReferenceables().then((refs: any) => setReferenceables(refs));
});
}, []);
React.useEffect(() => {
console.log('Object Editor', { currentInputUid, currentSchema, currentSchemaSHName });
}, [currentInputUid]);

return (
<Box sx={{ display: 'inline-flex', flexDirection: 'row', alignItems: 'center' }}>
<TextField
onChange={(e) => {
setCurrentInputUid(e.target.value);
}}
value={currentInputUid}
/>
<Button onClick={() => setCurrentUid(currentInputUid)}>Load object</Button>
Schema name:{' '}
<ReferenceableSelectorControlled
referenceables={referenceables}
onChange={(schema: string) =>
window.unigraph.getSchemas().then((schemas: Record<string, SchemaDgraph>) => {
setCurrentSchema(schemas[schema]);
setCurrentSchemaSHName(schema);
})
}
value={currentSchema?._definition?.type['unigraph.id']}
sx={{ width: '300px' }}
/>
<Button
onClick={async () => {
const returnUid = await window.unigraph.addObject({}, currentSchemaSHName);
setCurrentUid(returnUid);
}}
>
Create with schema
</Button>
</Box>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
{/* <div style={{ display: 'flex', flexDirection: 'column' }}>
Create a new object
<Box sx={{ display: 'inline-flex', flexDirection: 'row', alignItems: 'center' }}>
<ReferenceableSelectorControlled
referenceables={referenceables}
onChange={(schema: string) =>
window.unigraph.getSchemas().then((schemas: Record<string, SchemaDgraph>) => {
setCurrentSchema(schemas[schema]);
setCurrentSchemaSHName(schema);
})
}
value={currentSchema?._definition?.type['unigraph.id']}
sx={{ width: '300px' }}
/>
<Button
onClick={async () => {
const returnUid = await window.unigraph.addObject({}, currentSchemaSHName);
console.log('Obj Editor: Added new obj', { returnUid });
setCurrentUid(returnUid);
}}
>
Create
</Button>
</Box>
</div>
or */}
<div style={{ display: 'flex', flexDirection: 'column' }}>
Load an existing object
<Box sx={{ display: 'inline-flex', flexDirection: 'row', alignItems: 'center' }}>
<TextField
onChange={(e) => {
setCurrentInputUid(e.target.value);
}}
value={currentInputUid}
label="Object UID"
/>
<Button onClick={() => setCurrentUid(currentInputUid)}>Load</Button>
</Box>
</div>
</div>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function ReferenceableSelectorControlled({ referenceables, value, onChang
renderInput={(params) => (
<TextField
{...params}
label="Type"
label="Object Schema"
variant="filled"
value={value || ''}
sx={{
Expand Down

0 comments on commit 57e96f7

Please sign in to comment.