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
d2e218f1
Commit
d2e218f1
authored
Dec 20, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#113
Пофиксил баги, реализовал копирование задачи
parent
0b83e0ac
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
21 deletions
+65
-21
CalendarStandartCell.js
...ts/Calendars/CalendarStandartCell/CalendarStandartCell.js
+10
-5
CalendarColumnDayWeek.js
...lendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
+6
-2
CalendarWeekTask.js
...alendarColumnDayWeek/CalendarWeekTask/CalendarWeekTask.js
+7
-2
WeekCalendarBody.js
...lendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
+4
-1
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+2
-3
WeekCalendar.js
planner-front/src/containers/WeekCalendar/WeekCalendar.js
+36
-8
No files found.
planner-front/src/components/Calendars/CalendarStandartCell/CalendarStandartCell.js
View file @
d2e218f1
...
...
@@ -5,7 +5,7 @@ import DefaultTask from "../DefaultTask/DefaultTask";
const
CalendarStandartCell
=
({
children
,
xs
,
hours
,
dayNumber
,
createTaskInCellHandler
,
handleOpen
,
modal
,
dragTaskHandler
,
linesInDay
,
week
})
=>
{
const
CalendarStandartCell
=
({
children
,
xs
,
hours
,
dayNumber
,
createTaskInCellHandler
,
handleOpen
,
modal
,
dragTaskHandler
,
linesInDay
,
week
,
copyTask
,
createCopyTask
,
month
})
=>
{
const
[
isThisCell
,
setIsThisCell
]
=
useState
(
false
)
const
cellClass
=
{
...
...
@@ -30,6 +30,7 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
e
.
preventDefault
();
dragTaskHandler
(
dayNumber
,
parseInt
(
hours
.
split
(
':'
)[
0
]))
}
const
onClickHandler
=
(
e
)
=>
{
if
(
linesInDay
?.
length
)
{
createTaskInCellHandler
(
dayNumber
,
hours
);
...
...
@@ -37,11 +38,15 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
handleOpen
(
e
)
}
if
(
week
)
{
createTaskInCellHandler
(
dayNumber
,
hours
);
if
(
copyTask
)
{
createCopyTask
(
dayNumber
,
parseInt
(
hours
.
split
(
':'
)[
0
]),
month
)
}
else
{
createTaskInCellHandler
(
dayNumber
,
hours
,
month
);
setIsThisCell
(
true
);
handleOpen
(
e
)
}
}
}
return
<>
<
Grid
...
...
@@ -53,7 +58,7 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
>
{
children
}
{
isThisCell
?
<
DefaultTask
week
=
{
week
}
/> : null
}
<
DefaultTask
week
=
{
week
}
/> : null
}
<
/Grid
>
<
/
>
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
View file @
d2e218f1
...
...
@@ -8,10 +8,9 @@ import { getTasksWithInfoForPosition, getWidthLeftZIndex } from "./Helpers";
function
CalendarColumnDayWeek
({
hoursInDay
,
tasks
,
month
,
year
,
day
,
hourFormat
,
handleOpen
,
setCurrentTask
,
copyTask
,
createCopyTask
,
createTaskInCellHandler
,
modal
})
{
function
CalendarColumnDayWeek
({
hoursInDay
,
tasks
,
month
,
year
,
day
,
hourFormat
,
handleOpen
,
setCurrentTask
,
copyTask
,
setCopyTask
,
createCopyTask
,
createTaskInCellHandler
,
modal
})
{
const
[
columnDaySize
,
setColumnDaySize
]
=
useState
({
width
:
0
,
height
:
0
})
const
dayColumnRef
=
useRef
(
''
)
useEffect
(()
=>
{
setColumnDaySize
(
prev
=>
{
return
{
height
:
dayColumnRef
.
current
.
offsetHeight
,
width
:
dayColumnRef
.
current
.
offsetWidth
}
})
...
...
@@ -54,6 +53,8 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
handleOpen
=
{
handleOpen
}
setCurrentTask
=
{
setCurrentTask
}
modal
=
{
modal
}
month
=
{
month
}
setCopyTask
=
{
setCopyTask
}
>
<
/CalendarWeekTask
>
)
...
...
@@ -71,6 +72,9 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
dayNumber
=
{
day
}
hours
=
{
hour
}
modal
=
{
modal
}
copyTask
=
{
copyTask
}
createCopyTask
=
{
createCopyTask
}
month
=
{
month
}
>
<
/CalendarStandartCell
>
)
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarWeekTask/CalendarWeekTask.js
View file @
d2e218f1
import
{
Box
}
from
"@mui/material"
import
{
useEffect
,
useState
,
memo
,
useCallback
,
useMemo
}
from
"react"
import
{
getColorTaskByPriority
}
from
"../../../../../../helpers/CalendarHelpers"
import
ContentCopyIcon
from
'@mui/icons-material/ContentCopy'
;
function
CalendarWeekTask
({
height
,
width
,
left
,
top
,
task
,
zIndex
,
handleOpen
,
setCurrentTask
,
modal
})
{
function
CalendarWeekTask
({
height
,
width
,
left
,
top
,
task
,
zIndex
,
handleOpen
,
setCurrentTask
,
modal
,
setCopyTask
,
month
})
{
const
[
zIndexStyle
,
setZIndexStyle
]
=
useState
(
10
)
const
color
=
useMemo
(()
=>
{
return
getColorTaskByPriority
(
task
.
priority
)
...
...
@@ -22,7 +23,8 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
...
task
,
infoForCell
:
{
...
task
.
infoForCell
,
endHour
:
task
.
infoForCell
.
endHour
+
1
endHour
:
task
.
infoForCell
.
endHour
+
1
,
month
:
month
}
}
});
...
...
@@ -38,6 +40,7 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
height
:
`
${
height
-
1
}
px`
,
width
:
`
${
width
-
1
}
px`
,
position
:
'absolute'
,
display
:
'flex'
,
left
:
left
,
top
:
top
,
zIndex
:
zIndexStyle
,
...
...
@@ -57,6 +60,8 @@ 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
>
<
/Box>
)
;
}
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
View file @
d2e218f1
...
...
@@ -10,7 +10,7 @@ import HourFormatSwitch from "../../HourFormatSwitch/HourFormatSwitch";
import
CalendarColumnDayWeek
from
"./CalendarColumnDayWeek/CalendarColumnDayWeek"
;
import
{
getCurrentWeekDayString
,
getMonthToDayColumn
}
from
"./Helpers"
;
function
WeekCalendarBody
({
week
,
hoursInDay
,
hourFormat
,
setHourFormat
,
date
,
tasks
,
currentTask
,
setCurrentTask
,
onChangeCurrentTaskHandler
,
deleteTaskHandler
,
sendNewTaskHandler
,
createTaskInCellHandler
})
{
function
WeekCalendarBody
({
week
,
hoursInDay
,
hourFormat
,
setHourFormat
,
date
,
tasks
,
currentTask
,
setCurrentTask
,
onChangeCurrentTaskHandler
,
deleteTaskHandler
,
sendNewTaskHandler
,
createTaskInCellHandler
,
copyTask
,
setCopyTask
,
createCopyTask
})
{
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,
});
const
handleOpen
=
useCallback
((
e
)
=>
{
setModal
({
...
...
@@ -79,6 +79,9 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
handleOpen
=
{
handleOpen
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
modal
=
{
modal
.
open
}
copyTask
=
{
copyTask
}
setCopyTask
=
{
setCopyTask
}
createCopyTask
=
{
createCopyTask
}
/
>
)
})}
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
d2e218f1
import
{
useEffect
,
useCallback
,
useState
,
useMemo
}
from
'react'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
{
useNavigate
}
from
'react-router-dom'
;
import
CalendarModalWorkerContent
from
'../../components/Calendars/CalendarModalWorkerContent/CalendarModalWorkerContent'
;
import
MonthCalendarBody
from
'../../components/Calendars/MonthCalendar/MonthCalendarBody/MonthCalendarBody'
;
import
MonthCalendarHeader
from
'../../components/Calendars/MonthCalendar/MonthCalendarHeader/MonthCalendarHeader'
;
...
...
@@ -245,9 +244,9 @@ function MonthCalendar() {
const
onChangeCalendarUser
=
useCallback
(()
=>
{
setModal
(
false
)
dispatch
(
setUserCalendarId
(
workerInfo
.
worker
.
user
.
id
)
)
setUserCalendarId
(
workerInfo
.
worker
.
user
.
id
)
setWorkerInfo
({
project
:
''
,
worker
:
''
})
},
[
dispatch
,
workerInfo
?.
worker
?.
user
?.
id
])
},
[
workerInfo
?.
worker
?.
user
?.
id
])
return
(
<>
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
View file @
d2e218f1
...
...
@@ -4,12 +4,13 @@ import { useDispatch, useSelector } from 'react-redux';
import
WeekCalendarBody
from
'../../components/Calendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody'
;
import
WeekCalendarHeader
from
'../../components/Calendars/WeekCalendar/WeekCalendarHeader/WeekCalendarHeader'
;
import
{
getWeekInfoString
,
getWeekFromCurrentDate
,
dateToISOLikeButLocal
}
from
'../../helpers/CalendarHelpers'
;
import
{
addCalendarTask
,
deleteCalendarTask
,
editCalendarTask
,
fetchCalendarTasks
}
from
'../../store/actions/tasksActions'
;
import
{
addCalendarTask
,
addCopyCalendarTask
,
deleteCalendarTask
,
editCalendarTask
,
fetchCalendarTasks
}
from
'../../store/actions/tasksActions'
;
function
WeekCalendar
()
{
const
dispatch
=
useDispatch
();
const
{
calendarTasks
}
=
useSelector
(
state
=>
state
.
tasks
);
const
[
copyTask
,
setCopyTask
]
=
useState
(
null
)
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
const
[
dateNow
,
setDateNow
]
=
useState
({
year
:
''
,
month
:
''
,
currentDay
:
''
})
const
[
currentTask
,
setCurrentTask
]
=
useState
({
title
:
''
,
description
:
''
,
priority
:
null
,
infoForCell
:
{
startHour
:
null
,
endHour
:
null
}
})
...
...
@@ -77,7 +78,7 @@ function WeekCalendar() {
}
},
[]);
const
createTaskInCellHandler
=
useCallback
((
dayNumber
,
dayHour
)
=>
{
const
createTaskInCellHandler
=
useCallback
((
dayNumber
,
dayHour
,
month
)
=>
{
let
hour
if
(
!
isNaN
(
dayHour
))
{
hour
=
dayHour
...
...
@@ -94,23 +95,25 @@ function WeekCalendar() {
title
:
"Задача"
,
description
:
"описание"
,
priority
:
null
,
dateTimeStart
:
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
,
0
)),
dateTimeDue
:
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hourDue
,
59
)),
dateTimeStart
:
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
hour
,
0
)),
dateTimeDue
:
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
hourDue
,
59
)),
infoForCell
:
{
startHour
:
hour
,
endHour
:
hourDue
,
startDay
:
dayNumber
startDay
:
dayNumber
,
month
:
month
}
}
setCurrentTask
((
newTask
))
},[
dateNow
.
month
,
dateNow
.
year
,
hourFormat
])
},
[
dateNow
.
month
,
dateNow
.
year
,
hourFormat
])
const
sendNewTaskHandler
=
useCallback
(
async
()
=>
{
const
timeEndHour
=
currentTask
.
infoForCell
.
endHour
const
timeStartHour
=
currentTask
.
infoForCell
.
startHour
const
month
=
currentTask
.
infoForCell
.
month
const
day
=
currentTask
.
infoForCell
.
startDay
const
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
day
,
timeEndHour
-
1
,
59
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
day
,
timeStartHour
,
0
))
const
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
day
,
timeEndHour
-
1
,
59
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
day
,
timeStartHour
,
0
))
if
(
currentTask
.
id
)
{
const
newTask
=
{
...
currentTask
,
...
...
@@ -135,6 +138,28 @@ function WeekCalendar() {
}
},
[
currentTask
,
dateNow
.
month
,
dateNow
.
year
,
dispatch
,
user
.
id
,
userId
])
const
createCopyTask
=
useCallback
(
async
(
dayNumber
,
hour
,
month
)
=>
{
const
hourDiff
=
copyTask
.
infoForCell
.
endHour
-
copyTask
.
infoForCell
.
startHour
const
lastHour
=
hoursInDay
[
hoursInDay
.
length
-
1
].
split
(
':'
)[
0
]
let
due
if
(
hour
+
hourDiff
>=
lastHour
)
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
lastHour
,
59
))
}
else
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
hour
+
hourDiff
,
59
))
}
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
month
,
dayNumber
,
hour
,
0
))
const
newTask
=
{
...
copyTask
,
dateTimeStart
:
start
,
dateTimeDue
:
due
,
taskId
:
copyTask
.
mainTaskId
}
delete
newTask
.
infoForCell
delete
newTask
.
id
await
dispatch
(
addCopyCalendarTask
(
newTask
,
userId
))
setCopyTask
(
null
)
},
[
copyTask
,
dateNow
.
month
,
dateNow
.
year
,
dispatch
,
hoursInDay
,
userId
])
const
deleteTaskHandler
=
useCallback
(
async
(
taskId
)
=>
{
dispatch
(
deleteCalendarTask
(
taskId
,
userId
))
},[
dispatch
,
userId
])
...
...
@@ -159,6 +184,9 @@ function WeekCalendar() {
setHourFormat
=
{
setHourFormat
}
hoursInDay
=
{
hoursInDay
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
createCopyTask
=
{
createCopyTask
}
copyTask
=
{
copyTask
}
setCopyTask
=
{
setCopyTask
}
/
>
<
/
>
);
...
...
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