Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/shared/DropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Select from "react-select";
* - Creating typescript types for each "type" is moot atm, as a lot of them (i.e. capture agents) are not properly typed yet
* I would suggest waiting with typing options until all of its inputs are properly typed
*/
export type DropDownType = "language" | "isPartOf" | "captureAgent" | "aclRole" | "workflow" | "aclTemplate" | "newTheme" | "comment" | "theme" | "time";
export type DropDownType = "language" | "isPartOf" | "license" | "captureAgent" | "aclRole" | "workflow" | "aclTemplate" | "newTheme" | "comment" | "theme" | "time";

// type DPTime = {
// index: number,
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/wizard/RenderField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const RenderField = ({
metadataField={metadataField}
field={field}
form={form}
text={field.value}
text={t(getMetadataCollectionFieldName(metadataField, field))}
editMode={editMode}
setEditMode={setEditMode}
showCheck={showCheck}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dropDownUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const formatDropDownOptions = (
label: `-- ${t("SELECT_NO_OPTION_SELECTED")} --`,
});
}
if (type === "language") {
if (type === "language" || type === "license") {
for (const item of unformattedOptions) {
formattedOptions.push({
value: item.value,
Expand Down
22 changes: 15 additions & 7 deletions src/utils/resourceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Acl } from "../slices/aclSlice";
import { NewUser } from "../slices/userSlice";
import { Recording } from "../slices/recordingSlice";
import { UserInfoState } from "../slices/userInfoSlice";
import { hasAccess } from "./utils";
import { hasAccess, isJson } from "./utils";
import { RootState } from "../store";
import { MetadataCatalog } from "../slices/eventSlice";

Expand Down Expand Up @@ -141,8 +141,7 @@ export const getInitialMetadataFieldValues = (
};

// transform collection of metadata into object with name and value
// @ts-expect-error TS(7006): Parameter 'metadata' implicitly has an 'any' type.
export const transformMetadataCollection = (metadata, noField) => {
export const transformMetadataCollection = (metadata: any, noField: boolean) => {
if (noField) {
for (let i = 0; metadata.length > i; i++) {
if (!!metadata[i].collection) {
Expand All @@ -166,10 +165,19 @@ export const transformMetadataCollection = (metadata, noField) => {
metadata.fields[i].collection = Object.keys(
metadata.fields[i].collection
).map((key) => {
return {
name: key,
value: metadata.fields[i].collection[key],
};
if (isJson(key)) {
let collectionParsed = JSON.parse(key);
return {
name: collectionParsed.label ? collectionParsed.label : key,
value: metadata.fields[i].collection[key],
...collectionParsed,
};
} else {
return {
name: key,
value: metadata.fields[i].collection[key],
};
}
});
}
}
Expand Down