2020-06-30 22:53:36 +02:00
|
|
|
import React, { useRef } 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-30 17:27:35 +02:00
|
|
|
import classnames from 'classnames';
|
2020-06-10 15:10:00 +02:00
|
|
|
import { useDrag } from 'react-dnd';
|
2020-04-13 12:59:58 +02:00
|
|
|
|
|
|
|
|
import { Icon } from '@ohif/ui';
|
2020-06-30 22:53:36 +02:00
|
|
|
import blurHandlerListener from '../../utils/blurHandlerListener';
|
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,
|
|
|
|
|
onClick,
|
|
|
|
|
dragData,
|
2020-06-30 20:54:21 +02:00
|
|
|
isActive,
|
2020-06-10 15:10:00 +02:00
|
|
|
}) => {
|
|
|
|
|
const [collectedProps, drag, dragPreview] = useDrag({
|
|
|
|
|
item: { ...dragData },
|
|
|
|
|
canDrag: function(monitor) {
|
|
|
|
|
return Object.keys(dragData).length !== 0;
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2020-06-30 22:53:36 +02:00
|
|
|
const thumbnailElement = useRef(null);
|
|
|
|
|
|
2020-04-13 12:59:58 +02:00
|
|
|
return (
|
2020-04-14 00:35:32 +02:00
|
|
|
<div
|
2020-06-30 22:53:36 +02:00
|
|
|
ref={thumbnailElement}
|
|
|
|
|
onFocus={() => blurHandlerListener(thumbnailElement)}
|
2020-06-30 20:54:21 +02:00
|
|
|
className={classnames(
|
2020-06-30 21:05:18 +02:00
|
|
|
'flex flex-row flex-1 px-4 py-3 cursor-pointer outline-none border-transparent hover:border-blue-300 focus:border-blue-300 rounded',
|
2020-06-30 20:54:21 +02:00
|
|
|
isActive ? 'border-2 border-primary-light' : 'border'
|
|
|
|
|
)}
|
2020-06-30 17:27:35 +02:00
|
|
|
id={`thumbnail-${displaySetInstanceUID}`}
|
2020-06-30 20:54:21 +02:00
|
|
|
onDoubleClick={onClick}
|
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" />
|
|
|
|
|
<div className="px-3 mr-4 text-lg text-white rounded-sm bg-primary-main">
|
|
|
|
|
{modality}
|
|
|
|
|
</div>
|
|
|
|
|
<span className="text-base text-blue-300">{seriesDate}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="ml-12 text-base text-white break-all">
|
|
|
|
|
{description}
|
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,
|
|
|
|
|
seriesDate: PropTypes.string.isRequired,
|
2020-04-14 00:35:32 +02:00
|
|
|
onClick: 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;
|