Commit 0ae42d59 authored by Ermolaev Timur's avatar Ermolaev Timur

#71 Удалил стрелочки, изменил кнопку, пофиксил чуть отображение

parent 59ece50e
import { Grid } from "@mui/material";
import { memo, useEffect, useMemo, useState } from "react";
import { memo, useMemo} from "react";
import CalendarStandartCell from "../CalendarStandartCell.js/CalendarStandartCell";
import CalendarTask from "../CalendarTask/CalendarTask";
import EmptyBox from "./EmptyBox/EmptyBox";
import { getAvailableTasks, getBoxesInLine, getLinesInDay, getSortedTasks } from "./Helpers";
const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, handleOpen, modal, setCurrentTask, year, month, tasks, day, hourFormat, setCurrentLine, currentLine, dragTaskHandler, increaseTaskHandler, reduceTaskHandler, createCopyTask, setCopyTask, copyTask}) => {
const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, handleOpen, modal, setCurrentTask, year, month, tasks, day, hourFormat, setCurrentLine, currentLine, dragTaskHandler, createCopyTask, setCopyTask, copyTask}) => {
const hours = useMemo(()=>{
return hoursInDay.map((hour)=>parseInt(hour.split(':')[0]))},
......@@ -68,11 +68,8 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
hour={parseInt(hours[index])}
line={day.dayNumber}
task={box.task}
hourFormat={hourFormat}
setCurrentTask={setCurrentTask}
handleOpen={handleOpen}
increaseTaskHandler={increaseTaskHandler}
reduceTaskHandler={reduceTaskHandler}
setCopyTask={setCopyTask}
/>
</Grid>)
......
......@@ -38,6 +38,7 @@ const EmptyBox = ({hourNumber, handleOpen, dayNumber, xs, dragTaskHandler, modal
height: '35px',
backgroundColor: 'rgb(0,0,0,0)',
zIndex: '6',
cursor: copyTask ? 'pointer' : 'default'
}}>
{isThisCell ?
<DefaultTask/> : null}
......
import { Button, Grid} from "@mui/material";
import React, { memo, useEffect, useRef, useState} from "react";
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
import { Grid} from "@mui/material";
import React, { memo, useEffect, useState} from "react";
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
const arrowClass = {
height: '20px',
cursor: 'pointer',
transition: '0.5s',
"&:hover": {
transition: '0.5s',
transform: 'scale(1.2)'
}
}
const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, increaseTaskHandler, reduceTaskHandler, hourFormat, setCopyTask}) => {
const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, setCopyTask}) => {
const [color, setColor] = useState('')
useEffect(() => {
......@@ -57,45 +46,16 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, i
onDragLeave={(e)=>{dragLeaveHandler(e)}}
onDragStart={(e)=>{dragStartHandler(e, line, task)}}
onDragEnd={(e)=>{dragEndHandler(e)}}
sx={{ position: 'relative', height: '30px', backgroundColor: color, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', borderRadius: '10px', margin: '5px 10px', display: 'flex', justifyContent: 'flex-start', alignItems: 'center', paddingLeft: '5px', zIndex: '5', justifyContent: 'space-between'}}
sx={{ position: 'relative', height: '30px', backgroundColor: color, borderRadius: '10px', margin: '5px 10px', display: 'flex', alignItems: 'center', zIndex: '5', justifyContent: 'space-between', padding: '0 15px'}}
onClick={(e)=>{onClickTaskHandler(e, task)}}
>
{task.infoForCell.endHour === task.infoForCell.startHour && hourFormat ?
<>
<div tyle={{display: 'flex', alignItems: 'center'}}>
<div style={{display: 'flex', alignItems: 'center'}}>
<ArrowBackIcon sx={arrowClass} onClick={(e)=>{e.stopPropagation(); increaseTaskHandler(line, task, true)}}/>
<ArrowForwardIcon sx={arrowClass} onClick={(e)=>{e.stopPropagation(); reduceTaskHandler(line, task, true)}}/>
<ArrowBackIcon sx={arrowClass} onClick={(e)=>{e.stopPropagation(); reduceTaskHandler(line, task, false)}}/>
<ArrowForwardIcon sx={arrowClass} onClick={(e)=>{e.stopPropagation(); increaseTaskHandler(line, task, false)}}/>
</div>
</div>
<div>
<span style={{maxWidth: '60%', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>
{task.title}
</div>
</>
</span>
<ContentCopyIcon sx={{width: '20px', cursor: 'pointer'}} onClick={(e)=>{e.stopPropagation(); setCopyTask(task)}}>
</ContentCopyIcon>
:
<>
<div style={{display: 'flex', alignItems: 'center'}}>
<ArrowBackIcon sx={arrowClass} onClick={(e)=>{e.stopPropagation(); increaseTaskHandler(line, task, true)}}/>
<ArrowForwardIcon sx={arrowClass} onClick={(e)=>{e.stopPropagation(); reduceTaskHandler(line, task, true)}}/>
</div>
{task.title}
<div style={{display: 'flex', alignItems: 'center'}}>
<Button sx={{color:'black', fontWeight:'600'}} onClick={(e)=>{e.stopPropagation(); setCopyTask(task)}}>
Copy
</Button>
<ArrowBackIcon sx={arrowClass} onClick={(e)=>{e.stopPropagation(); reduceTaskHandler(line, task, false)}}/>
<ArrowForwardIcon sx={arrowClass} onClick={(e)=>{e.stopPropagation(); increaseTaskHandler(line, task, false)}}/>
</div>
</>
}
</Grid>
</>)
};
......
......@@ -8,7 +8,7 @@ import MonthCalendarModalContent from "../MonthCalendarModalContent/MonthCalenda
import CalendarRowDay from "./CalendarRowDay/CalendarRowDay";
function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, currentTask, setCurrentTask, hourFormat, setHourFormat, onChangeCurrentTaskHandler, sendNewTaskHandler, deleteTaskHandler, cellSizes, hoursInDay, daysInMonth, dragTaskHandler, increaseTaskHandler, reduceTaskHandler, createCopyTask, setCopyTask, copyTask}) {
function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, currentTask, setCurrentTask, hourFormat, setHourFormat, onChangeCurrentTaskHandler, sendNewTaskHandler, deleteTaskHandler, cellSizes, hoursInDay, daysInMonth, dragTaskHandler, createCopyTask, setCopyTask, copyTask}) {
const [currentLine, setCurrentLine] = useState('')
const [modal, setModal] = useState({open:false, y: 0, x: 0,});
......@@ -71,8 +71,6 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
tasks={tasks}
day={day}
hourFormat={hourFormat}
increaseTaskHandler={increaseTaskHandler}
reduceTaskHandler={reduceTaskHandler}
createCopyTask={createCopyTask}
copyTask={copyTask}
setCopyTask={setCopyTask}
......
......@@ -145,68 +145,6 @@ function MonthCalendar() {
setCurrentTask({})
}
const increaseTaskHandler = async (dayNumber, task, isStartTask) => {
const timeEndHour = task.infoForCell.endHour
const timeStartHour = task.infoForCell.startHour
let hourDiff
if (hourFormat) {
hourDiff = 1
} else {
hourDiff = 2
}
let due
let start
if (isStartTask) {
due = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, timeEndHour, 59))
start = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, timeStartHour - hourDiff, 0))
} else {
due = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, timeEndHour + hourDiff, 59))
start = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, timeStartHour, 0))
}
const newObj = {
...task,
dateTimeStart: start,
dateTimeDue: due
}
delete newObj.infoForCell
await dispatch(editCalendarTask(newObj))
setCurrentTask({})
}
const reduceTaskHandler = async (dayNumber, task, isStartTask) => {
const timeEndHour = task.infoForCell.endHour
const timeStartHour = task.infoForCell.startHour
let hourDiff
let hourDiffCheck
if (hourFormat) {
hourDiff = 1
hourDiffCheck = 0
} else {
hourDiff = 2
hourDiffCheck = 1
}
let due
let start
if (task.infoForCell.endHour - task.infoForCell.startHour - hourDiffCheck !== 0) {
if (isStartTask) {
due = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, timeEndHour, 59))
start = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, timeStartHour + hourDiff, 0))
} else {
due = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, timeEndHour - hourDiff, 59))
start = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, dayNumber, timeStartHour, 0))
}
const newObj = {
...task,
dateTimeStart: start,
dateTimeDue: due
}
delete newObj.infoForCell
await dispatch(editCalendarTask(newObj))
setCurrentTask({})
}
}
const sendNewTaskHandler = async () => {
const timeEndHour = currentTask.infoForCell.endHour
const timeStartHour = currentTask.infoForCell.startHour
......@@ -279,8 +217,6 @@ function MonthCalendar() {
hoursInDay={hoursInDay}
daysInMonth={daysInMonth}
dragTaskHandler={dragTaskHandler}
increaseTaskHandler={increaseTaskHandler}
reduceTaskHandler={reduceTaskHandler}
createCopyTask={createCopyTask}
copyTask={copyTask}
setCopyTask={setCopyTask}
......
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