Commit e61c5e29 authored by Ermolaev Timur's avatar Ermolaev Timur

#131 Пофиксил отображение задачи пустышки

parent 5b44f9ae
...@@ -17,7 +17,7 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCopyTask, wid ...@@ -17,7 +17,7 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCopyTask, wid
const styles = { const styles = {
boxSizing: 'border-box', boxSizing: 'border-box',
backgroundColor: color, backgroundColor: color,
height: `${35}px`, height: `35px`,
width: `${width - 10}px`, width: `${width - 10}px`,
position: 'absolute', position: 'absolute',
display: 'flex', display: 'flex',
......
...@@ -2,20 +2,18 @@ import { Grid } from "@mui/material"; ...@@ -2,20 +2,18 @@ import { Grid } from "@mui/material";
import { memo, useEffect, useState } from "react"; import { memo, useEffect, useState } from "react";
import DefaultTask from "../DefaultTask/DefaultTask"; import DefaultTask from "../DefaultTask/DefaultTask";
const heightCell = 45
const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCellHandler, handleOpen, modal, dragTaskHandler, linesInDay, week, copyTask, createCopyTask, month, year}) => {
const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCellHandler, handleOpen, modal, dragTaskHandler, linesInDay, week, copyTask, createCopyTask, month , year}) => {
const [isThisCell, setIsThisCell] = useState(false) const [isThisCell, setIsThisCell] = useState(false)
const [top, setTop] = useState(0)
const cellClass = { const cellClass = {
position: 'relative', position: 'relative',
height: linesInDay?.length ? `${45 * linesInDay.length}px` : `${40}px`, height: linesInDay?.length ? `${heightCell * linesInDay.length}px` : `${40}px`,
borderRight: '1px solid black', borderRight: '1px solid black',
borderBottom: week ? '1px solid black' : null, borderBottom: week ? '1px solid black' : null,
'&:hover': { '&:hover': {
cursor: children ? null :'#d6d2d2', cursor: children ? null : '#d6d2d2',
background: children ? null :'#d6d2d2' background: children ? null : '#d6d2d2'
}, },
} }
...@@ -27,21 +25,25 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell ...@@ -27,21 +25,25 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
const dragOverHandler = (e) => { const dragOverHandler = (e) => {
e.preventDefault(); e.preventDefault();
e.target.style.background = children ? null :'#d6d2d2' e.target.style.background = children ? null : '#d6d2d2'
} }
const dragLeaveHandler = (e) => { const dragLeaveHandler = (e) => {
e.preventDefault(); e.preventDefault();
e.target.style.background = null e.target.style.background = null
} }
const dropHandler = (e) => { const dropHandler = (e) => {
e.stopPropagation() e.stopPropagation()
e.preventDefault(); e.preventDefault();
e.target.style.background = null e.target.style.background = null
dragTaskHandler(dayNumber, parseInt(hours.split(':')[0]), month, year) dragTaskHandler(dayNumber, parseInt(hours.split(':')[0]), month, year)
} }
const onClickHandler = (e) => { const onClickHandler = (e) => {
if (!week) {
console.log(e.nativeEvent.offsetY)
setTop( 40 * Math.ceil((e.nativeEvent.offsetY - 5 * linesInDay.length)/40 - 1))
}
if (copyTask) { if (copyTask) {
createCopyTask(dayNumber, parseInt(hours.split(':')[0]), month, year) createCopyTask(dayNumber, parseInt(hours.split(':')[0]), month, year)
} else { } else {
...@@ -57,12 +59,12 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell ...@@ -57,12 +59,12 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
sx={cellClass} sx={cellClass}
onClick={(e) => { onClickHandler(e) }} onClick={(e) => { onClickHandler(e) }}
onDragOver={(e) => { dragOverHandler(e) }} onDragOver={(e) => { dragOverHandler(e) }}
onDragLeave={(e)=>{dragLeaveHandler(e)}} onDragLeave={(e) => { dragLeaveHandler(e) }}
onDrop={(e) => { dropHandler(e) }} onDrop={(e) => { dropHandler(e) }}
> >
{children} {children}
{isThisCell ? {isThisCell ?
<DefaultTask week={week} /> : null} <DefaultTask week={week} top={top} /> : null}
</Grid> </Grid>
</> </>
......
import { Box } from "@mui/material"; import { Box } from "@mui/material";
import { memo } from "react"; import { memo } from "react";
const MonthDefaultTaskStyles = {
position: 'relative',
height: '30px',
backgroundColor: 'lightgreen',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
borderRadius: '10px',
margin: '5px 10px',
display: 'flex',
justifyContent: 'flex-start',
alignItems: 'center',
paddingLeft: '5px',
zIndex: '5'
}
const WeekDefaultTaskStyles = { const WeekDefaultTaskStyles = {
boxSizing: 'border-box', boxSizing: 'border-box',
padding: '0 5px', padding: '0 5px',
...@@ -31,7 +17,25 @@ const WeekDefaultTaskStyles = { ...@@ -31,7 +17,25 @@ const WeekDefaultTaskStyles = {
} }
const DefaultTask = ({ week }) => { const DefaultTask = ({ week, top }) => {
const MonthDefaultTaskStyles = {
boxSizing: 'border-box',
position: 'relative',
height: '35px',
backgroundColor: 'lightgreen',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
borderRadius: '10px',
margin: '5px 3px 0 6px',
padding: '5px',
top: top,
display: 'flex',
justifyContent: 'flex-start',
alignItems: 'center',
zIndex: '5'
}
return (<> return (<>
<Box <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