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
7d1a4927
Commit
7d1a4927
authored
Dec 25, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#131
Пофиксил баги с недельном календарем и реализовал драг энд дроп на задачи
parent
e61c5e29
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
96 additions
and
61 deletions
+96
-61
CalendarRowDay.js
...lendar/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
+2
-0
CalendarTask.js
...thCalendar/MonthCalendarBody/CalendarTask/CalendarTask.js
+60
-47
CalendarSmallCell.js
...nents/Calendars/UI/CalendarSmallCell/CalendarSmallCell.js
+1
-1
CalendarStandartCell.js
...Calendars/UI/CalendarStandartCell/CalendarStandartCell.js
+8
-5
CopyIcon.js
...er-front/src/components/Calendars/UI/CopyIcon/CopyIcon.js
+13
-0
CalendarColumnDayWeek.js
...lendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
+0
-2
CalendarWeekTask.js
...alendarColumnDayWeek/CalendarWeekTask/CalendarWeekTask.js
+11
-5
WeekCalendar.js
planner-front/src/containers/WeekCalendar/WeekCalendar.js
+1
-1
No files found.
planner-front/src/components/Calendars/MonthCalendar/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
View file @
7d1a4927
...
@@ -42,6 +42,7 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
...
@@ -42,6 +42,7 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
const
tasks
=
getTasksWithInfoForPosition
(
line
,
hoursInDay
,
sortedTasks
,
i
,
rowDaySize
.
width
)
const
tasks
=
getTasksWithInfoForPosition
(
line
,
hoursInDay
,
sortedTasks
,
i
,
rowDaySize
.
width
)
return
(
<>
return
(
<>
{
tasks
.
map
((
task
)
=>
{
{
tasks
.
map
((
task
)
=>
{
const
step
=
rowDaySize
.
width
/
hoursInDay
.
length
return
(
return
(
<
CalendarTask
<
CalendarTask
key
=
{
task
.
task
.
id
}
key
=
{
task
.
task
.
id
}
...
@@ -56,6 +57,7 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
...
@@ -56,6 +57,7 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
setCopyTask
=
{
setCopyTask
}
setCopyTask
=
{
setCopyTask
}
dragTaskHandler
=
{
dragTaskHandler
}
dragTaskHandler
=
{
dragTaskHandler
}
hourFormat
=
{
hourFormat
}
hourFormat
=
{
hourFormat
}
step
=
{
step
}
>
>
<
/CalendarTask
>
<
/CalendarTask
>
)
)
...
...
planner-front/src/components/Calendars/MonthCalendar/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
7d1a4927
import
{
Grid
}
from
"@mui/material"
;
import
{
Grid
}
from
"@mui/material"
;
import
React
,
{
memo
,
useMemo
}
from
"react"
;
import
React
,
{
memo
,
useCallback
,
useMemo
}
from
"react"
;
import
ContentCopyIcon
from
'@mui/icons-material/ContentCopy'
;
import
{
getColorTaskByPriority
}
from
"../../../../../helpers/CalendarHelpers"
;
import
{
getColorTaskByPriority
}
from
"../../../../../helpers/CalendarHelpers"
;
import
CopyIcon
from
"../../../UI/CopyIcon/CopyIcon"
;
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
,
setCopyTask
,
width
,
left
,
top
,
dragTaskHandler
,
hourFormat
,
step
})
=>
{
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
,
line
,
setCopyTask
,
width
,
left
,
top
})
=>
{
const
color
=
useMemo
(()
=>
{
const
color
=
useMemo
(()
=>
{
return
getColorTaskByPriority
(
task
.
priority
)
return
getColorTaskByPriority
(
task
.
priority
)
},
[
task
.
priority
])
},
[
task
.
priority
])
const
styles
=
{
const
styles
=
useMemo
(()
=>
{
return
{
boxSizing
:
'border-box'
,
boxSizing
:
'border-box'
,
backgroundColor
:
color
,
backgroundColor
:
color
,
height
:
`35px`
,
height
:
`35px`
,
...
@@ -36,8 +32,9 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCopyTask, wid
...
@@ -36,8 +32,9 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCopyTask, wid
boxShadow
:
'inset 0 0 100px 100px rgba(255, 255, 255, 0.3)'
boxShadow
:
'inset 0 0 100px 100px rgba(255, 255, 255, 0.3)'
},
},
}
}
},
[
width
,
left
,
top
,
color
])
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
const
onClickTaskHandler
=
useCallback
(
(
e
,
task
)
=>
{
e
.
stopPropagation
();
e
.
stopPropagation
();
setCurrentTask
((
prevState
)
=>
{
setCurrentTask
((
prevState
)
=>
{
return
{
return
{
...
@@ -49,42 +46,58 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCopyTask, wid
...
@@ -49,42 +46,58 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCopyTask, wid
}
}
});
});
handleOpen
(
e
)
handleOpen
(
e
)
}
}
,[
handleOpen
,
setCurrentTask
])
const
dragLeaveHandler
=
(
e
)
=>
{
const
dragLeaveHandler
=
useCallback
(
(
e
)
=>
{
e
.
target
.
style
.
boxShadow
=
'none'
e
.
target
.
style
.
boxShadow
=
'none'
}
}
,[])
const
dragStartHandler
=
(
e
,
lin
e
,
task
)
=>
{
const
dragStartHandler
=
useCallback
((
e
,
task
)
=>
{
setCurrentTask
(
task
);
setCurrentTask
(
task
);
}
}
,[
setCurrentTask
])
const
dragEndHandler
=
(
e
)
=>
{
const
dragEndHandler
=
useCallback
(
(
e
)
=>
{
e
.
target
.
style
.
boxShadow
=
'none'
e
.
target
.
style
.
boxShadow
=
'none'
}
}
,[])
const
onClickCopyIconHandler
=
(
e
)
=>
{
const
onClickCopyIconHandler
=
useCallback
(
(
e
)
=>
{
e
.
stopPropagation
();
e
.
stopPropagation
();
setCopyTask
(
task
)
setCopyTask
(
task
)
},[
task
,
setCopyTask
])
const
dragOverHandler
=
useCallback
((
e
)
=>
{
e
.
preventDefault
();
},[])
const
dropHandler
=
useCallback
((
e
,
task
)
=>
{
e
.
preventDefault
();
let
hour
if
(
hourFormat
)
{
hour
=
task
.
infoForCell
.
startHour
+
(
Math
.
ceil
(
e
.
nativeEvent
.
offsetX
/
step
)
-
1
)
}
else
{
hour
=
task
.
infoForCell
.
startHour
+
(
Math
.
ceil
(
e
.
nativeEvent
.
offsetX
/
step
)
-
1
+
Math
.
ceil
(
e
.
nativeEvent
.
offsetX
/
step
)
-
1
)
}
}
dragTaskHandler
(
task
.
infoForCell
.
startDay
,
hour
)
},[
dragTaskHandler
,
hourFormat
,
step
])
return
(
<>
return
(
<>
<
Grid
<
Grid
draggable
=
{
true
}
draggable
=
{
true
}
onDragLeave
=
{(
e
)
=>
{
dragLeaveHandler
(
e
)
}}
onDragLeave
=
{(
e
)
=>
{
dragLeaveHandler
(
e
)
}}
onDragStart
=
{(
e
)
=>
{
dragStartHandler
(
e
,
line
,
task
)
}}
onDragStart
=
{(
e
)
=>
{
dragStartHandler
(
e
,
task
)
}}
onDragEnd
=
{(
e
)
=>
{
dragEndHandler
(
e
)
}}
onDragEnd
=
{(
e
)
=>
{
dragEndHandler
(
e
)
}}
onDrop
=
{(
e
)
=>
{
dropHandler
(
e
,
task
)
}}
onDragOver
=
{(
e
)
=>
{
dragOverHandler
(
e
)
}}
sx
=
{
styles
}
sx
=
{
styles
}
onClick
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)
}}
onClick
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)
}}
>
>
<
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'
,
marginLeft
:
'auto'
}}
onClick
=
{(
e
)
=>
{
onClickCopyIconHandler
(
e
)
}}
>
<
CopyIcon
<
/ContentCopyIcon
>
onClick
=
{(
e
)
=>
{
onClickCopyIconHandler
(
e
)}}
/
>
<
/Grid
>
<
/Grid
>
<
/>
)
<
/>
)
};
};
...
...
planner-front/src/components/Calendars/UI/CalendarSmallCell/CalendarSmallCell.js
View file @
7d1a4927
...
@@ -3,7 +3,7 @@ import { memo } from "react";
...
@@ -3,7 +3,7 @@ import { memo } from "react";
const
CalendarSmallCell
=
({
children
,
xs
,
week
})
=>
{
const
CalendarSmallCell
=
({
children
,
xs
,
week
})
=>
{
return
<>
return
<>
<
Grid
align
=
'center'
item
xs
=
{
xs
}
sx
=
{{
borderRight
:
week
?
null
:
'1px solid black'
,
height
:
week
?
'4
0
px'
:
null
,
borderBottom
:
week
?
'1px solid black'
:
null
,
}}
>
<
Grid
align
=
'center'
item
xs
=
{
xs
}
sx
=
{{
borderRight
:
week
?
null
:
'1px solid black'
,
height
:
week
?
'4
5
px'
:
null
,
borderBottom
:
week
?
'1px solid black'
:
null
,
}}
>
{
children
}
{
children
}
<
/Grid
>
<
/Grid
>
<
/
>
<
/
>
...
...
planner-front/src/components/Calendars/UI/CalendarStandartCell/CalendarStandartCell.js
View file @
7d1a4927
...
@@ -2,13 +2,13 @@ import { Grid } from "@mui/material";
...
@@ -2,13 +2,13 @@ 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
=
4
5
const
heightCell
=
4
0
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
[
top
,
setTop
]
=
useState
(
0
)
const
cellClass
=
{
const
cellClass
=
{
position
:
'relative'
,
position
:
'relative'
,
height
:
linesInDay
?.
length
?
`
${
heightCell
*
linesInDay
.
length
}
px`
:
`
${
40
}
px`
,
height
:
linesInDay
?.
length
?
`
${
heightCell
*
linesInDay
.
length
+
5
}
px`
:
`
${
45
}
px`
,
borderRight
:
'1px solid black'
,
borderRight
:
'1px solid black'
,
borderBottom
:
week
?
'1px solid black'
:
null
,
borderBottom
:
week
?
'1px solid black'
:
null
,
'&:hover'
:
{
'&:hover'
:
{
...
@@ -41,8 +41,11 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
...
@@ -41,8 +41,11 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
const
onClickHandler
=
(
e
)
=>
{
const
onClickHandler
=
(
e
)
=>
{
if
(
!
week
)
{
if
(
!
week
)
{
console
.
log
(
e
.
nativeEvent
.
offsetY
)
if
(
e
.
nativeEvent
.
offsetY
<=
5
)
{
setTop
(
40
*
Math
.
ceil
((
e
.
nativeEvent
.
offsetY
-
5
*
linesInDay
.
length
)
/
40
-
1
))
setTop
(
40
*
Math
.
ceil
((
e
.
nativeEvent
.
offsetY
)
/
40
-
1
))
}
else
{
setTop
(
40
*
Math
.
ceil
((
e
.
nativeEvent
.
offsetY
-
5
)
/
40
-
1
))
}
}
}
if
(
copyTask
)
{
if
(
copyTask
)
{
createCopyTask
(
dayNumber
,
parseInt
(
hours
.
split
(
':'
)[
0
]),
month
,
year
)
createCopyTask
(
dayNumber
,
parseInt
(
hours
.
split
(
':'
)[
0
]),
month
,
year
)
...
...
planner-front/src/components/Calendars/UI/CopyIcon/CopyIcon.js
0 → 100644
View file @
7d1a4927
import
React
,
{
memo
}
from
"react"
;
import
ContentCopyIcon
from
'@mui/icons-material/ContentCopy'
;
const
styles
=
{
width
:
'20px'
,
cursor
:
'pointer'
,
marginLeft
:
'auto'
}
const
CopyIcon
=
({
onClick
})
=>
{
return
(
<
ContentCopyIcon
sx
=
{
styles
}
onClick
=
{
onClick
}
>
<
/ContentCopyIcon>
)
};
export
default
memo
(
CopyIcon
);
\ No newline at end of file
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
View file @
7d1a4927
...
@@ -35,8 +35,6 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -35,8 +35,6 @@ 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
)
=>
{
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarWeekTask/CalendarWeekTask.js
View file @
7d1a4927
import
{
Box
}
from
"@mui/material"
import
{
Box
}
from
"@mui/material"
import
{
useEffect
,
useState
,
memo
,
useCallback
,
useMemo
}
from
"react"
import
{
useEffect
,
useState
,
memo
,
useCallback
,
useMemo
}
from
"react"
import
{
getColorTaskByPriority
}
from
"../../../../../../helpers/CalendarHelpers"
import
{
getColorTaskByPriority
}
from
"../../../../../../helpers/CalendarHelpers"
import
Co
ntentCopyIcon
from
'@mui/icons-material/ContentCopy'
;
import
Co
pyIcon
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
})
{
...
@@ -81,13 +81,18 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
...
@@ -81,13 +81,18 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
}
else
{
}
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
)
dragTaskHandler
(
task
.
infoForCell
.
startDay
,
hour
,
task
.
infoForCell
.
startMonth
-
1
,
task
.
infoForCell
.
startYear
)
}
}
const
dragLeaveHandler
=
(
e
)
=>
{
const
dragLeaveHandler
=
(
e
)
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
}
}
const
onClickCopyIconHandler
=
useCallback
((
e
)
=>
{
e
.
stopPropagation
();
setCopyTask
(
task
)
},[
task
,
setCopyTask
])
return
(
return
(
<
Box
<
Box
draggable
=
{
true
}
draggable
=
{
true
}
...
@@ -102,8 +107,9 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
...
@@ -102,8 +107,9 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
<
span
style
=
{{
textOverflow
:
'ellipsis'
,
padding
:
'5px 0 0 5px'
}}
>
<
span
style
=
{{
textOverflow
:
'ellipsis'
,
padding
:
'5px 0 0 5px'
}}
>
{
task
.
title
}
{
task
.
title
}
<
/span
>
<
/span
>
<
ContentCopyIcon
sx
=
{{
marginLeft
:
'auto'
,
marginTop
:
'5px'
}}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCopyTask
(
task
)
}}
>
<
CopyIcon
<
/ContentCopyIcon
>
onClick
=
{(
e
)
=>
{
onClickCopyIconHandler
(
e
)}}
/
>
<
/Box>
)
;
<
/Box>
)
;
}
}
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
View file @
7d1a4927
...
@@ -172,7 +172,7 @@ function WeekCalendar() {
...
@@ -172,7 +172,7 @@ function WeekCalendar() {
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
year
=
currentTask
.
infoForCell
.
y
ear
const
year
=
currentTask
.
infoForCell
.
startY
ear
const
due
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
day
,
timeEndHour
-
1
,
59
))
const
due
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
day
,
timeEndHour
-
1
,
59
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
day
,
timeStartHour
,
0
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
day
,
timeStartHour
,
0
))
if
(
currentTask
.
id
)
{
if
(
currentTask
.
id
)
{
...
...
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