Skip to content

Commit

Permalink
32162 Object store managed attribute labels not attached to correct data
Browse files Browse the repository at this point in the history
- Changed DinaForm to DinaFormSection in ManagedAttributesViewer to override initialValues
- Changed initial values from array to object, this is where the problem was
- Override managedAttributes values with sorted values
- Changed FieldView name to get the correct managed attributes key
  • Loading branch information
johnphan96 committed Oct 27, 2023
1 parent f2d63b1 commit 6cdaa30
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { DinaForm, FieldView, useApiClient, useIsMounted } from "common-ui";
import {
DinaForm,
DinaFormSection,
FieldView,
useApiClient,
useIsMounted
} from "common-ui";
import { toPairs } from "lodash";
import { ManagedAttribute } from "../../types/collection-api";
import { useEffect, useState } from "react";
Expand Down Expand Up @@ -61,18 +67,21 @@ export function ManagedAttributesViewer({
name: allAttrKeyNameMap[item.key]
}))
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));

const managedAttributesInitialValues = managedAttributeValues.reduce(
(prev, curr) => ({ ...prev, [curr.key]: curr.value }),
{}
);
return (
<DinaForm initialValues={managedAttributeValues} readOnly={true}>
<DinaFormSection initialValues={managedAttributesInitialValues}>
{managedAttributeValues.length ? (
<div className="row">
{managedAttributeValues.map((mav, index) => {
{managedAttributeValues.map((mav) => {
return (
<FieldView
key={mav.key}
className="col-6"
label={mav.name}
name={`${index}.value`}
name={`managedAttributes.${mav.key}`}
key={mav.key}
/>
);
})}
Expand All @@ -82,6 +91,6 @@ export function ManagedAttributesViewer({
<DinaMessage id="noManagedAttributeValues" />
</div>
)}
</DinaForm>
</DinaFormSection>
);
}

0 comments on commit 6cdaa30

Please sign in to comment.