fix(layouts): and fix thumbnail in touch and update migration guide for 3.8 release (#4052)

This commit is contained in:
Alireza authored and GitHub committed 2024-04-18 23:21:02 -04:00
1 parent 28bc8914a8
commit d250d04580
30 files changed
+209 -158

No files matched your search

@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { useDrag } from 'react-dnd';
@@ -35,6 +35,19 @@ const Thumbnail = ({
},
});
const [lastTap, setLastTap] = useState(0);
const handleTouchEnd = e => {
const currentTime = new Date().getTime();
const tapLength = currentTime - lastTap;
if (tapLength < 300 && tapLength > 0) {
onDoubleClick(e);
} else {
onClick(e);
}
setLastTap(currentTime);
};
return (
<div
className={classnames(
@@ -45,6 +58,7 @@ const Thumbnail = ({
data-cy={`study-browser-thumbnail`}
onClick={onClick}
onDoubleClick={onDoubleClick}
onTouchEnd={handleTouchEnd}
role="button"
tabIndex="0"
>
@@ -56,9 +70,6 @@ const Thumbnail = ({
? 'border-primary-light border-2'
: 'border-secondary-light border hover:border-blue-300'
)}
style={{
margin: isActive ? '0' : '1px',
}}
>
{imageSrc ? (
<img
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import { useDrag } from 'react-dnd';
@@ -30,6 +30,19 @@ const ThumbnailNoImage = ({
},
});
const [lastTap, setLastTap] = useState(0);
const handleTouchEnd = e => {
const currentTime = new Date().getTime();
const tapLength = currentTime - lastTap;
if (tapLength < 300 && tapLength > 0) {
onDoubleClick(e);
} else {
onClick(e);
}
setLastTap(currentTime);
};
return (
<div
className={classnames(
@@ -42,6 +55,7 @@ const ThumbnailNoImage = ({
id={`thumbnail-${displaySetInstanceUID}`}
onClick={onClick}
onDoubleClick={onDoubleClick}
onTouchEnd={handleTouchEnd}
role="button"
tabIndex="0"
data-cy={`study-browser-thumbnail-no-image`}
@@ -224,7 +224,6 @@ export function ViewportGridProvider({ children, service }) {
// If empty viewportOptions, we use numRow and numCols to calculate number of viewports
const hasOptions = layoutOptions?.length;
const viewports = new Map<string, Viewport>();
// Options is a temporary state store which can be used by the
// findOrCreate to store state about already found viewports. Typically,
// it will be used to store the display set UID's which are already
@@ -237,7 +236,21 @@ export function ViewportGridProvider({ children, service }) {
for (let col = 0; col < numCols; col++) {
const position = col + row * numCols;
const layoutOption = layoutOptions[position];
const positionId = layoutOption?.positionId || `${col}-${row}`;
let xPos, yPos, w, h;
if (layoutOptions && layoutOptions[position]) {
({ x: xPos, y: yPos, width: w, height: h } = layoutOptions[position]);
} else {
w = 1 / numCols;
h = 1 / numRows;
xPos = col * w;
yPos = row * h;
}
const colIndex = Math.round(xPos * numCols);
const rowIndex = Math.round(yPos * numRows);
const positionId = layoutOption?.positionId || `${colIndex}-${rowIndex}`;
if (hasOptions && position >= layoutOptions.length) {
continue;
@@ -264,16 +277,6 @@ export function ViewportGridProvider({ children, service }) {
// and it is part of the read only state
viewports.set(viewport.viewportId, viewport);
let xPos, yPos, w, h;
if (layoutOptions && layoutOptions[position]) {
({ x: xPos, y: yPos, width: w, height: h } = layoutOptions[position]);
} else {
w = 1 / numCols;
h = 1 / numRows;
xPos = col * w;
yPos = row * h;
}
Object.assign(viewport, {
width: w,
height: h,