Drag and drop w/ dragSource + dragTarget w/o errors
This commit is contained in:
parent
1333c2b89d
commit
591da12536
@ -57,6 +57,10 @@ function PanelStudyBrowser({
|
|||||||
StudyInstanceUID: ds.StudyInstanceUID,
|
StudyInstanceUID: ds.StudyInstanceUID,
|
||||||
componentType: 'thumbnail', // 'thumbnailNoImage' || 'thumbnailTracked' // TODO: PUT THIS SOMEWHERE ELSE
|
componentType: 'thumbnail', // 'thumbnailNoImage' || 'thumbnailTracked' // TODO: PUT THIS SOMEWHERE ELSE
|
||||||
imageSrc,
|
imageSrc,
|
||||||
|
dragData: {
|
||||||
|
type: 'displayset',
|
||||||
|
// .. Any other data to pass
|
||||||
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -147,21 +147,6 @@ StudyBrowser.propTypes = {
|
|||||||
numInstances: PropTypes.number,
|
numInstances: PropTypes.number,
|
||||||
modalities: PropTypes.string,
|
modalities: PropTypes.string,
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
// These apply to each thumbnail; we should set Thumbnails
|
|
||||||
// As children and kill the <ThumbnailList> component to
|
|
||||||
// make it easier to set this prop.
|
|
||||||
// Do much less nesting so we have a bit more control.
|
|
||||||
/**
|
|
||||||
* 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,
|
|
||||||
}),
|
|
||||||
displaySets: PropTypes.arrayOf(
|
displaySets: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
displaySetInstanceUID: PropTypes.string.isRequired,
|
displaySetInstanceUID: PropTypes.string.isRequired,
|
||||||
@ -178,6 +163,17 @@ StudyBrowser.propTypes = {
|
|||||||
]).isRequired,
|
]).isRequired,
|
||||||
isTracked: PropTypes.bool,
|
isTracked: PropTypes.bool,
|
||||||
viewportIdentificator: PropTypes.string,
|
viewportIdentificator: PropTypes.string,
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|||||||
@ -4,17 +4,17 @@ import PropTypes from 'prop-types';
|
|||||||
import { Thumbnail, ThumbnailNoImage, ThumbnailTracked } from '@ohif/ui';
|
import { Thumbnail, ThumbnailNoImage, ThumbnailTracked } from '@ohif/ui';
|
||||||
|
|
||||||
const ThumbnailList = ({
|
const ThumbnailList = ({
|
||||||
dragData,
|
|
||||||
thumbnails,
|
thumbnails,
|
||||||
thumbnailActive,
|
thumbnailActive,
|
||||||
onThumbnailClick,
|
onThumbnailClick,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className="bg-black py-3">
|
<div className="py-3 bg-black">
|
||||||
{thumbnails.map(
|
{thumbnails.map(
|
||||||
({
|
({
|
||||||
displaySetInstanceUID,
|
displaySetInstanceUID,
|
||||||
description,
|
description,
|
||||||
|
dragData,
|
||||||
seriesNumber,
|
seriesNumber,
|
||||||
numInstances,
|
numInstances,
|
||||||
modality,
|
modality,
|
||||||
@ -80,17 +80,6 @@ const ThumbnailList = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
ThumbnailList.propTypes = {
|
ThumbnailList.propTypes = {
|
||||||
/**
|
|
||||||
* 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,
|
|
||||||
}),
|
|
||||||
thumbnails: PropTypes.arrayOf(
|
thumbnails: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
displaySetInstanceUID: PropTypes.string.isRequired,
|
displaySetInstanceUID: PropTypes.string.isRequired,
|
||||||
@ -107,6 +96,17 @@ ThumbnailList.propTypes = {
|
|||||||
]).isRequired,
|
]).isRequired,
|
||||||
viewportIdentificator: PropTypes.string,
|
viewportIdentificator: PropTypes.string,
|
||||||
isTracked: PropTypes.bool,
|
isTracked: PropTypes.bool,
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
thumbnailActive: PropTypes.string,
|
thumbnailActive: PropTypes.string,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ function ViewportPane({
|
|||||||
onDrop,
|
onDrop,
|
||||||
acceptDropsFor,
|
acceptDropsFor,
|
||||||
}) {
|
}) {
|
||||||
/*const [{ isHovered, isHighlighted }, drop] = useDrop({
|
const [{ isHovered, isHighlighted }, drop] = useDrop({
|
||||||
accept: acceptDropsFor,
|
accept: acceptDropsFor,
|
||||||
// TODO: pass in as prop?
|
// TODO: pass in as prop?
|
||||||
drop: (droppedItem, monitor) => {
|
drop: (droppedItem, monitor) => {
|
||||||
@ -29,11 +29,11 @@ function ViewportPane({
|
|||||||
isHighlighted: monitor.canDrop(),
|
isHighlighted: monitor.canDrop(),
|
||||||
isHovered: monitor.isOver(),
|
isHovered: monitor.isOver(),
|
||||||
}),
|
}),
|
||||||
});*/
|
});
|
||||||
|
|
||||||
// ref={drop}
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
ref={drop}
|
||||||
className={classnames(
|
className={classnames(
|
||||||
'rounded-lg hover:border-primary-light transition duration-300 outline-none overflow-hidden',
|
'rounded-lg hover:border-primary-light transition duration-300 outline-none overflow-hidden',
|
||||||
{
|
{
|
||||||
|
|||||||
@ -76,7 +76,7 @@ function ViewerViewportGrid(props) {
|
|||||||
console.warn('DROPPED ITEM:', droppedItem);
|
console.warn('DROPPED ITEM:', droppedItem);
|
||||||
}}
|
}}
|
||||||
isActive={activeViewportIndex === viewportIndex}
|
isActive={activeViewportIndex === viewportIndex}
|
||||||
></ViewportPane>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +101,7 @@ function ViewerViewportGrid(props) {
|
|||||||
<ViewportPane
|
<ViewportPane
|
||||||
key={viewportIndex}
|
key={viewportIndex}
|
||||||
className="m-1"
|
className="m-1"
|
||||||
|
acceptDropsFor="displayset"
|
||||||
onDrop={() => {
|
onDrop={() => {
|
||||||
/* setDisplaySet for Viewport */
|
/* setDisplaySet for Viewport */
|
||||||
}}
|
}}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user