Commit c90e117a authored by Ermolaev Timur's avatar Ermolaev Timur

#56 Пофиксил разные баги с драг энд дроп и модальным окном

parent bc35da21
...@@ -25,8 +25,8 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -25,8 +25,8 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
const sortedTasks = useMemo(() => { const sortedTasks = useMemo(() => {
if (availableTasks.length) { if (availableTasks.length) {
const newSortedArr = [...availableTasks].sort(function(a,b){ const newSortedArr = [...availableTasks].sort(function(a,b){
const durattionFirstDate = new Date(a.dateTimeDue).getTime() - new Date(a.dateTimeStart).getTime() const durattionFirstDate = a.infoForCell.endHour - a.infoForCell.startHour
const durattionSecondDate = new Date(b.dateTimeDue).getTime() - new Date(b.dateTimeStart).getTime() const durattionSecondDate = b.infoForCell.endHour - b.infoForCell.startHour
return durattionSecondDate - durattionFirstDate; return durattionSecondDate - durattionFirstDate;
}) })
return newSortedArr return newSortedArr
...@@ -104,7 +104,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -104,7 +104,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
// if (boxes[boxes.length -1]?.task === null) { // if (boxes[boxes.length -1]?.task === null) {
// boxes[boxes.length -1].xs += xs // boxes[boxes.length -1].xs += xs
// } else { // } else {
boxes.push({xs: xs, task: null}) boxes.push({xs: xs, task: null, hour: line[i]})
// } // }
} else { } else {
const task = sortedTasks[line[i].split('-')[1]] const task = sortedTasks[line[i].split('-')[1]]
...@@ -131,8 +131,6 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -131,8 +131,6 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
e.preventDefault(); e.preventDefault();
dragTaskHandler(day.dayNumber, currentHour) dragTaskHandler(day.dayNumber, currentHour)
} }
console.log(sortedTasks)
console.log(linesInDay)
return <> return <>
<Grid <Grid
...@@ -187,7 +185,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -187,7 +185,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
} else { } else {
return (<Grid return (<Grid
onDragOver={(e)=>{dragOverHandler(e)}} onDragOver={(e)=>{dragOverHandler(e)}}
onDrop={(e)=>{dropHandler(e, parseInt(hours[index]))}} onDrop={(e)=>{dropHandler(e, box.hour)}}
item xs={box.xs} sx={{height: '35px', backgroundColor: 'rgb(0,0,0,0)'}}> item xs={box.xs} sx={{height: '35px', backgroundColor: 'rgb(0,0,0,0)'}}>
</Grid>) </Grid>)
......
...@@ -13,10 +13,11 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current ...@@ -13,10 +13,11 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
const [currentLine, setCurrentLine] = useState('') const [currentLine, setCurrentLine] = useState('')
const [modal, setModal] = useState({open:false, y: 0, x: 0,}); const [modal, setModal] = useState({open:false, y: 0, x: 0,});
const handleOpen = (e) => { const handleOpen = (e) => {
console.log(e)
setModal( { setModal( {
open: true, open: true,
yPage: e.pageY, yPage: e.clientY,
xPage: e.pageX, xPage: e.clientX,
yDivClick: e.nativeEvent.offsetY, yDivClick: e.nativeEvent.offsetY,
xDivClick: e.nativeEvent.offsetX, xDivClick: e.nativeEvent.offsetX,
yDiv: e.target.offsetHeight, yDiv: e.target.offsetHeight,
...@@ -39,6 +40,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current ...@@ -39,6 +40,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
}) })
} }
}, [divRef.current?.offsetHeight, hourFormat, month, tasks]); }, [divRef.current?.offsetHeight, hourFormat, month, tasks]);
return ( return (
<div ref={divRef} style={{marginBottom: '30px'}}> <div ref={divRef} style={{marginBottom: '30px'}}>
......
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