2020-07-22 21:07:20 +02:00
|
|
|
import React from 'react';
|
2020-06-30 20:54:21 +02:00
|
|
|
import classnames from 'classnames';
|
2020-04-13 12:59:58 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2020-06-10 15:10:00 +02:00
|
|
|
import { useDrag } from 'react-dnd';
|
2020-08-14 20:25:08 +02:00
|
|
|
import { Icon, Tooltip, Typography } from '../';
|
2020-04-13 12:59:58 +02:00
|
|
|
|
2020-06-10 15:10:00 +02:00
|
|
|
const ThumbnailNoImage = ({
|
2020-06-30 17:27:35 +02:00
|
|
|
displaySetInstanceUID,
|
2020-06-10 15:10:00 +02:00
|
|
|
description,
|
|
|
|
|
seriesDate,
|
|
|
|
|
modality,
|
2020-07-03 03:41:55 +02:00
|
|
|
modalityTooltip,
|
2020-06-10 15:10:00 +02:00
|
|
|
onClick,
|
2020-07-01 02:49:37 +02:00
|
|
|
onDoubleClick,
|
2020-08-19 21:27:34 +02:00
|
|
|
canReject,
|
|
|
|
|
onReject,
|
2020-06-10 15:10:00 +02:00
|
|
|
dragData,
|
2020-06-30 20:54:21 +02:00
|
|
|
isActive,
|
2020-06-10 15:10:00 +02:00
|
|
|
}) => {
|
|
|
|
|
const [collectedProps, drag, dragPreview] = useDrag({
|
2021-07-08 15:23:09 +02:00
|
|
|
type: "displayset",
|
2020-06-10 15:10:00 +02:00
|
|
|
item: { ...dragData },
|
2020-10-02 04:09:03 +02:00
|
|
|
canDrag: function(monitor) {
|
2020-06-10 15:10:00 +02:00
|
|
|
return Object.keys(dragData).length !== 0;
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2020-04-13 12:59:58 +02:00
|
|
|
return (
|
2020-04-14 00:35:32 +02:00
|
|
|
<div
|
2020-06-30 20:54:21 +02:00
|
|
|
className={classnames(
|
2020-07-10 20:52:58 +02:00
|
|
|
'flex flex-row flex-1 cursor-pointer outline-none border-transparent hover:border-blue-300 focus:border-blue-300 rounded select-none',
|
2020-06-30 20:54:21 +02:00
|
|
|
isActive ? 'border-2 border-primary-light' : 'border'
|
|
|
|
|
)}
|
2020-07-10 20:52:58 +02:00
|
|
|
style={{
|
|
|
|
|
padding: isActive ? '11px' : '12px',
|
|
|
|
|
}}
|
2020-06-30 17:27:35 +02:00
|
|
|
id={`thumbnail-${displaySetInstanceUID}`}
|
2020-07-01 02:49:37 +02:00
|
|
|
onClick={onClick}
|
|
|
|
|
onDoubleClick={onDoubleClick}
|
2020-05-15 14:29:27 +02:00
|
|
|
role="button"
|
|
|
|
|
tabIndex="0"
|
2020-04-14 00:35:32 +02:00
|
|
|
>
|
2020-06-30 22:53:36 +02:00
|
|
|
<div ref={drag}>
|
|
|
|
|
<div className="flex flex-col flex-1">
|
|
|
|
|
<div className="flex flex-row items-center flex-1 mb-2">
|
|
|
|
|
<Icon name="list-bullets" className="w-12 text-secondary-light" />
|
2020-07-03 03:41:55 +02:00
|
|
|
<Tooltip
|
|
|
|
|
position="bottom"
|
|
|
|
|
content={<Typography>{modalityTooltip}</Typography>}
|
|
|
|
|
>
|
|
|
|
|
<div className="px-3 text-lg text-white rounded-sm bg-primary-main">
|
|
|
|
|
{modality}
|
|
|
|
|
</div>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
<span className="ml-4 text-base text-blue-300">{seriesDate}</span>
|
2020-06-30 22:53:36 +02:00
|
|
|
</div>
|
2020-08-19 21:27:34 +02:00
|
|
|
<div className="flex flex-row">
|
2020-10-02 04:09:03 +02:00
|
|
|
{canReject && (
|
|
|
|
|
<Icon
|
|
|
|
|
name="old-trash"
|
|
|
|
|
style={{ minWidth: '12px' }}
|
|
|
|
|
className="w-3 ml-4 text-red-500"
|
|
|
|
|
onClick={onReject}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2020-08-19 21:27:34 +02:00
|
|
|
<div className="ml-4 text-base text-white break-all">
|
|
|
|
|
{description}
|
|
|
|
|
</div>
|
2020-04-13 12:59:58 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-21 20:12:34 +02:00
|
|
|
ThumbnailNoImage.propTypes = {
|
2020-06-30 22:59:57 +02:00
|
|
|
displaySetInstanceUID: PropTypes.string.isRequired,
|
2020-06-30 20:54:21 +02:00
|
|
|
/**
|
|
|
|
|
* Data the thumbnail should expose to a receiving drop target. Use a matching
|
|
|
|
|
* `dragData.type` to identify which targets can receive this draggable item.
|
|
|
|
|
* If this is not set, drag-n-drop will be disabled for this thumbnail.
|
|
|
|
|
*
|
|
|
|
|
* Ref: https://react-dnd.github.io/react-dnd/docs/api/use-drag#specification-object-members
|
|
|
|
|
*/
|
|
|
|
|
dragData: PropTypes.shape({
|
|
|
|
|
/** Must match the "type" a dropTarget expects */
|
|
|
|
|
type: PropTypes.string.isRequired,
|
|
|
|
|
}),
|
2020-04-21 20:12:34 +02:00
|
|
|
description: PropTypes.string.isRequired,
|
|
|
|
|
modality: PropTypes.string.isRequired,
|
2020-07-03 03:41:55 +02:00
|
|
|
/* Tooltip message to display when modality text is hovered */
|
|
|
|
|
modalityTooltip: PropTypes.string.isRequired,
|
2020-04-21 20:12:34 +02:00
|
|
|
seriesDate: PropTypes.string.isRequired,
|
2020-04-14 00:35:32 +02:00
|
|
|
onClick: PropTypes.func.isRequired,
|
2020-07-01 02:49:37 +02:00
|
|
|
onDoubleClick: PropTypes.func.isRequired,
|
2020-06-30 20:54:21 +02:00
|
|
|
isActive: PropTypes.bool.isRequired,
|
2020-04-13 12:59:58 +02:00
|
|
|
};
|
|
|
|
|
|
2020-04-21 20:12:34 +02:00
|
|
|
export default ThumbnailNoImage;
|