Skip to content

Commit

Permalink
#1178 | fix: multi select file work in DEA
Browse files Browse the repository at this point in the history
  • Loading branch information
vedfordev committed Dec 6, 2024
2 parents 0781cb7 + c4d3b39 commit c9fe3b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/dataEntryApp/components/MediaUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const MediaUploader = ({ label, obsValue, mediaType, update, formElement
const [openImage, setOpenImage] = useState();
const isFileDataType = formElement.getType() === Concept.dataType.File;
const supportedMIMEType = isFileDataType ? getFileMimeType(formElement) : `${mediaType}/*`;
const isMultiSelect = formElement.isMultiSelect() && !isFileDataType;
const isMultiSelect = formElement.isMultiSelect();

useEffect(() => {
addObsResultsToPreview(localObsValue, setPreview);
Expand Down
32 changes: 20 additions & 12 deletions src/dataEntryApp/components/Observations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { subjectService } from "../services/SubjectService";
import { useTranslation } from "react-i18next";
import ErrorIcon from "@material-ui/icons/Error";
import PropTypes from "prop-types";
import { find, get, includes, isEmpty, isNil, lowerCase, map } from "lodash";
import { find, includes, isEmpty, isNil, lowerCase, map } from "lodash";
import clsx from "clsx";
import Colors from "dataEntryApp/Colors";
import { Link } from "react-router-dom";
Expand Down Expand Up @@ -298,19 +298,27 @@ const Observations = ({ observations, additionalRows, form, customKey, highlight
};

const fileOptions = conceptName => {
const signedURL = get(find(mediaDataList, ({ altTag }) => altTag === conceptName), "url");
return _.isNil(signedURL) ? (
const signedURLS = mediaDataList.filter(mediaData => mediaData.altTag === conceptName).map(mediaData => mediaData.url);
return _.isNil(signedURLS) ? (
<TextField>MediaData.MissingSignedMediaMessage</TextField>
) : (
<Link
to={"#"}
onClick={event => {
event.preventDefault();
window.open(signedURL, "_blank");
}}
>
{t("View/Download File")}
</Link>
<>
{signedURLS.map((signedURL, index) => (
<>
<Link
to={"#"}
onClick={event => {
event.preventDefault();
window.open(signedURL, "_blank");
}}
key={index}
>
{t("View/Download File")}
</Link>
<br />
</>
))}
</>
);
};

Expand Down

0 comments on commit c9fe3b1

Please sign in to comment.