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
5f036ba8
Commit
5f036ba8
authored
Dec 21, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#115
реализовал драг энд дроп задач, даже друг на друга
parent
4ab57d10
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
4 deletions
+77
-4
CalendarColumnDayWeek.js
...lendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
+8
-1
CalendarWeekTask.js
...alendarColumnDayWeek/CalendarWeekTask/CalendarWeekTask.js
+44
-2
WeekCalendarBody.js
...lendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
+2
-1
WeekCalendar.js
planner-front/src/containers/WeekCalendar/WeekCalendar.js
+23
-0
No files found.
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
View file @
5f036ba8
...
@@ -8,9 +8,11 @@ import { getTasksWithInfoForPosition, getWidthLeftZIndex } from "./Helpers";
...
@@ -8,9 +8,11 @@ import { getTasksWithInfoForPosition, getWidthLeftZIndex } from "./Helpers";
function
CalendarColumnDayWeek
({
hoursInDay
,
tasks
,
month
,
year
,
day
,
hourFormat
,
handleOpen
,
setCurrentTask
,
copyTask
,
setCopyTask
,
createCopyTask
,
createTaskInCellHandler
,
modal
})
{
function
CalendarColumnDayWeek
({
hoursInDay
,
tasks
,
month
,
year
,
day
,
hourFormat
,
handleOpen
,
setCurrentTask
,
copyTask
,
setCopyTask
,
createCopyTask
,
createTaskInCellHandler
,
modal
,
dragTaskHandler
})
{
const
[
columnDaySize
,
setColumnDaySize
]
=
useState
({
width
:
0
,
height
:
0
})
const
[
columnDaySize
,
setColumnDaySize
]
=
useState
({
width
:
0
,
height
:
0
})
const
[
diffForDragAndDrop
,
setDiffForDragAndDrop
]
=
useState
(
1
)
const
dayColumnRef
=
useRef
(
''
)
const
dayColumnRef
=
useRef
(
''
)
useEffect
(()
=>
{
useEffect
(()
=>
{
setColumnDaySize
(
prev
=>
{
return
{
height
:
dayColumnRef
.
current
.
offsetHeight
,
width
:
dayColumnRef
.
current
.
offsetWidth
}
})
setColumnDaySize
(
prev
=>
{
return
{
height
:
dayColumnRef
.
current
.
offsetHeight
,
width
:
dayColumnRef
.
current
.
offsetWidth
}
})
...
@@ -41,6 +43,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -41,6 +43,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
return
(
<>
return
(
<>
{
boxes
.
map
((
task
)
=>
{
{
boxes
.
map
((
task
)
=>
{
const
{
width
,
left
,
zIndex
}
=
getWidthLeftZIndex
(
task
,
columnDaySize
.
width
,
i
)
const
{
width
,
left
,
zIndex
}
=
getWidthLeftZIndex
(
task
,
columnDaySize
.
width
,
i
)
const
step
=
columnDaySize
.
height
/
hours
.
length
return
(
return
(
<
CalendarWeekTask
<
CalendarWeekTask
key
=
{
task
.
task
.
id
}
key
=
{
task
.
task
.
id
}
...
@@ -55,6 +58,9 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -55,6 +58,9 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
modal
=
{
modal
}
modal
=
{
modal
}
month
=
{
month
}
month
=
{
month
}
setCopyTask
=
{
setCopyTask
}
setCopyTask
=
{
setCopyTask
}
dragTaskHandler
=
{
dragTaskHandler
}
step
=
{
step
}
hourFormat
=
{
hourFormat
}
>
>
<
/CalendarWeekTask
>
<
/CalendarWeekTask
>
)
)
...
@@ -75,6 +81,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -75,6 +81,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
copyTask
=
{
copyTask
}
copyTask
=
{
copyTask
}
createCopyTask
=
{
createCopyTask
}
createCopyTask
=
{
createCopyTask
}
month
=
{
month
}
month
=
{
month
}
dragTaskHandler
=
{
dragTaskHandler
}
>
>
<
/CalendarStandartCell
>
<
/CalendarStandartCell
>
)
)
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarWeekTask/CalendarWeekTask.js
View file @
5f036ba8
...
@@ -4,7 +4,7 @@ import { getColorTaskByPriority } from "../../../../../../helpers/CalendarHelper
...
@@ -4,7 +4,7 @@ import { getColorTaskByPriority } from "../../../../../../helpers/CalendarHelper
import
ContentCopyIcon
from
'@mui/icons-material/ContentCopy'
;
import
ContentCopyIcon
from
'@mui/icons-material/ContentCopy'
;
function
CalendarWeekTask
({
height
,
width
,
left
,
top
,
task
,
zIndex
,
handleOpen
,
setCurrentTask
,
modal
,
setCopyTask
,
month
})
{
function
CalendarWeekTask
({
height
,
width
,
left
,
top
,
task
,
zIndex
,
handleOpen
,
setCurrentTask
,
modal
,
setCopyTask
,
month
,
dragTaskHandler
,
step
,
hourFormat
})
{
const
[
zIndexStyle
,
setZIndexStyle
]
=
useState
(
10
)
const
[
zIndexStyle
,
setZIndexStyle
]
=
useState
(
10
)
const
color
=
useMemo
(()
=>
{
const
color
=
useMemo
(()
=>
{
return
getColorTaskByPriority
(
task
.
priority
)
return
getColorTaskByPriority
(
task
.
priority
)
...
@@ -53,14 +53,56 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
...
@@ -53,14 +53,56 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
},
},
}
}
const
dragStartHandler
=
(
e
,
task
)
=>
{
setCurrentTask
((
prevState
)
=>
{
return
{
...
task
,
infoForCell
:
{
...
task
?.
infoForCell
,
month
:
month
}
}
});
}
const
dragEndHandler
=
(
e
)
=>
{
e
.
target
.
style
.
boxShadow
=
'none'
}
const
dragOverHandler
=
(
e
)
=>
{
e
.
preventDefault
();
}
const
dropHandler
=
(
e
,
task
)
=>
{
e
.
preventDefault
();
let
hour
if
(
hourFormat
)
{
hour
=
task
.
infoForCell
.
startHour
+
(
Math
.
ceil
(
e
.
nativeEvent
.
offsetY
/
step
)
-
1
)
}
else
{
hour
=
task
.
infoForCell
.
startHour
+
(
Math
.
ceil
(
e
.
nativeEvent
.
offsetY
/
step
)
-
1
+
Math
.
ceil
(
e
.
nativeEvent
.
offsetY
/
step
)
-
1
)
}
dragTaskHandler
(
task
.
infoForCell
.
startDay
,
hour
)
}
const
dragLeaveHandler
=
(
e
)
=>
{
e
.
preventDefault
();
}
return
(
return
(
<
Box
<
Box
draggable
=
{
true
}
onDragStart
=
{(
e
)
=>
{
dragStartHandler
(
e
,
task
)
}}
onDragEnd
=
{(
e
)
=>
{
dragEndHandler
(
e
)
}}
onDrop
=
{(
e
)
=>
{
dropHandler
(
e
,
task
)
}}
onDragOver
=
{(
e
)
=>
{
dragOverHandler
(
e
)
}}
onDragLeave
=
{(
e
)
=>
{
dragLeaveHandler
(
e
)
}}
onClick
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)
}}
onClick
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)
}}
className
=
'calendar_task_block'
sx
=
{
styles
}
>
sx
=
{
styles
}
>
<
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
)
}}
>
<
ContentCopyIcon
sx
=
{{
marginLeft
:
'auto'
,
marginTop
:
'5px'
}}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCopyTask
(
task
)
}}
>
<
/ContentCopyIcon
>
<
/ContentCopyIcon
>
<
/Box>
)
;
<
/Box>
)
;
}
}
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
View file @
5f036ba8
...
@@ -10,7 +10,7 @@ import HourFormatSwitch from "../../HourFormatSwitch/HourFormatSwitch";
...
@@ -10,7 +10,7 @@ import HourFormatSwitch from "../../HourFormatSwitch/HourFormatSwitch";
import
CalendarColumnDayWeek
from
"./CalendarColumnDayWeek/CalendarColumnDayWeek"
;
import
CalendarColumnDayWeek
from
"./CalendarColumnDayWeek/CalendarColumnDayWeek"
;
import
{
getCurrentWeekDayString
,
getMonthToDayColumn
}
from
"./Helpers"
;
import
{
getCurrentWeekDayString
,
getMonthToDayColumn
}
from
"./Helpers"
;
function
WeekCalendarBody
({
week
,
hoursInDay
,
hourFormat
,
setHourFormat
,
date
,
tasks
,
currentTask
,
setCurrentTask
,
onChangeCurrentTaskHandler
,
deleteTaskHandler
,
sendNewTaskHandler
,
createTaskInCellHandler
,
copyTask
,
setCopyTask
,
createCopyTask
})
{
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
,
});
const
handleOpen
=
useCallback
((
e
)
=>
{
const
handleOpen
=
useCallback
((
e
)
=>
{
setModal
({
setModal
({
...
@@ -82,6 +82,7 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
...
@@ -82,6 +82,7 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
copyTask
=
{
copyTask
}
copyTask
=
{
copyTask
}
setCopyTask
=
{
setCopyTask
}
setCopyTask
=
{
setCopyTask
}
createCopyTask
=
{
createCopyTask
}
createCopyTask
=
{
createCopyTask
}
dragTaskHandler
=
{
dragTaskHandler
}
/
>
/
>
)
)
})}
})}
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
View file @
5f036ba8
...
@@ -160,6 +160,28 @@ function WeekCalendar() {
...
@@ -160,6 +160,28 @@ function WeekCalendar() {
setCopyTask
(
null
)
setCopyTask
(
null
)
},
[
copyTask
,
dateNow
.
month
,
dateNow
.
year
,
dispatch
,
hoursInDay
,
userId
])
},
[
copyTask
,
dateNow
.
month
,
dateNow
.
year
,
dispatch
,
hoursInDay
,
userId
])
const
dragTaskHandler
=
useCallback
(
async
(
dayNumber
,
hour
)
=>
{
const
hourDiff
=
currentTask
.
infoForCell
.
endHour
-
currentTask
.
infoForCell
.
startHour
const
lastHour
=
hoursInDay
[
hoursInDay
.
length
-
1
].
split
(
':'
)[
0
]
let
due
if
(
hour
+
hourDiff
>=
lastHour
)
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
lastHour
,
59
))
}
else
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
+
hourDiff
,
59
))
}
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
,
0
))
const
newTask
=
{
...
currentTask
,
taskId
:
currentTask
.
mainTaskId
,
dateTimeStart
:
start
,
dateTimeDue
:
due
}
delete
newTask
.
id
delete
newTask
.
infoForCell
await
dispatch
(
editCalendarTask
(
newTask
,
currentTask
.
id
,
userId
))
setCurrentTask
({})
},
[
currentTask
,
dateNow
.
month
,
dateNow
.
year
,
dispatch
,
hoursInDay
,
userId
])
const
deleteTaskHandler
=
useCallback
(
async
(
taskId
)
=>
{
const
deleteTaskHandler
=
useCallback
(
async
(
taskId
)
=>
{
dispatch
(
deleteCalendarTask
(
taskId
,
userId
))
dispatch
(
deleteCalendarTask
(
taskId
,
userId
))
},[
dispatch
,
userId
])
},[
dispatch
,
userId
])
...
@@ -187,6 +209,7 @@ function WeekCalendar() {
...
@@ -187,6 +209,7 @@ function WeekCalendar() {
createCopyTask
=
{
createCopyTask
}
createCopyTask
=
{
createCopyTask
}
copyTask
=
{
copyTask
}
copyTask
=
{
copyTask
}
setCopyTask
=
{
setCopyTask
}
setCopyTask
=
{
setCopyTask
}
dragTaskHandler
=
{
dragTaskHandler
}
/
>
/
>
<
/
>
<
/
>
);
);
...
...
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