Skip to content

Commit

Permalink
can now view selected file in view more tab
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleqhua committed May 14, 2020
1 parent 32f56d2 commit 391f761
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/javascript/components/ActionItemCreationPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class ActionItemCreationPage extends React.Component {
hasFile: true,
}));
}
console.log(this.state.files);
}

handleFileEdit(event, actionItem) {
Expand Down Expand Up @@ -601,6 +600,8 @@ class ActionItemCreationPage extends React.Component {
description={this.state.modalActionItem.description}
category={this.state.modalActionItem.category}
dueDate={this.state.modalActionItem.dueDate}
files={this.state.files}
fileIndex={this.state.modalActionItem.fileIndex}
/>
) : null}
{this.state.editModalOpen ? (
Expand Down
34 changes: 34 additions & 0 deletions app/javascript/components/ViewMoreModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Input,
Fab,
Typography,
Button,
} from '@material-ui/core/';
import styles from './styles';

Expand All @@ -23,6 +24,8 @@ function ViewMoreModal({
isCaseNote,
open,
handleClose,
files,
fileIndex,
}) {
const renderRichText = desc => (
<MUIRichTextEditor value={desc} readOnly toolbar={false} />
Expand Down Expand Up @@ -60,6 +63,36 @@ function ViewMoreModal({
return null;
};

const renderFileName = fileIndex => {
if (fileIndex != null) {
return (
<Grid item>
<Fab
className={classes.iconStyle}
component="span"
variant="extended"
size="small"
aria-label="category"
>
<Typography
className={classes.categoryButtonStyle}
color="primary"
align="center"
onClick={showFile}
>
View File
</Typography>
</Fab>
</Grid >);
}
}

const showFile = url => {
const file = files[fileIndex];
const objectURL = window.URL.createObjectURL(file);
window.open(objectURL, '_blank');
}

return (
<>
<Dialog
Expand All @@ -82,6 +115,7 @@ function ViewMoreModal({
<Grid item>
<h3 className={classes.titleStyle}>{title}</h3>
</Grid>
{renderFileName(fileIndex)}
{isCaseNote ? null : renderCategory(category)}
</Grid>
{isCaseNote ? null : renderDueDate(dueDate)}
Expand Down

0 comments on commit 391f761

Please sign in to comment.