Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
26d9e4ab
Commit
26d9e4ab
authored
Dec 25, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#131
Пофиксил баги, которые вылезли, и драг энд дроп
parent
2fb152e9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
61 additions
and
65 deletions
+61
-65
CalendarRowDay.js
...lendar/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
+4
-7
Helpers.js
...MonthCalendar/MonthCalendarBody/CalendarRowDay/Helpers.js
+0
-1
CalendarTask.js
...thCalendar/MonthCalendarBody/CalendarTask/CalendarTask.js
+9
-9
MonthCalendarBody.js
...dars/MonthCalendar/MonthCalendarBody/MonthCalendarBody.js
+0
-3
CalendarStandartCell.js
...Calendars/UI/CalendarStandartCell/CalendarStandartCell.js
+12
-14
CalendarColumnDayWeek.js
...lendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
+3
-0
Helpers.js
...onents/Calendars/WeekCalendar/WeekCalendarBody/Helpers.js
+9
-8
WeekCalendarBody.js
...lendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
+4
-3
WeekCalendar.js
planner-front/src/containers/WeekCalendar/WeekCalendar.js
+20
-20
No files found.
planner-front/src/components/Calendars/MonthCalendar/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
View file @
26d9e4ab
...
@@ -3,10 +3,9 @@ import { memo, useEffect, useMemo, useRef, useState } from "react";
...
@@ -3,10 +3,9 @@ import { memo, useEffect, useMemo, useRef, useState } from "react";
import
{
getHoursInDayNumbers
,
getAvailableTasks
,
getLinesInDay
,
getSortedTasks
}
from
"../../../../../helpers/CalendarHelpers"
;
import
{
getHoursInDayNumbers
,
getAvailableTasks
,
getLinesInDay
,
getSortedTasks
}
from
"../../../../../helpers/CalendarHelpers"
;
import
CalendarStandartCell
from
"../../../UI/CalendarStandartCell/CalendarStandartCell"
;
import
CalendarStandartCell
from
"../../../UI/CalendarStandartCell/CalendarStandartCell"
;
import
CalendarTask
from
"../CalendarTask/CalendarTask"
;
import
CalendarTask
from
"../CalendarTask/CalendarTask"
;
import
EmptyBox
from
"./EmptyBox/EmptyBox"
;
import
{
getTasksWithInfoForPosition
}
from
"./Helpers"
;
import
{
getTasksWithInfoForPosition
}
from
"./Helpers"
;
const
CalendarRowDay
=
({
xs
,
hoursInDay
,
createTaskInCellHandler
,
currentTask
,
handleOpen
,
modal
,
setCurrentTask
,
year
,
month
,
tasks
,
day
,
hourFormat
,
setCurrentLine
,
currentLine
,
dragTaskHandler
,
createCopyTask
,
setCopyTask
,
copyTask
})
=>
{
const
CalendarRowDay
=
({
xs
,
hoursInDay
,
createTaskInCellHandler
,
currentTask
,
handleOpen
,
modal
,
setCurrentTask
,
year
,
month
,
tasks
,
day
,
hourFormat
,
dragTaskHandler
,
createCopyTask
,
setCopyTask
,
copyTask
})
=>
{
const
[
rowDaySize
,
setRowDaySize
]
=
useState
({
width
:
0
,
height
:
0
})
const
[
rowDaySize
,
setRowDaySize
]
=
useState
({
width
:
0
,
height
:
0
})
const
dayRowRef
=
useRef
(
''
)
const
dayRowRef
=
useRef
(
''
)
...
@@ -30,11 +29,6 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
...
@@ -30,11 +29,6 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
return
getLinesInDay
(
availableTasks
,
sortedTasks
,
hoursInDay
,
hours
,
hourFormat
)
return
getLinesInDay
(
availableTasks
,
sortedTasks
,
hoursInDay
,
hours
,
hourFormat
)
},
[
availableTasks
,
hourFormat
,
hours
,
hoursInDay
,
sortedTasks
])
},
[
availableTasks
,
hourFormat
,
hours
,
hoursInDay
,
sortedTasks
])
if
(
day
.
dayNumber
===
16
)
{
console
.
log
(
linesInDay
)
console
.
log
(
getTasksWithInfoForPosition
(
linesInDay
[
0
],
hoursInDay
,
sortedTasks
,
0
,
rowDaySize
.
width
))
console
.
log
(
getTasksWithInfoForPosition
(
linesInDay
[
1
],
hoursInDay
,
sortedTasks
,
1
,
rowDaySize
.
width
))
}
return
<>
return
<>
<
Grid
<
Grid
container
container
...
@@ -82,6 +76,9 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
...
@@ -82,6 +76,9 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
currentTask
=
{
currentTask
}
currentTask
=
{
currentTask
}
handleOpen
=
{
handleOpen
}
handleOpen
=
{
handleOpen
}
modal
=
{
modal
}
modal
=
{
modal
}
copyTask
=
{
copyTask
}
createCopyTask
=
{
createCopyTask
}
month
=
{
month
}
>
>
<
/CalendarStandartCell
>
<
/CalendarStandartCell
>
)
)
...
...
planner-front/src/components/Calendars/MonthCalendar/MonthCalendarBody/CalendarRowDay/Helpers.js
View file @
26d9e4ab
export
const
getTasksWithInfoForPosition
=
(
line
,
hoursInDay
,
sortedTasks
,
index
,
rowDayWidth
)
=>
{
export
const
getTasksWithInfoForPosition
=
(
line
,
hoursInDay
,
sortedTasks
,
index
,
rowDayWidth
)
=>
{
const
widthStep
=
rowDayWidth
/
hoursInDay
.
length
const
widthStep
=
rowDayWidth
/
hoursInDay
.
length
console
.
log
(
widthStep
)
if
(
line
)
{
if
(
line
)
{
const
tasks
=
[]
const
tasks
=
[]
for
(
let
i
=
0
;
i
<
line
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
line
.
length
;
i
++
)
{
...
...
planner-front/src/components/Calendars/MonthCalendar/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
26d9e4ab
import
{
Grid
}
from
"@mui/material"
;
import
{
Grid
}
from
"@mui/material"
;
import
React
,
{
memo
,
use
Effect
,
useMemo
,
useState
}
from
"react"
;
import
React
,
{
memo
,
use
Memo
}
from
"react"
;
import
ContentCopyIcon
from
'@mui/icons-material/ContentCopy'
;
import
ContentCopyIcon
from
'@mui/icons-material/ContentCopy'
;
import
{
getColorTaskByPriority
}
from
"../../../../../helpers/CalendarHelpers"
;
import
{
getColorTaskByPriority
}
from
"../../../../../helpers/CalendarHelpers"
;
...
@@ -7,7 +7,7 @@ import { getColorTaskByPriority } from "../../../../../helpers/CalendarHelpers";
...
@@ -7,7 +7,7 @@ import { getColorTaskByPriority } from "../../../../../helpers/CalendarHelpers";
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
,
line
,
setC
urrentLine
,
setC
opyTask
,
width
,
left
,
top
})
=>
{
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
,
line
,
setCopyTask
,
width
,
left
,
top
})
=>
{
const
color
=
useMemo
(()
=>
{
const
color
=
useMemo
(()
=>
{
...
@@ -16,20 +16,19 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCurrentLine,
...
@@ -16,20 +16,19 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCurrentLine,
const
styles
=
{
const
styles
=
{
boxSizing
:
'border-box'
,
boxSizing
:
'border-box'
,
borderRadius
:
'3px'
,
border
:
'1px solid white'
,
backgroundColor
:
color
,
backgroundColor
:
color
,
height
:
`
${
35
}
px`
,
height
:
`
${
35
}
px`
,
width
:
`
${
width
}
px`
,
width
:
`
${
width
-
10
}
px`
,
position
:
'absolute'
,
position
:
'absolute'
,
display
:
'flex'
,
display
:
'flex'
,
left
:
left
,
left
:
left
+
5
,
top
:
top
,
top
:
top
,
margin
:
'5px 5px 0 0'
,
padding
:
'5px'
,
textAlign
:
'left'
,
textAlign
:
'left'
,
overflow
:
'hidden'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
textOverflow
:
'ellipsis'
,
borderRadius
:
'10px'
,
borderRadius
:
'10px'
,
margin
:
'5px 10px'
,
alignItems
:
'center'
,
alignItems
:
'center'
,
zIndex
:
'5'
,
zIndex
:
'5'
,
'&:hover'
:
{
'&:hover'
:
{
...
@@ -55,10 +54,11 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCurrentLine,
...
@@ -55,10 +54,11 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCurrentLine,
const
dragLeaveHandler
=
(
e
)
=>
{
const
dragLeaveHandler
=
(
e
)
=>
{
e
.
target
.
style
.
boxShadow
=
'none'
e
.
target
.
style
.
boxShadow
=
'none'
}
}
const
dragStartHandler
=
(
e
,
line
,
task
)
=>
{
const
dragStartHandler
=
(
e
,
line
,
task
)
=>
{
setCurrentLine
()
setCurrentTask
(
task
);
setCurrentTask
(
task
);
}
}
const
dragEndHandler
=
(
e
)
=>
{
const
dragEndHandler
=
(
e
)
=>
{
e
.
target
.
style
.
boxShadow
=
'none'
e
.
target
.
style
.
boxShadow
=
'none'
}
}
...
@@ -76,7 +76,7 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCurrentLine,
...
@@ -76,7 +76,7 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCurrentLine,
<
span
style
=
{{
maxWidth
:
'60%'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
}}
>
<
span
style
=
{{
maxWidth
:
'60%'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
}}
>
{
task
.
title
}
{
task
.
title
}
<
/span
>
<
/span
>
<
ContentCopyIcon
sx
=
{{
width
:
'20px'
,
cursor
:
'pointer'
}}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCopyTask
(
task
)
}}
>
<
ContentCopyIcon
sx
=
{{
width
:
'20px'
,
cursor
:
'pointer'
,
marginLeft
:
'auto'
}}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCopyTask
(
task
)
}}
>
<
/ContentCopyIcon
>
<
/ContentCopyIcon
>
...
...
planner-front/src/components/Calendars/MonthCalendar/MonthCalendarBody/MonthCalendarBody.js
View file @
26d9e4ab
...
@@ -11,7 +11,6 @@ import { useSelector } from "react-redux";
...
@@ -11,7 +11,6 @@ import { useSelector } from "react-redux";
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
currentTask
,
setCurrentTask
,
hourFormat
,
setHourFormat
,
onChangeCurrentTaskHandler
,
sendNewTaskHandler
,
deleteTaskHandler
,
cellSizes
,
hoursInDay
,
daysInMonth
,
dragTaskHandler
,
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
,
});
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,
});
const
handleOpen
=
useCallback
((
e
)
=>
{
const
handleOpen
=
useCallback
((
e
)
=>
{
setModal
({
setModal
({
...
@@ -65,8 +64,6 @@ function MonthCalendarBody({ month, year, tasks, createTaskInCellHandler, curren
...
@@ -65,8 +64,6 @@ function MonthCalendarBody({ month, year, tasks, createTaskInCellHandler, curren
hoursInDay
=
{
hoursInDay
}
hoursInDay
=
{
hoursInDay
}
currentTask
=
{
currentTask
}
currentTask
=
{
currentTask
}
handleOpen
=
{
handleOpen
}
handleOpen
=
{
handleOpen
}
currentLine
=
{
currentLine
}
setCurrentLine
=
{
setCurrentLine
}
modal
=
{
modal
.
open
}
modal
=
{
modal
.
open
}
setCurrentTask
=
{
setCurrentTask
}
setCurrentTask
=
{
setCurrentTask
}
year
=
{
year
}
year
=
{
year
}
...
...
planner-front/src/components/Calendars/UI/CalendarStandartCell/CalendarStandartCell.js
View file @
26d9e4ab
...
@@ -5,14 +5,18 @@ import DefaultTask from "../DefaultTask/DefaultTask";
...
@@ -5,14 +5,18 @@ import DefaultTask from "../DefaultTask/DefaultTask";
const
CalendarStandartCell
=
({
children
,
xs
,
hours
,
dayNumber
,
createTaskInCellHandler
,
handleOpen
,
modal
,
dragTaskHandler
,
linesInDay
,
week
,
copyTask
,
createCopyTask
,
month
})
=>
{
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
cellClass
=
{
const
cellClass
=
{
position
:
'relative'
,
position
:
'relative'
,
height
:
linesInDay
?.
length
?
`
${
4
0
*
linesInDay
.
length
}
px`
:
`
${
40
}
px`
,
height
:
linesInDay
?.
length
?
`
${
4
5
*
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'
:
{
cursor
:
'pointer'
,
background
:
children
?
null
:
'#d6d2d2'
},
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -28,24 +32,18 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
...
@@ -28,24 +32,18 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
const
dropHandler
=
(
e
)
=>
{
const
dropHandler
=
(
e
)
=>
{
e
.
stopPropagation
()
e
.
stopPropagation
()
e
.
preventDefault
();
e
.
preventDefault
();
dragTaskHandler
(
dayNumber
,
parseInt
(
hours
.
split
(
':'
)[
0
]))
console
.
log
(
dayNumber
,
parseInt
(
hours
.
split
(
':'
)[
0
]))
dragTaskHandler
(
dayNumber
,
parseInt
(
hours
.
split
(
':'
)[
0
]),
month
,
year
)
}
}
const
onClickHandler
=
(
e
)
=>
{
const
onClickHandler
=
(
e
)
=>
{
if
(
linesInDay
?.
length
)
{
if
(
copyTask
)
{
createTaskInCellHandler
(
dayNumber
,
hours
);
createCopyTask
(
dayNumber
,
parseInt
(
hours
.
split
(
':'
)[
0
]),
month
,
year
)
}
else
{
createTaskInCellHandler
(
dayNumber
,
hours
,
month
,
year
);
setIsThisCell
(
true
);
setIsThisCell
(
true
);
handleOpen
(
e
)
handleOpen
(
e
)
}
}
if
(
week
)
{
if
(
copyTask
)
{
createCopyTask
(
dayNumber
,
parseInt
(
hours
.
split
(
':'
)[
0
]),
month
)
}
else
{
createTaskInCellHandler
(
dayNumber
,
hours
,
month
);
setIsThisCell
(
true
);
handleOpen
(
e
)
}
}
}
}
return
<>
return
<>
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
View file @
26d9e4ab
...
@@ -35,6 +35,8 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -35,6 +35,8 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
return
getLinesInDay
(
availableTasks
,
sortedTasks
,
hoursInDay
,
hours
,
hourFormat
)
return
getLinesInDay
(
availableTasks
,
sortedTasks
,
hoursInDay
,
hours
,
hourFormat
)
},
[
availableTasks
,
hourFormat
,
hours
,
hoursInDay
,
sortedTasks
])
},
[
availableTasks
,
hourFormat
,
hours
,
hoursInDay
,
sortedTasks
])
console
.
log
(
month
,
year
)
return
(
<>
return
(
<>
<
Grid
item
xs
=
{
12
/
7
}
ref
=
{
dayColumnRef
}
sx
=
{{
position
:
'relative'
}}
>
<
Grid
item
xs
=
{
12
/
7
}
ref
=
{
dayColumnRef
}
sx
=
{{
position
:
'relative'
}}
>
{
linesInDay
?.
map
((
line
,
i
)
=>
{
{
linesInDay
?.
map
((
line
,
i
)
=>
{
...
@@ -80,6 +82,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -80,6 +82,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
copyTask
=
{
copyTask
}
copyTask
=
{
copyTask
}
createCopyTask
=
{
createCopyTask
}
createCopyTask
=
{
createCopyTask
}
month
=
{
month
}
month
=
{
month
}
year
=
{
year
}
dragTaskHandler
=
{
dragTaskHandler
}
dragTaskHandler
=
{
dragTaskHandler
}
>
>
<
/CalendarStandartCell
>
<
/CalendarStandartCell
>
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/Helpers.js
View file @
26d9e4ab
...
@@ -6,17 +6,18 @@ export const getCurrentWeekDayString = (dayNumber) => {
...
@@ -6,17 +6,18 @@ export const getCurrentWeekDayString = (dayNumber) => {
}
}
}
}
export
const
getMonthToDayColumn
=
(
week
,
weekDay
,
month
)
=>
{
export
const
getMonthAndYearToDayColumn
=
(
week
,
weekDay
,
month
,
year
)
=>
{
if
(
week
[
0
]
>
week
[
6
])
{
if
(
week
[
0
]
>
week
[
6
])
{
if
(
weekDay
<
week
[
0
])
{
if
(
weekDay
<
week
[
0
])
{
if
(
month
===
11
)
{
return
{
month
:
month
,
year
:
year
}
return
0
}
return
month
+
1
}
else
{
}
else
{
return
month
if
(
month
===
0
)
{
return
{
month
:
11
,
year
:
year
-
1
}
}
return
{
month
:
month
-
1
,
year
:
year
}
}
}
}
else
{
}
else
{
return
month
return
{
month
:
month
,
year
:
year
}
}
}
}
}
\ No newline at end of file
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
View file @
26d9e4ab
...
@@ -8,7 +8,7 @@ import CalendarSmallCell from "../../UI/CalendarSmallCell/CalendarSmallCell";
...
@@ -8,7 +8,7 @@ import CalendarSmallCell from "../../UI/CalendarSmallCell/CalendarSmallCell";
import
CalendarStandartCell
from
"../../UI/CalendarStandartCell/CalendarStandartCell"
;
import
CalendarStandartCell
from
"../../UI/CalendarStandartCell/CalendarStandartCell"
;
import
HourFormatSwitch
from
"../../UI/HourFormatSwitch/HourFormatSwitch"
;
import
HourFormatSwitch
from
"../../UI/HourFormatSwitch/HourFormatSwitch"
;
import
CalendarColumnDayWeek
from
"./CalendarColumnDayWeek/CalendarColumnDayWeek"
;
import
CalendarColumnDayWeek
from
"./CalendarColumnDayWeek/CalendarColumnDayWeek"
;
import
{
getCurrentWeekDayString
,
getMonthToDayColumn
}
from
"./Helpers"
;
import
{
getCurrentWeekDayString
,
getMonth
AndYear
ToDayColumn
}
from
"./Helpers"
;
function
WeekCalendarBody
({
week
,
hoursInDay
,
hourFormat
,
setHourFormat
,
date
,
tasks
,
currentTask
,
setCurrentTask
,
onChangeCurrentTaskHandler
,
deleteTaskHandler
,
sendNewTaskHandler
,
createTaskInCellHandler
,
copyTask
,
setCopyTask
,
createCopyTask
,
dragTaskHandler
})
{
function
WeekCalendarBody
({
week
,
hoursInDay
,
hourFormat
,
setHourFormat
,
date
,
tasks
,
currentTask
,
setCurrentTask
,
onChangeCurrentTaskHandler
,
deleteTaskHandler
,
sendNewTaskHandler
,
createTaskInCellHandler
,
copyTask
,
setCopyTask
,
createCopyTask
,
dragTaskHandler
})
{
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,
});
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,
});
...
@@ -66,13 +66,14 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
...
@@ -66,13 +66,14 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
<
Grid
item
xs
=
{
11.005
}
>
<
Grid
item
xs
=
{
11.005
}
>
<
CalendarRow
week
=
{
true
}
>
<
CalendarRow
week
=
{
true
}
>
{
week
?.
map
((
weekDay
,
i
)
=>
{
{
week
?.
map
((
weekDay
,
i
)
=>
{
const
{
month
,
year
}
=
getMonthAndYearToDayColumn
(
week
,
weekDay
,
date
.
month
,
date
.
year
)
return
(
return
(
<
CalendarColumnDayWeek
<
CalendarColumnDayWeek
key
=
{
i
}
key
=
{
i
}
hoursInDay
=
{
hoursInDay
}
hoursInDay
=
{
hoursInDay
}
tasks
=
{
tasks
}
tasks
=
{
tasks
}
month
=
{
getMonthToDayColumn
(
week
,
weekDay
,
date
.
month
)
}
month
=
{
month
}
year
=
{
date
.
year
}
year
=
{
year
}
day
=
{
weekDay
}
day
=
{
weekDay
}
hourFormat
=
{
hourFormat
}
hourFormat
=
{
hourFormat
}
setCurrentTask
=
{
setCurrentTask
}
setCurrentTask
=
{
setCurrentTask
}
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
View file @
26d9e4ab
...
@@ -136,7 +136,7 @@ function WeekCalendar() {
...
@@ -136,7 +136,7 @@ function WeekCalendar() {
setWorkerInfo
({
project
:
''
,
worker
:
''
})
setWorkerInfo
({
project
:
''
,
worker
:
''
})
},
[
workerInfo
?.
worker
?.
user
?.
id
])
},
[
workerInfo
?.
worker
?.
user
?.
id
])
const
createTaskInCellHandler
=
useCallback
((
dayNumber
,
dayHour
,
month
)
=>
{
const
createTaskInCellHandler
=
useCallback
((
dayNumber
,
dayHour
,
month
,
year
)
=>
{
let
hour
let
hour
if
(
!
isNaN
(
dayHour
))
{
if
(
!
isNaN
(
dayHour
))
{
hour
=
dayHour
hour
=
dayHour
...
@@ -153,26 +153,28 @@ function WeekCalendar() {
...
@@ -153,26 +153,28 @@ function WeekCalendar() {
title
:
"Задача"
,
title
:
"Задача"
,
description
:
"описание"
,
description
:
"описание"
,
priority
:
null
,
priority
:
null
,
dateTimeStart
:
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
hour
,
0
)),
dateTimeStart
:
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
,
0
)),
dateTimeDue
:
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
hourDue
,
59
)),
dateTimeDue
:
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hourDue
,
59
)),
infoForCell
:
{
infoForCell
:
{
startHour
:
hour
,
startHour
:
hour
,
endHour
:
hourDue
,
endHour
:
hourDue
,
startDay
:
dayNumber
,
startDay
:
dayNumber
,
month
:
month
month
:
month
,
year
:
year
,
},
},
project
:
allUserProjects
[
0
]?.
id
project
:
allUserProjects
[
0
]?.
id
}
}
setCurrentTask
((
newTask
))
setCurrentTask
((
newTask
))
},
[
dateNow
.
year
,
hourFormat
,
allUserProjects
])
},
[
hourFormat
,
allUserProjects
])
const
sendNewTaskHandler
=
useCallback
(
async
()
=>
{
const
sendNewTaskHandler
=
useCallback
(
async
()
=>
{
const
timeEndHour
=
currentTask
.
infoForCell
.
endHour
const
timeEndHour
=
currentTask
.
infoForCell
.
endHour
const
timeStartHour
=
currentTask
.
infoForCell
.
startHour
const
timeStartHour
=
currentTask
.
infoForCell
.
startHour
const
month
=
currentTask
.
infoForCell
.
month
const
month
=
currentTask
.
infoForCell
.
month
const
day
=
currentTask
.
infoForCell
.
startDay
const
day
=
currentTask
.
infoForCell
.
startDay
const
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
day
,
timeEndHour
-
1
,
59
))
const
year
=
currentTask
.
infoForCell
.
year
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
day
,
timeStartHour
,
0
))
const
due
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
day
,
timeEndHour
-
1
,
59
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
day
,
timeStartHour
,
0
))
if
(
currentTask
.
id
)
{
if
(
currentTask
.
id
)
{
const
newTask
=
{
const
newTask
=
{
...
currentTask
,
...
currentTask
,
...
@@ -195,18 +197,18 @@ function WeekCalendar() {
...
@@ -195,18 +197,18 @@ function WeekCalendar() {
delete
newTask
.
id
delete
newTask
.
id
await
dispatch
(
addCalendarTask
(
newTask
,
userId
))
await
dispatch
(
addCalendarTask
(
newTask
,
userId
))
}
}
},
[
currentTask
,
d
ateNow
.
year
,
d
ispatch
,
user
.
id
,
userId
])
},
[
currentTask
,
dispatch
,
user
.
id
,
userId
])
const
createCopyTask
=
useCallback
(
async
(
dayNumber
,
hour
,
month
)
=>
{
const
createCopyTask
=
useCallback
(
async
(
dayNumber
,
hour
,
month
,
year
)
=>
{
const
hourDiff
=
copyTask
.
infoForCell
.
endHour
-
copyTask
.
infoForCell
.
startHour
const
hourDiff
=
copyTask
.
infoForCell
.
endHour
-
copyTask
.
infoForCell
.
startHour
const
lastHour
=
hoursInDay
[
hoursInDay
.
length
-
1
].
split
(
':'
)[
0
]
const
lastHour
=
hoursInDay
[
hoursInDay
.
length
-
1
].
split
(
':'
)[
0
]
let
due
let
due
if
(
hour
+
hourDiff
>=
lastHour
)
{
if
(
hour
+
hourDiff
>=
lastHour
)
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
lastHour
,
59
))
due
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
lastHour
,
59
))
}
else
{
}
else
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
hour
+
hourDiff
,
59
))
due
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
+
hourDiff
,
59
))
}
}
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
hour
,
0
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
,
0
))
const
newTask
=
{
const
newTask
=
{
...
copyTask
,
...
copyTask
,
dateTimeStart
:
start
,
dateTimeStart
:
start
,
...
@@ -217,18 +219,18 @@ function WeekCalendar() {
...
@@ -217,18 +219,18 @@ function WeekCalendar() {
delete
newTask
.
id
delete
newTask
.
id
await
dispatch
(
addCopyCalendarTask
(
newTask
,
userId
))
await
dispatch
(
addCopyCalendarTask
(
newTask
,
userId
))
setCopyTask
(
null
)
setCopyTask
(
null
)
},
[
copyTask
,
d
ateNow
.
year
,
d
ispatch
,
hoursInDay
,
userId
])
},
[
copyTask
,
dispatch
,
hoursInDay
,
userId
])
const
dragTaskHandler
=
useCallback
(
async
(
dayNumber
,
hour
)
=>
{
const
dragTaskHandler
=
useCallback
(
async
(
dayNumber
,
hour
,
month
,
year
)
=>
{
const
hourDiff
=
currentTask
.
infoForCell
.
endHour
-
currentTask
.
infoForCell
.
startHour
const
hourDiff
=
currentTask
.
infoForCell
.
endHour
-
currentTask
.
infoForCell
.
startHour
const
lastHour
=
hoursInDay
[
hoursInDay
.
length
-
1
].
split
(
':'
)[
0
]
const
lastHour
=
hoursInDay
[
hoursInDay
.
length
-
1
].
split
(
':'
)[
0
]
let
due
let
due
if
(
hour
+
hourDiff
>=
lastHour
)
{
if
(
hour
+
hourDiff
>=
lastHour
)
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
lastHour
,
59
))
due
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
lastHour
,
59
))
}
else
{
}
else
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
+
hourDiff
,
59
))
due
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
+
hourDiff
,
59
))
}
}
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
,
0
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
,
0
))
const
newTask
=
{
const
newTask
=
{
...
currentTask
,
...
currentTask
,
taskId
:
currentTask
.
mainTaskId
,
taskId
:
currentTask
.
mainTaskId
,
...
@@ -239,7 +241,7 @@ function WeekCalendar() {
...
@@ -239,7 +241,7 @@ function WeekCalendar() {
delete
newTask
.
infoForCell
delete
newTask
.
infoForCell
await
dispatch
(
editCalendarTask
(
newTask
,
currentTask
.
id
,
userId
))
await
dispatch
(
editCalendarTask
(
newTask
,
currentTask
.
id
,
userId
))
setCurrentTask
({})
setCurrentTask
({})
},
[
currentTask
,
d
ateNow
.
month
,
dateNow
.
year
,
d
ispatch
,
hoursInDay
,
userId
])
},
[
currentTask
,
dispatch
,
hoursInDay
,
userId
])
const
deleteTaskHandler
=
useCallback
(
async
(
taskId
)
=>
{
const
deleteTaskHandler
=
useCallback
(
async
(
taskId
)
=>
{
dispatch
(
deleteCalendarTask
(
taskId
,
userId
))
dispatch
(
deleteCalendarTask
(
taskId
,
userId
))
...
@@ -259,8 +261,6 @@ function WeekCalendar() {
...
@@ -259,8 +261,6 @@ function WeekCalendar() {
}
}
},
[
dispatch
,
user
.
id
,
userId
])
},
[
dispatch
,
user
.
id
,
userId
])
console
.
log
(
project
)
return
(
return
(
<>
<>
<
DefaultModal
<
DefaultModal
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment