Commit ad9c78d9 authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: accept prefix in form sections

parent 507cbd96
......@@ -24,12 +24,15 @@ import { isEmail, isUrl } from '@/modules/form/validate'
export interface ActorsFormSectionProps {
initialValues?: any
prefix?: string
}
/**
* Form section for contributors.
*/
export function ActorsFormSection(props: ActorsFormSectionProps): JSX.Element {
const prefix = props.prefix ?? ''
const [showCreateNewDialog, setShowCreateNewDialog] = useState(false)
function openCreateNewDialog() {
setShowCreateNewDialog(true)
......@@ -47,7 +50,7 @@ export function ActorsFormSection(props: ActorsFormSectionProps): JSX.Element {
</FormFieldAddButton>
}
>
<FormFieldArray name="contributors">
<FormFieldArray name={`${prefix}contributors`}>
{({ fields }) => {
return (
<FormRecords>
......
import { FormSection } from '@/modules/form/components/FormSection/FormSection'
import { FormTextField } from '@/modules/form/components/FormTextField/FormTextField'
export interface DateFormSectionProps {
prefix?: string
}
/**
* Form section for dates.
*/
export function DateFormSection(): JSX.Element {
export function DateFormSection(props: DateFormSectionProps): JSX.Element {
const prefix = props.prefix ?? ''
return (
<FormSection style={{ alignItems: 'start' }}>
<FormTextField
name="dateCreated"
name={`${prefix}dateCreated`}
label={'Date created'}
type="date"
variant="form"
/>
<FormTextField
name="dateLastUpdated"
name={`${prefix}dateLastUpdated`}
label={'Date last updated'}
type="date"
variant="form"
......
......@@ -7,24 +7,39 @@ import { FormTextArea } from '@/modules/form/components/FormTextArea/FormTextAre
import { FormTextField } from '@/modules/form/components/FormTextField/FormTextField'
import { FormFieldArray } from '@/modules/form/FormFieldArray'
export interface MainFormSectionProps {
prefix?: string
}
/**
* Main form section for item label, version, description, and URLs.
*/
export function MainFormSection(): JSX.Element {
export function MainFormSection(props: MainFormSectionProps): JSX.Element {
const prefix = props.prefix ?? ''
return (
<FormSection>
<div className="grid gap-4" style={{ gridTemplateColumns: '1fr 100px' }}>
<FormTextField name="label" label={'Label'} isRequired variant="form" />
<FormTextField name="version" label={'Version'} variant="form" />
<FormTextField
name={`${prefix}label`}
label={'Label'}
isRequired
variant="form"
/>
<FormTextField
name={`${prefix}version`}
label={'Version'}
variant="form"
/>
</div>
<FormTextArea
name="description"
name={`${prefix}description`}
label={'Description'}
isRequired
rows={4}
variant="form"
/>
<FormFieldArray name="accessibleAt">
<FormFieldArray name={`${prefix}accessibleAt`}>
{({ fields }) => {
return (
<FormRecords>
......
......@@ -22,6 +22,7 @@ import { FormFieldCondition } from '@/modules/form/FormFieldCondition'
export interface PropertiesFormSectionProps {
initialValues?: any
prefix?: string
}
/**
......@@ -30,6 +31,8 @@ export interface PropertiesFormSectionProps {
export function PropertiesFormSection(
props: PropertiesFormSectionProps,
): JSX.Element {
const prefix = props.prefix ?? ''
const propertyTypes = useGetPropertyTypes({
/** try to get everything in one go, so we don't need a combobox here */
perpage: 100,
......@@ -50,7 +53,7 @@ export function PropertiesFormSection(
return (
<FormSection title={'Properties'}>
<FormFieldArray name="properties">
<FormFieldArray name={`${prefix}properties`}>
{({ fields }) => {
return (
<FormRecords>
......
......@@ -13,6 +13,7 @@ import { FormFieldArray } from '@/modules/form/FormFieldArray'
export interface RelatedItemsFormSectionProps {
initialValues?: any
prefix?: string
}
/**
......@@ -21,9 +22,11 @@ export interface RelatedItemsFormSectionProps {
export function RelatedItemsFormSection(
props: RelatedItemsFormSectionProps,
): JSX.Element {
const prefix = props.prefix ?? ''
return (
<FormSection title={'Related items'}>
<FormFieldArray name="relatedItems">
<FormFieldArray name={`${prefix}relatedItems`}>
{({ fields }) => {
return (
<FormRecords>
......
......@@ -8,22 +8,25 @@ import { FormTextField } from '@/modules/form/components/FormTextField/FormTextF
export interface SoureFormSectionProps {
initialValues?: any
prefix?: string
}
/**
* Form section for item source.
*/
export function SourceFormSection(props: SoureFormSectionProps): JSX.Element {
const prefix = props.prefix ?? ''
return (
<FormSection title={'Source'}>
<div className="flex space-x-4">
<SourceComboBox
name="source.id"
name={`${prefix}source.id`}
label={'Source'}
initialValues={props.initialValues}
/>
<FormTextField
name="sourceItemId"
name={`${prefix}sourceItemId`}
label={'Source ID'}
variant="form"
style={{ flex: 1 }}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment