From ac7bd51d9e1c7729a52b916d0f2120ea352bb5da Mon Sep 17 00:00:00 2001 From: Sebastian Tilsch Date: Sun, 11 Feb 2024 21:59:54 +0100 Subject: [PATCH] more consistency and inlien editiing --- .../components/content/main/TypedForm.tsx | 65 +++++----- .../components/form/show/EntityDetailCard.tsx | 112 +++++++++++++----- .../form/show/EntityDetailElement.tsx | 2 +- .../renderer/SimpleExpandPanelRenderer.tsx | 24 ++-- .../public/locales/de/translation.json | 1 + .../public/locales/en/translation.json | 1 + 6 files changed, 123 insertions(+), 82 deletions(-) diff --git a/apps/exhibition-live/components/content/main/TypedForm.tsx b/apps/exhibition-live/components/content/main/TypedForm.tsx index 2bbb157a..bb67555f 100644 --- a/apps/exhibition-live/components/content/main/TypedForm.tsx +++ b/apps/exhibition-live/components/content/main/TypedForm.tsx @@ -39,47 +39,42 @@ const WithPreviewForm = ({ classIRI, entityIRI, data, children }: Props) => { [rightDrawerOpen, rightDrawerWidth], ); - return features?.enablePreview ? ( + return ( <> - {previewEnabled ? ( - - - {children} - + + + {children} + + {features?.enablePreview && previewEnabled && ( - { - - } + - - - ) : ( - children - )} + // boxSizing: 'border-box', + }, + }} + /> + - ) : ( - <>{children} ); }; + export type MainFormProps = { typeName: string; entityIRI?: string; @@ -135,7 +130,7 @@ const TypedForm = ({ typeName, entityIRI, classIRI }: MainFormProps) => { return ( {loadedSchema && ( - + = ({ const { t } = useTranslation(); const router = useModifiedRouter(); + const [editMode, setEditMode] = useState(false); const editEntry = useCallback(() => { const typeName = typeIRItoTypeName(typeIRI); router.push(`/create/${typeName}?encID=${encodeIRI(entityIRI)}`); @@ -47,38 +57,80 @@ export const EntityDetailCard: FunctionComponent = ({ features: { enableDebug }, } = useSettings(); + const editInlineEntry = useCallback(() => { + setEditMode(true); + }, []); + const [formData, setFormData] = useState(data); + const typeName = typeIRItoTypeName(typeIRI); + const loadedSchema = useExtendedSchema({ typeName, classIRI: typeIRI }); + const { crudOptions } = useGlobalCRUDOptions(); + const uischema = useMemo( + () => uischemata[typeName] || (uischemas as any)[typeName], + [typeName], + ); + return ( <> - - - {cardInfo.image && ( - - )} - - - {cardInfo.label} - - - {cardInfo.description} - - - - - - - - - {enableDebug && ( + {editMode ? ( + + ) : ( <> - lvl < 3} /> - lvl < 3} /> + + + {cardInfo.image && ( + + )} + + + {cardInfo.label} + + + {cardInfo.description} + + + + + + + + + + {enableDebug && ( + <> + lvl < 3} + /> + lvl < 3} /> + + )} )} diff --git a/apps/exhibition-live/components/form/show/EntityDetailElement.tsx b/apps/exhibition-live/components/form/show/EntityDetailElement.tsx index 7506777b..03382c63 100644 --- a/apps/exhibition-live/components/form/show/EntityDetailElement.tsx +++ b/apps/exhibition-live/components/form/show/EntityDetailElement.tsx @@ -64,7 +64,7 @@ export const EntityDetailElement = ({ }, [typeName, data]); return ( - + { - setModalIsOpen(!modalIsOpen); - }, [setModalIsOpen, modalIsOpen]); + const subSchema = useMemo( () => bringDefinitionToTop(rootSchema as JSONSchema7, typeName) as JSONSchema7, @@ -130,6 +130,10 @@ export const SimpleExpandPanelRenderer = ( const router = useModifiedRouter(); const locale = router.query.locale || ""; + const showDetailModal = useCallback(() => { + NiceModal.show(EntityDetailModal, { typeIRI, entityIRI, data }); + }, [typeIRI, entityIRI, data]); + return ( } > - + {count + 1} @@ -162,18 +166,6 @@ export const SimpleExpandPanelRenderer = ( secondary={description} /> - {!draft && ( - setModalIsOpen(false)} - askCancel={() => setModalIsOpen(false)} - onChange={onChange} - /> - )} ); }; diff --git a/apps/exhibition-live/public/locales/de/translation.json b/apps/exhibition-live/public/locales/de/translation.json index 34163651..efe0a86c 100644 --- a/apps/exhibition-live/public/locales/de/translation.json +++ b/apps/exhibition-live/public/locales/de/translation.json @@ -1,5 +1,6 @@ { "edit": "bearbeiten", + "edit inline": "Inline bearbeiten", "cancel": "abbrechen", "settings": "Einstellungen", "search": "Suche", diff --git a/apps/exhibition-live/public/locales/en/translation.json b/apps/exhibition-live/public/locales/en/translation.json index fdfadc71..671c47cb 100644 --- a/apps/exhibition-live/public/locales/en/translation.json +++ b/apps/exhibition-live/public/locales/en/translation.json @@ -1,5 +1,6 @@ { "edit": "edit", + "edit inline": "edit inline", "cancel": "cancel", "settings": "settings", "search": "search",