2020-04-21 17:44:19 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import classnames from 'classnames';
|
|
|
|
|
|
2023-06-07 15:05:35 +02:00
|
|
|
import Icon from '../Icon';
|
|
|
|
|
import Thumbnail from '../Thumbnail';
|
|
|
|
|
import Tooltip from '../Tooltip';
|
2022-09-20 17:05:26 +02:00
|
|
|
import { StringNumber } from '../../types';
|
2023-12-11 15:43:58 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2020-04-21 17:44:19 +02:00
|
|
|
|
2024-03-27 21:01:32 +01:00
|
|
|
// Todo: This class to me feels like it belongs in an extension, not in platform/ui
|
|
|
|
|
// because it is dealing with mode specific components/information
|
|
|
|
|
function ThumbnailTracked({
|
2020-06-30 17:27:35 +02:00
|
|
|
displaySetInstanceUID,
|
2020-04-21 17:44:19 +02:00
|
|
|
className,
|
|
|
|
|
imageSrc,
|
|
|
|
|
imageAltText,
|
2020-04-21 20:12:46 +02:00
|
|
|
description,
|
2020-04-21 17:44:19 +02:00
|
|
|
seriesNumber,
|
2020-04-21 20:12:46 +02:00
|
|
|
numInstances,
|
2023-03-15 17:41:41 +01:00
|
|
|
countIcon,
|
2023-08-12 00:16:25 +02:00
|
|
|
messages,
|
2020-05-26 16:39:40 +02:00
|
|
|
dragData,
|
2020-04-21 17:44:19 +02:00
|
|
|
onClick,
|
2020-07-01 02:49:37 +02:00
|
|
|
onDoubleClick,
|
2020-06-07 18:08:50 +02:00
|
|
|
onClickUntrack,
|
2020-04-21 17:44:19 +02:00
|
|
|
isTracked,
|
2020-04-21 20:12:46 +02:00
|
|
|
isActive,
|
2023-12-11 15:43:58 +01:00
|
|
|
}) {
|
|
|
|
|
const { t } = useTranslation('ThumbnailTracked');
|
2020-04-21 17:44:19 +02:00
|
|
|
const trackedIcon = isTracked ? 'circled-checkmark' : 'dotted-circle';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
2024-04-16 17:04:48 +02:00
|
|
|
className={classnames('flex flex-1 cursor-pointer flex-row px-3 outline-none', className)}
|
2020-06-30 17:27:35 +02:00
|
|
|
id={`thumbnail-${displaySetInstanceUID}`}
|
2020-04-21 17:44:19 +02:00
|
|
|
>
|
2023-09-01 22:19:39 +02:00
|
|
|
<div className="flex-2 flex flex-col items-center">
|
2020-04-21 17:44:19 +02:00
|
|
|
<div
|
|
|
|
|
className={classnames(
|
2023-09-01 22:19:39 +02:00
|
|
|
'relative mb-2 flex cursor-pointer flex-col items-center justify-start p-2',
|
2020-04-24 00:23:37 +02:00
|
|
|
isTracked && 'rounded-sm hover:bg-gray-900'
|
2020-04-21 17:44:19 +02:00
|
|
|
)}
|
|
|
|
|
>
|
2020-04-24 00:23:37 +02:00
|
|
|
<Tooltip
|
|
|
|
|
position="right"
|
|
|
|
|
content={
|
2023-09-01 22:19:39 +02:00
|
|
|
<div className="flex flex-1 flex-row">
|
|
|
|
|
<div className="flex-2 flex items-center justify-center pr-4">
|
|
|
|
|
<Icon
|
|
|
|
|
name="info-link"
|
|
|
|
|
className="text-primary-active"
|
|
|
|
|
/>
|
2021-07-16 19:32:51 +02:00
|
|
|
</div>
|
2023-09-01 22:19:39 +02:00
|
|
|
<div className="flex flex-1 flex-col">
|
2020-04-21 17:44:19 +02:00
|
|
|
<span>
|
2024-03-27 21:01:32 +01:00
|
|
|
<span className="text-white">
|
|
|
|
|
{isTracked ? t('Series is tracked') : t('Series is untracked')}
|
|
|
|
|
</span>
|
2020-04-21 17:44:19 +02:00
|
|
|
</span>
|
2020-04-24 00:23:37 +02:00
|
|
|
</div>
|
2020-04-21 17:44:19 +02:00
|
|
|
</div>
|
2020-04-24 00:23:37 +02:00
|
|
|
}
|
|
|
|
|
>
|
2023-09-01 22:19:39 +02:00
|
|
|
<Icon
|
|
|
|
|
name={trackedIcon}
|
|
|
|
|
className="text-primary-light mb-2 w-4"
|
|
|
|
|
/>
|
2020-04-24 00:23:37 +02:00
|
|
|
</Tooltip>
|
2020-04-21 17:44:19 +02:00
|
|
|
</div>
|
|
|
|
|
{isTracked && (
|
2020-06-07 18:08:50 +02:00
|
|
|
<div onClick={onClickUntrack}>
|
2023-09-01 22:19:39 +02:00
|
|
|
<Icon
|
|
|
|
|
name="cancel"
|
|
|
|
|
className="text-primary-active w-4"
|
|
|
|
|
/>
|
2020-06-07 18:08:50 +02:00
|
|
|
</div>
|
2020-04-21 17:44:19 +02:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<Thumbnail
|
2020-07-03 03:41:55 +02:00
|
|
|
displaySetInstanceUID={displaySetInstanceUID}
|
2020-04-21 17:44:19 +02:00
|
|
|
imageSrc={imageSrc}
|
|
|
|
|
imageAltText={imageAltText}
|
2020-05-26 16:39:40 +02:00
|
|
|
dragData={dragData}
|
2020-04-21 20:12:46 +02:00
|
|
|
description={description}
|
2020-04-21 17:44:19 +02:00
|
|
|
seriesNumber={seriesNumber}
|
2023-08-12 00:16:25 +02:00
|
|
|
messages={messages}
|
2020-04-21 20:12:46 +02:00
|
|
|
numInstances={numInstances}
|
2023-03-15 17:41:41 +01:00
|
|
|
countIcon={countIcon}
|
2020-04-21 17:44:19 +02:00
|
|
|
isActive={isActive}
|
|
|
|
|
onClick={onClick}
|
2020-07-01 02:49:37 +02:00
|
|
|
onDoubleClick={onDoubleClick}
|
2020-04-21 17:44:19 +02:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2024-03-27 21:01:32 +01:00
|
|
|
}
|
2020-04-21 17:44:19 +02:00
|
|
|
|
|
|
|
|
ThumbnailTracked.propTypes = {
|
2020-05-26 16:39:40 +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-07-01 02:49:37 +02:00
|
|
|
displaySetInstanceUID: PropTypes.string.isRequired,
|
2020-04-21 17:44:19 +02:00
|
|
|
className: PropTypes.string,
|
|
|
|
|
imageSrc: PropTypes.string,
|
|
|
|
|
imageAltText: PropTypes.string,
|
2020-04-21 20:12:46 +02:00
|
|
|
description: PropTypes.string.isRequired,
|
2022-09-09 04:09:28 +02:00
|
|
|
seriesNumber: StringNumber.isRequired,
|
2020-04-21 20:12:46 +02:00
|
|
|
numInstances: PropTypes.number.isRequired,
|
2020-04-21 17:44:19 +02:00
|
|
|
onClick: PropTypes.func.isRequired,
|
2020-07-01 02:49:37 +02:00
|
|
|
onDoubleClick: PropTypes.func.isRequired,
|
2020-06-07 18:08:50 +02:00
|
|
|
onClickUntrack: PropTypes.func.isRequired,
|
2020-04-21 20:12:46 +02:00
|
|
|
isTracked: PropTypes.bool,
|
2023-08-12 00:16:25 +02:00
|
|
|
messages: PropTypes.object,
|
2020-04-21 20:12:46 +02:00
|
|
|
isActive: PropTypes.bool.isRequired,
|
2020-04-21 17:44:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ThumbnailTracked;
|