|
@@ -6,7 +6,7 @@ import { UserPicture } from '../User/UserPicture';
|
|
|
|
|
|
|
|
type AttachmentProps = {
|
|
type AttachmentProps = {
|
|
|
attachment: IAttachment & HasObjectId,
|
|
attachment: IAttachment & HasObjectId,
|
|
|
- inUse: { [id: string]: boolean },
|
|
|
|
|
|
|
+ inUse: boolean,
|
|
|
onAttachmentDeleteClicked?: (attachment: IAttachment & HasObjectId) => void,
|
|
onAttachmentDeleteClicked?: (attachment: IAttachment & HasObjectId) => void,
|
|
|
isUserLoggedIn?: boolean,
|
|
isUserLoggedIn?: boolean,
|
|
|
};
|
|
};
|
|
@@ -17,22 +17,13 @@ export const Attachment = (props: AttachmentProps): JSX.Element => {
|
|
|
attachment, inUse, isUserLoggedIn, onAttachmentDeleteClicked,
|
|
attachment, inUse, isUserLoggedIn, onAttachmentDeleteClicked,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
- const iconNameByFormat = (format: string) => {
|
|
|
|
|
- return (format.match(/image\/.+/i)) ? 'icon-picture' : 'icon-doc';
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
const _onAttachmentDeleteClicked = () => {
|
|
const _onAttachmentDeleteClicked = () => {
|
|
|
if (onAttachmentDeleteClicked != null) {
|
|
if (onAttachmentDeleteClicked != null) {
|
|
|
onAttachmentDeleteClicked(attachment);
|
|
onAttachmentDeleteClicked(attachment);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const formatIcon = iconNameByFormat(attachment.fileFormat);
|
|
|
|
|
-
|
|
|
|
|
- const fileInUse = (inUse) ? <span className="attachment-in-use badge badge-pill badge-info">In Use</span> : '';
|
|
|
|
|
-
|
|
|
|
|
- const fileType = <span className="attachment-filetype badge badge-pill badge-secondary">{attachment.fileFormat}</span>;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const formatIcon = (attachment.fileFormat.match(/image\/.+/i)) ? 'icon-picture' : 'icon-doc';
|
|
|
const btnDownload = (isUserLoggedIn)
|
|
const btnDownload = (isUserLoggedIn)
|
|
|
? (
|
|
? (
|
|
|
<a className="attachment-download" href={attachment.downloadPathProxied}>
|
|
<a className="attachment-download" href={attachment.downloadPathProxied}>
|
|
@@ -40,14 +31,15 @@ export const Attachment = (props: AttachmentProps): JSX.Element => {
|
|
|
</a>
|
|
</a>
|
|
|
)
|
|
)
|
|
|
: '';
|
|
: '';
|
|
|
-
|
|
|
|
|
const btnTrash = (isUserLoggedIn)
|
|
const btnTrash = (isUserLoggedIn)
|
|
|
? (
|
|
? (
|
|
|
- <a className="text-danger attachment-delete" onClick={() => _onAttachmentDeleteClicked()}>
|
|
|
|
|
|
|
+ <a className="text-danger attachment-delete" onClick={_onAttachmentDeleteClicked}>
|
|
|
<i className="icon-trash" />
|
|
<i className="icon-trash" />
|
|
|
</a>
|
|
</a>
|
|
|
)
|
|
)
|
|
|
: '';
|
|
: '';
|
|
|
|
|
+ const fileType = <span className="attachment-filetype badge badge-pill badge-secondary">{attachment.fileFormat}</span>;
|
|
|
|
|
+ const fileInUse = (inUse) ? <span className="attachment-in-use badge badge-pill badge-info">In Use</span> : '';
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className="attachment mb-2">
|
|
<div className="attachment mb-2">
|