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
Hide 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,
const
tasks
=
getTasksWithInfoForPosition
(
line
,
hoursInDay
,
sortedTasks
,
i
,
rowDaySize
.
width
)
return
(
<>
{
tasks
.
map
((
task
)
=>
{
const
step
=
rowDaySize
.
width
/
hoursInDay
.
length
return
(
<
CalendarTask
key
=
{
task
.
task
.
id
}
...
...
@@ -56,6 +57,7 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
setCopyTask
=
{
setCopyTask
}
dragTaskHandler
=
{
dragTaskHandler
}
hourFormat
=
{
hourFormat
}
step
=
{
step
}
>
<
/CalendarTask
>
)
...
...
planner-front/src/components/Calendars/MonthCalendar/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
7d1a4927
import
{
Grid
}
from
"@mui/material"
;
import
React
,
{
memo
,
useMemo
}
from
"react"
;
import
ContentCopyIcon
from
'@mui/icons-material/ContentCopy'
;
import
React
,
{
memo
,
useCallback
,
useMemo
}
from
"react"
;
import
{
getColorTaskByPriority
}
from
"../../../../../helpers/CalendarHelpers"
;
import
CopyIcon
from
"../../../UI/CopyIcon/CopyIcon"
;
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
,
line
,
setCopyTask
,
width
,
left
,
top
})
=>
{
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
,
setCopyTask
,
width
,
left
,
top
,
dragTaskHandler
,
hourFormat
,
step
})
=>
{
const
color
=
useMemo
(()
=>
{
return
getColorTaskByPriority
(
task
.
priority
)
},
[
task
.
priority
])
const
styles
=
{
boxSizing
:
'border-box'
,
backgroundColor
:
color
,
height
:
`35px`
,
width
:
`
${
width
-
10
}
px`
,
position
:
'absolute'
,
display
:
'flex'
,
left
:
left
+
5
,
top
:
top
,
margin
:
'5px 5px 0 0'
,
padding
:
'5px'
,
textAlign
:
'left'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
borderRadius
:
'10px'
,
alignItems
:
'center'
,
zIndex
:
'5'
,
'&:hover'
:
{
cursor
:
'pointer'
,
boxShadow
:
'inset 0 0 100px 100px rgba(255, 255, 255, 0.3)'
},
}
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
const
styles
=
useMemo
(()
=>
{
return
{
boxSizing
:
'border-box'
,
backgroundColor
:
color
,
height
:
`35px`
,
width
:
`
${
width
-
10
}
px`
,
position
:
'absolute'
,
display
:
'flex'
,
left
:
left
+
5
,
top
:
top
,
margin
:
'5px 5px 0 0'
,
padding
:
'5px'
,
textAlign
:
'left'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
borderRadius
:
'10px'
,
alignItems
:
'center'
,
zIndex
:
'5'
,
'&:hover'
:
{
cursor
:
'pointer'
,
boxShadow
:
'inset 0 0 100px 100px rgba(255, 255, 255, 0.3)'
},
}
},
[
width
,
left
,
top
,
color
])
const
onClickTaskHandler
=
useCallback
((
e
,
task
)
=>
{
e
.
stopPropagation
();
setCurrentTask
((
prevState
)
=>
{
return
{
...
...
@@ -49,42 +46,58 @@ const CalendarTask = ({ setCurrentTask, handleOpen, task, line, setCopyTask, wid
}
});
handleOpen
(
e
)
}
}
,[
handleOpen
,
setCurrentTask
])
const
dragLeaveHandler
=
(
e
)
=>
{
const
dragLeaveHandler
=
useCallback
(
(
e
)
=>
{
e
.
target
.
style
.
boxShadow
=
'none'
}
}
,[])
const
dragStartHandler
=
(
e
,
lin
e
,
task
)
=>
{
const
dragStartHandler
=
useCallback
((
e
,
task
)
=>
{
setCurrentTask
(
task
);
}
}
,[
setCurrentTask
])
const
dragEndHandler
=
(
e
)
=>
{
const
dragEndHandler
=
useCallback
(
(
e
)
=>
{
e
.
target
.
style
.
boxShadow
=
'none'
}
}
,[])
const
onClickCopyIconHandler
=
(
e
)
=>
{
e
.
stopPropagation
();
const
onClickCopyIconHandler
=
useCallback
(
(
e
)
=>
{
e
.
stopPropagation
();
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
(
<>
<
Grid
draggable
=
{
true
}
onDragLeave
=
{(
e
)
=>
{
dragLeaveHandler
(
e
)
}}
onDragStart
=
{(
e
)
=>
{
dragStartHandler
(
e
,
line
,
task
)
}}
onDragStart
=
{(
e
)
=>
{
dragStartHandler
(
e
,
task
)
}}
onDragEnd
=
{(
e
)
=>
{
dragEndHandler
(
e
)
}}
onDrop
=
{(
e
)
=>
{
dropHandler
(
e
,
task
)
}}
onDragOver
=
{(
e
)
=>
{
dragOverHandler
(
e
)
}}
sx
=
{
styles
}
onClick
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)
}}
>
<
span
style
=
{{
maxWidth
:
'60%'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
}}
>
{
task
.
title
}
<
/span
>
<
ContentCopyIcon
sx
=
{{
width
:
'20px'
,
cursor
:
'pointer'
,
marginLeft
:
'auto'
}}
onClick
=
{(
e
)
=>
{
onClickCopyIconHandler
(
e
)
}}
>
<
/ContentCopyIcon
>
<
CopyIcon
onClick
=
{(
e
)
=>
{
onClickCopyIconHandler
(
e
)}}
/
>
<
/Grid
>
<
/>
)
};
...
...
planner-front/src/components/Calendars/UI/CalendarSmallCell/CalendarSmallCell.js
View file @
7d1a4927
...
...
@@ -3,7 +3,7 @@ import { memo } from "react";
const
CalendarSmallCell
=
({
children
,
xs
,
week
})
=>
{
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
}
<
/Grid
>
<
/
>
...
...
planner-front/src/components/Calendars/UI/CalendarStandartCell/CalendarStandartCell.js
View file @
7d1a4927
...
...
@@ -2,13 +2,13 @@ import { Grid } from "@mui/material";
import
{
memo
,
useEffect
,
useState
}
from
"react"
;
import
DefaultTask
from
"../DefaultTask/DefaultTask"
;
const
heightCell
=
4
5
const
CalendarStandartCell
=
({
children
,
xs
,
hours
,
dayNumber
,
createTaskInCellHandler
,
handleOpen
,
modal
,
dragTaskHandler
,
linesInDay
,
week
,
copyTask
,
createCopyTask
,
month
,
year
})
=>
{
const
heightCell
=
4
0
const
CalendarStandartCell
=
({
children
,
xs
,
hours
,
dayNumber
,
createTaskInCellHandler
,
handleOpen
,
modal
,
dragTaskHandler
,
linesInDay
,
week
,
copyTask
,
createCopyTask
,
month
,
year
})
=>
{
const
[
isThisCell
,
setIsThisCell
]
=
useState
(
false
)
const
[
top
,
setTop
]
=
useState
(
0
)
const
cellClass
=
{
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'
,
borderBottom
:
week
?
'1px solid black'
:
null
,
'&:hover'
:
{
...
...
@@ -41,8 +41,11 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
const
onClickHandler
=
(
e
)
=>
{
if
(
!
week
)
{
console
.
log
(
e
.
nativeEvent
.
offsetY
)
setTop
(
40
*
Math
.
ceil
((
e
.
nativeEvent
.
offsetY
-
5
*
linesInDay
.
length
)
/
40
-
1
))
if
(
e
.
nativeEvent
.
offsetY
<=
5
)
{
setTop
(
40
*
Math
.
ceil
((
e
.
nativeEvent
.
offsetY
)
/
40
-
1
))
}
else
{
setTop
(
40
*
Math
.
ceil
((
e
.
nativeEvent
.
offsetY
-
5
)
/
40
-
1
))
}
}
if
(
copyTask
)
{
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
return
getLinesInDay
(
availableTasks
,
sortedTasks
,
hoursInDay
,
hours
,
hourFormat
)
},
[
availableTasks
,
hourFormat
,
hours
,
hoursInDay
,
sortedTasks
])
console
.
log
(
month
,
year
)
return
(
<>
<
Grid
item
xs
=
{
12
/
7
}
ref
=
{
dayColumnRef
}
sx
=
{{
position
:
'relative'
}}
>
{
linesInDay
?.
map
((
line
,
i
)
=>
{
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarWeekTask/CalendarWeekTask.js
View file @
7d1a4927
import
{
Box
}
from
"@mui/material"
import
{
useEffect
,
useState
,
memo
,
useCallback
,
useMemo
}
from
"react"
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
})
{
...
...
@@ -81,13 +81,18 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
}
else
{
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
)
=>
{
e
.
preventDefault
();
}
const
onClickCopyIconHandler
=
useCallback
((
e
)
=>
{
e
.
stopPropagation
();
setCopyTask
(
task
)
},[
task
,
setCopyTask
])
return
(
<
Box
draggable
=
{
true
}
...
...
@@ -102,8 +107,9 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
<
span
style
=
{{
textOverflow
:
'ellipsis'
,
padding
:
'5px 0 0 5px'
}}
>
{
task
.
title
}
<
/span
>
<
ContentCopyIcon
sx
=
{{
marginLeft
:
'auto'
,
marginTop
:
'5px'
}}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCopyTask
(
task
)
}}
>
<
/ContentCopyIcon
>
<
CopyIcon
onClick
=
{(
e
)
=>
{
onClickCopyIconHandler
(
e
)}}
/
>
<
/Box>
)
;
}
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
View file @
7d1a4927
...
...
@@ -172,7 +172,7 @@ function WeekCalendar() {
const
timeStartHour
=
currentTask
.
infoForCell
.
startHour
const
month
=
currentTask
.
infoForCell
.
month
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
start
=
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
day
,
timeStartHour
,
0
))
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