Skip to content

Commit

Permalink
Fix metadata fields not editable during multi edit
Browse files Browse the repository at this point in the history
In the modal for editing multiple events at the same time,
the fields "presenter(s)" and "contributor(s)"
were not editable in some cases. This patch fixes that.
  • Loading branch information
Arnei committed Jan 3, 2025
1 parent fba544d commit 8a91398
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ const DetailsExtendedMetadataTab = ({
) : (
<td className="editable">
{/* Render single value or multi value editable input */}
{field.type === "mixed_text" &&
field.collection?.length !== 0 ? (
{field.type === "mixed_text" ? (
<Field
name={field.id}
fieldInfo={field}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ const DetailsMetadataTab = ({
) : (
<td className="editable">
{/* Render single value or multi value editable input */}
{field.type === "mixed_text" &&
field.collection?.length !== 0 ? (
{field.type === "mixed_text" ? (
<Field
name={field.id}
fieldInfo={field}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ const NewMetadataExtendedPage = <T,>({
)
) : (
<td className="editable ng-isolated-scope">
{field.type === "mixed_text" &&
field.collection?.length !== 0 ? (
{field.type === "mixed_text" ? (
<Field
name={catalog.flavor + "_" + field.id}
fieldInfo={field}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ const NewMetadataPage = <T,>({
</td>
<td className="editable ng-isolated-scope">
{/* Render single value or multi value input */}
{field.type === "mixed_text" &&
field.collection?.length !== 0 ? (
{field.type === "mixed_text" ? (
<Field
name={field.id}
fieldInfo={field}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ const EditMetadataEventsModal = ({
</td>
<td className="editable ng-isolated-scope">
{/* Render single value or multi value input */}
{metadata.type === "mixed_text" &&
!!metadata.collection &&
metadata.collection.length !== 0 ? (
{metadata.type === "mixed_text" ? (
<Field
name={metadata.id}
fieldInfo={metadata}
Expand Down
62 changes: 2 additions & 60 deletions src/components/shared/wizard/RenderMultiField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ const RenderMultiField = ({
// (types: see metadata.json retrieved from backend)
editMode ? (
<>
{fieldInfo.type === "mixed_text" && !!fieldInfo.collection ? (
{fieldInfo.type === "mixed_text" && (
<EditMultiSelect
collection={fieldInfo.collection}
collection={fieldInfo.collection ? fieldInfo.collection : []}
field={field}
fieldValue={fieldValue}
inputValue={inputValue}
Expand All @@ -98,18 +98,6 @@ const RenderMultiField = ({
handleKeyDown={handleKeyDown}
handleBlur={submitValue}
/>
) : (
fieldInfo.type === "mixed_text" && (
<EditMultiValue
setEditMode={setEditMode}
fieldValue={fieldValue}
field={field}
inputValue={inputValue}
removeItem={removeItem}
handleChange={handleChange}
handleKeyDown={handleKeyDown}
/>
)
)}
</>
) : (
Expand Down Expand Up @@ -193,52 +181,6 @@ const EditMultiSelect = ({
);
};

// Renders editable field input for multiple values
const EditMultiValue = ({
setEditMode,
inputValue,
removeItem,
handleChange,
handleKeyDown,
field,
fieldValue,
}: {
setEditMode: (e: boolean) => void
inputValue: HTMLInputElement["value"]
removeItem: (key: number) => void
handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void
handleKeyDown: (event: React.KeyboardEvent) => void
field: FieldProps["field"]
fieldValue: FieldInputProps<unknown>["value"]
}) => {
const { t } = useTranslation();

return (
<>
<div onBlur={() => setEditMode(false)} ref={childRef}>
<input
type="text"
name={field.name}
onKeyDown={(e) => handleKeyDown(e)}
onChange={(e) => handleChange(e)}
value={inputValue}
placeholder={t("EDITABLE.MULTI.PLACEHOLDER")}
/>
</div>
{fieldValue instanceof Array &&
fieldValue.length !== 0 &&
fieldValue.map((item, key) => (
<span className="ng-multi-value" key={key}>
{item}
<button className="button-like-anchor" onClick={() => removeItem(key)}>
<i className="fa fa-times" />
</button>
</span>
))}
</>
);
};

// Shows the values of the array in non-edit mode
const ShowValue = ({
setEditMode,
Expand Down

0 comments on commit 8a91398

Please sign in to comment.