Commit 927ac48a authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: adjust to objectid=>persistentId change, pass dto to workflow edit form

parent fa3ebff7
Pipeline #188014 failed with stage
in 13 seconds
...@@ -74,28 +74,32 @@ export function convertToInitialFormValues( ...@@ -74,28 +74,32 @@ export function convertToInitialFormValues(
} }
}), }),
/** /**
* `persistentId` => `objectId` * Only ids needed.
*/ */
relatedItems: item.relatedItems?.map((relation) => { relatedItems: item.relatedItems?.map((relation) => {
return { return {
...relation, id: relation.id,
objectId: relation.persistentId, persistentId: relation.persistentId,
relation: relation.relation && { code: relation.relation.code },
} }
}), }),
/** /**
* Only ids needed. Also, fields are non-null. * Only ids needed. Also, fields are non-null.
*/ */
externalIds: item.externalIds?.map((id) => { externalIds: item.externalIds?.map((id) => {
return { const identifierService = { code: id.identifierService?.code }
serviceIdentifier: id.identifierService?.code ?? '', const identifier = id.identifier!
identifier: id.identifier ?? '', const externalId = {
identifier,
serviceIdentifier: identifierService,
} }
return externalId
}), }),
/** /**
* Only id needed. * Only id needed.
*/ */
source: { source: item.source && {
id: item.source?.id, id: item.source.id,
}, },
sourceItemId: item.sourceItemId, sourceItemId: item.sourceItemId,
} }
......
This diff is collapsed.
...@@ -263,7 +263,7 @@ function CreateActorForm(props: CreateActorFormProps) { ...@@ -263,7 +263,7 @@ function CreateActorForm(props: CreateActorFormProps) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id != null && id != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.serviceIdentifier != null && id.serviceIdentifier?.code != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.identifier == null id.identifier == null
) { ) {
...@@ -285,13 +285,13 @@ function CreateActorForm(props: CreateActorFormProps) { ...@@ -285,13 +285,13 @@ function CreateActorForm(props: CreateActorFormProps) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.identifier != null && id.identifier != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.serviceIdentifier == null id.serviceIdentifier?.code == null
) { ) {
if (errors.externalIds === undefined) { if (errors.externalIds === undefined) {
errors.externalIds = [] errors.externalIds = []
} }
errors.externalIds[index] = { errors.externalIds[index] = {
serviceIdentifier: 'Please select an ID service.', serviceIdentifier: { code: 'Please select an ID service.' },
} }
} }
}) })
......
...@@ -88,7 +88,7 @@ export function MainFormSection(props: MainFormSectionProps): JSX.Element { ...@@ -88,7 +88,7 @@ export function MainFormSection(props: MainFormSectionProps): JSX.Element {
} }
> >
<ExternalIdServiceSelect <ExternalIdServiceSelect
name={`${name}.serviceIdentifier`} name={`${name}.serviceIdentifier.code`}
label="ID Service" label="ID Service"
/> />
<FormTextField <FormTextField
......
...@@ -46,7 +46,7 @@ export function RelatedItemsFormSection( ...@@ -46,7 +46,7 @@ export function RelatedItemsFormSection(
label={'Relation type'} label={'Relation type'}
/> />
<RelatedItemComboBox <RelatedItemComboBox
name={`${name}.objectId`} name={`${name}.persistentId`}
label={'Item'} label={'Item'}
initialValues={props.initialValues} initialValues={props.initialValues}
index={index} index={index}
......
...@@ -440,7 +440,11 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -440,7 +440,11 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
</div> </div>
) : null} ) : null}
</div> </div>
<Page onSetPage={onSetPage} prefix={state.prefix} /> <Page
onSetPage={onSetPage}
prefix={state.prefix}
item={props.item}
/>
<div className="flex items-center justify-end space-x-6"> <div className="flex items-center justify-end space-x-6">
<Button onPress={onCancel} variant="link"> <Button onPress={onCancel} variant="link">
Cancel Cancel
...@@ -523,15 +527,16 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -523,15 +527,16 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
interface FormPageProps { interface FormPageProps {
onSetPage: (page: PageKey, prefix?: string, onReset?: () => void) => void onSetPage: (page: PageKey, prefix?: string, onReset?: () => void) => void
prefix?: string prefix?: string
item?: WorkflowDto
} }
function WorkflowPage() { function WorkflowPage(props: FormPageProps) {
return ( return (
<Fragment> <Fragment>
<MainFormSection /> <MainFormSection />
<ActorsFormSection /> <ActorsFormSection initialValues={props.item} />
<PropertiesFormSection /> <PropertiesFormSection initialValues={props.item} />
<RelatedItemsFormSection /> <RelatedItemsFormSection initialValues={props.item} />
<SourceFormSection /> <SourceFormSection />
</Fragment> </Fragment>
) )
......
...@@ -170,13 +170,13 @@ export function validateCommonFormFields< ...@@ -170,13 +170,13 @@ export function validateCommonFormFields<
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
item != null && item != null &&
item.relation !== undefined && item.relation !== undefined &&
item.objectId === undefined item.persistentId === undefined
) { ) {
if (errors.relatedItems === undefined) { if (errors.relatedItems === undefined) {
/* @ts-expect-error Untyped empty array. */ /* @ts-expect-error Untyped empty array. */
errors.relatedItems = [] errors.relatedItems = []
} }
errors.relatedItems[index] = { objectId: 'Please select an item.' } errors.relatedItems[index] = { persistentId: 'Please select an item.' }
} }
}) })
} }
...@@ -187,7 +187,7 @@ export function validateCommonFormFields< ...@@ -187,7 +187,7 @@ export function validateCommonFormFields<
if ( if (
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
item != null && item != null &&
item.objectId !== undefined && item.persistentId !== undefined &&
item.relation === undefined item.relation === undefined
) { ) {
if (errors.relatedItems === undefined) { if (errors.relatedItems === undefined) {
...@@ -207,7 +207,7 @@ export function validateCommonFormFields< ...@@ -207,7 +207,7 @@ export function validateCommonFormFields<
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id != null && id != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.serviceIdentifier != null && id.serviceIdentifier?.code != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.identifier == null id.identifier == null
) { ) {
...@@ -230,14 +230,14 @@ export function validateCommonFormFields< ...@@ -230,14 +230,14 @@ export function validateCommonFormFields<
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.identifier != null && id.identifier != null &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
id.serviceIdentifier == null id.serviceIdentifier?.code == null
) { ) {
if (errors.externalIds === undefined) { if (errors.externalIds === undefined) {
/* @ts-expect-error Untyped empty array. */ /* @ts-expect-error Untyped empty array. */
errors.externalIds = [] errors.externalIds = []
} }
errors.externalIds[index] = { errors.externalIds[index] = {
serviceIdentifier: 'Please select an ID service.', serviceIdentifier: { code: 'Please select an ID service.' },
} }
} }
}) })
......
Supports Markdown
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