Skip to content

Commit

Permalink
Merge pull request #4811 from kobotoolbox/fix-could-not-find-attachment
Browse files Browse the repository at this point in the history
`Could not find attachment` fix with filenames which contain non-latin characters.
  • Loading branch information
LMNTL committed Jan 24, 2024
2 parents a06c73e + c2f56d7 commit b38e778
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import singleProcessingStore from 'js/components/processing/singleProcessingStore';
import SubmissionDataList from 'js/components/submissions/submissionDataList';
import {
getQuestionXPath,
getRowData,
getMediaAttachment,
} from 'js/components/submissions/submissionUtils';
Expand Down Expand Up @@ -81,8 +82,13 @@ export default class SingleProcessingSubmissionDetails extends React.Component<S
return null;
}

// Attachment needs to be object with urls.
const attachment = getMediaAttachment(submissionData, rowData);
// Attachment needs to be an object with urls.
const questionXPath = getQuestionXPath(
this.props.assetContent.survey,
singleProcessingStore.currentQuestionName
);

const attachment = getMediaAttachment(submissionData, rowData, questionXPath);
if (typeof attachment === 'string') {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions jsapp/js/components/submissions/submissionDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class SubmissionDataTable extends React.Component<SubmissionDataTableProps> {
);
}
}

}

renderGroup(item: DisplayGroup, itemIndex?: number) {

return (
<bem.SubmissionDataTable__row
m={['group', `type-${item.type}`]}
Expand Down Expand Up @@ -202,7 +202,7 @@ class SubmissionDataTable extends React.Component<SubmissionDataTableProps> {
case QUESTION_TYPES.audio.id:
case QUESTION_TYPES.video.id:
case QUESTION_TYPES.file.id:
return this.renderAttachment(item.type, item.data, item.name);
return this.renderAttachment(item.type, item.data, item.name, item.xpath);
case QUESTION_TYPES.geotrace.id:
return this.renderMultiplePointsData(item.data);
case QUESTION_TYPES.geoshape.id:
Expand Down Expand Up @@ -260,8 +260,8 @@ class SubmissionDataTable extends React.Component<SubmissionDataTableProps> {
));
}

renderAttachment(type: string, filename: string, name: string) {
const attachment = getMediaAttachment(this.props.submissionData, filename);
renderAttachment(type: string, filename: string, name: string, xpath: string) {
const attachment = getMediaAttachment(this.props.submissionData, filename, xpath);
if (attachment && attachment instanceof Object) {
if (type === QUESTION_TYPES.audio.id) {
return (
Expand Down

0 comments on commit b38e778

Please sign in to comment.