Commit d56c1f40 authored by Ermolaev Timur's avatar Ermolaev Timur

Merge branch 'task-134-enhance/enhance-copy-task-weekly' into 'development'

#134 исправил кнопку копирования

See merge request !108
parents d5fb9f2c f9ec068f
......@@ -11,7 +11,7 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
height: linesInDay?.length ? `${heightCell * linesInDay.length + 5}px` : `${45}px`,
borderRight: '1px solid black',
borderBottom: week ? '1px solid black' : null,
transition: '0.3s',
transition: week ? '0.3s' : null,
'&:hover': {
transition: '0.3s',
cursor: children ? null : '#d6d2d2',
......
......@@ -2,9 +2,8 @@
import React, { memo} from "react";
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
const styles = { width: '20px', cursor: 'pointer', marginLeft: 'auto' }
const CopyIcon = ({onClick}) => {
const CopyIcon = ({onClick, tasksLength}) => {
const styles = { width: '20px', cursor: 'pointer', marginLeft: tasksLength > 2 ? '5px' : 'auto', marginTop: tasksLength ? '5px' : 0 }
return (
<ContentCopyIcon sx={styles} onClick={onClick}>
</ContentCopyIcon>)
......
......@@ -43,6 +43,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
{boxes.map((task) => {
const { width, left, zIndex } = getWidthLeftZIndex(task, columnDaySize.width, i)
const step = columnDaySize.height / hours.length
const tasksLength = task.tasksInHour
return (
<CalendarWeekTask
key={task.task.id}
......@@ -59,6 +60,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
setCopyTask={setCopyTask}
dragTaskHandler={dragTaskHandler}
step={step}
tasksLength={tasksLength}
hourFormat={hourFormat}
>
</CalendarWeekTask>
......
......@@ -4,7 +4,7 @@ import { getColorTaskByPriority } from "../../../../../../helpers/CalendarHelper
import CopyIcon from "../../../../UI/CopyIcon/CopyIcon";
function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen, setCurrentTask, modal, setCopyTask, month, dragTaskHandler, step, hourFormat}) {
function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen, setCurrentTask, modal, setCopyTask, month, dragTaskHandler, step, hourFormat, tasksLength }) {
const [zIndexStyle, setZIndexStyle] = useState(10)
const color = useMemo(() => {
return getColorTaskByPriority(task.priority)
......@@ -79,9 +79,9 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
e.preventDefault();
let hour
if (hourFormat) {
hour = task.infoForCell.startHour + (Math.ceil(e.nativeEvent.offsetY/step)-1)
hour = task.infoForCell.startHour + (Math.ceil(e.nativeEvent.offsetY / step) - 1)
} else {
hour = task.infoForCell.startHour + (Math.ceil(e.nativeEvent.offsetY/step)-1 + Math.ceil(e.nativeEvent.offsetY/step)-1)
hour = task.infoForCell.startHour + (Math.ceil(e.nativeEvent.offsetY / step) - 1 + Math.ceil(e.nativeEvent.offsetY / step) - 1)
}
dragTaskHandler(task.infoForCell.startDay, hour, task.infoForCell.startMonth - 1, task.infoForCell.startYear)
}
......@@ -93,25 +93,35 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
const onClickCopyIconHandler = useCallback((e) => {
e.stopPropagation();
setCopyTask(task)
},[task, setCopyTask])
}, [task, setCopyTask])
console.log(tasksLength)
return (
<Box
draggable={true}
onDragStart={(e) => { dragStartHandler(e, task) }}
onDragEnd={(e) => { dragEndHandler(e) }}
onDrop={(e) => { dropHandler(e, task) }}
onDragOver ={(e) => { dragOverHandler(e) }}
onDragOver={(e) => { dragOverHandler(e) }}
onDragLeave={(e) => { dragLeaveHandler(e) }}
onClick={(e) => { onClickTaskHandler(e, task) }}
className='calendar_task_block'
sx={styles}>
{tasksLength > 2 ? <>
<CopyIcon
tasksLength={tasksLength}
onClick={(e) => { onClickCopyIconHandler(e) }}
/>
<span style={{ textOverflow: 'ellipsis', padding: '5px 0 0 5px' }}>
{task.title}
</span>
</>
: <>
<span style={{ textOverflow: 'ellipsis', padding: '5px 0 0 5px' }}>
{task.title}
</span>
<CopyIcon
onClick={(e) => { onClickCopyIconHandler(e)}}
/>
onClick={(e) => { onClickCopyIconHandler(e) }}
/> </>}
</Box>);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment