diff --git a/ordinis-admin-ui/src/components/form/SchemaDrivenForm.tsx b/ordinis-admin-ui/src/components/form/SchemaDrivenForm.tsx index dd3427b..0f2fe79 100644 --- a/ordinis-admin-ui/src/components/form/SchemaDrivenForm.tsx +++ b/ordinis-admin-ui/src/components/form/SchemaDrivenForm.tsx @@ -96,19 +96,19 @@ export const SchemaDrivenForm = ({ } return ( -
+ - - - - +
+
+ +
- +
- +
{Object.entries(properties).map(([key, propSchema]) => ( ))} - +
{serverError && {serverError}} @@ -153,6 +153,14 @@ export const SchemaDrivenForm = ({ ) } +const isFullWidth = (s: JsonSchema): boolean => { + if (s['x-localized']) return true + if (s.type === 'array') return true + if ((s.maxLength ?? 0) > 200) return true + if (s.type === 'object') return true + return false +} + type FieldRendererProps = { fieldKey: string schema: JsonSchema @@ -163,7 +171,16 @@ type FieldRendererProps = { fieldError?: unknown } -const FieldRenderer = ({ +const FieldRenderer = (props: FieldRendererProps) => { + const wrapperClass = isFullWidth(props.schema) ? 'sm:col-span-2' : '' + return ( +
+ +
+ ) +} + +const FieldBody = ({ fieldKey, schema, required, @@ -188,11 +205,11 @@ const FieldRenderer = ({ control={control} name={`data.${fieldKey}.${loc}` as `data.${string}`} render={({ field }) => ( -
- +
+ {loc === defaultLocale ? {loc} : loc} -
+
diff --git a/ordinis-admin-ui/src/routes/dictionaries.$name.tsx b/ordinis-admin-ui/src/routes/dictionaries.$name.tsx index edcac0b..ab66cb0 100644 --- a/ordinis-admin-ui/src/routes/dictionaries.$name.tsx +++ b/ordinis-admin-ui/src/routes/dictionaries.$name.tsx @@ -156,17 +156,15 @@ function DictionaryDetail() { } onClick={() => setEdit({ kind: 'edit', record: r })} - > - - + /> } onClick={() => setEdit({ kind: 'close-confirm', record: r })} - > - - + />
@@ -186,7 +184,7 @@ function DictionaryDetail() { ? `${t('dict.action.edit')}: ${edit.record.businessKey}` : '' } - maxWidth="max-w-2xl" + maxWidth="max-w-4xl" > {detailQuery.data && (edit.kind === 'create' || edit.kind === 'edit') && (