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
6b4eb850
Commit
6b4eb850
authored
Dec 17, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#111
Чуть исправил логику, реализовал создание задачи
parent
989e9d5d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
104 additions
and
32 deletions
+104
-32
CalendarStandartCell.js
...ts/Calendars/CalendarStandartCell/CalendarStandartCell.js
+7
-2
DefaultTask.js
...front/src/components/Calendars/DefaultTask/DefaultTask.js
+17
-3
EmptyBox.js
...dar/MonthCalendarBody/CalendarRowDay/EmptyBox/EmptyBox.js
+1
-1
CalendarColumnDayWeek.js
...lendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
+31
-14
CalendarWeekTask.js
...alendarColumnDayWeek/CalendarWeekTask/CalendarWeekTask.js
+16
-10
WeekCalendarBody.js
...lendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
+3
-2
WeekCalendar.js
planner-front/src/containers/WeekCalendar/WeekCalendar.js
+29
-0
No files found.
planner-front/src/components/Calendars/CalendarStandartCell/CalendarStandartCell.js
View file @
6b4eb850
import
{
Grid
}
from
"@mui/material"
;
import
{
Grid
}
from
"@mui/material"
;
import
{
memo
,
useEffect
,
useState
}
from
"react"
;
import
{
memo
,
useEffect
,
useState
}
from
"react"
;
import
DefaultTask
from
"../
MonthCalendar/MonthCalendarBody/
DefaultTask/DefaultTask"
;
import
DefaultTask
from
"../DefaultTask/DefaultTask"
;
...
@@ -36,6 +36,11 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
...
@@ -36,6 +36,11 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
setIsThisCell
(
true
);
setIsThisCell
(
true
);
handleOpen
(
e
)
handleOpen
(
e
)
}
}
if
(
week
)
{
createTaskInCellHandler
(
dayNumber
,
hours
);
setIsThisCell
(
true
);
handleOpen
(
e
)
}
}
}
return
<>
return
<>
...
@@ -48,7 +53,7 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
...
@@ -48,7 +53,7 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
>
>
{
children
}
{
children
}
{
isThisCell
?
{
isThisCell
?
<
DefaultTask
/>
:
null
}
<
DefaultTask
week
=
{
week
}
/> : null
}
<
/Grid
>
<
/Grid
>
<
/
>
<
/
>
...
...
planner-front/src/components/Calendars/
MonthCalendar/MonthCalendarBody/
DefaultTask/DefaultTask.js
→
planner-front/src/components/Calendars/DefaultTask/DefaultTask.js
View file @
6b4eb850
import
{
Box
}
from
"@mui/material"
;
import
{
Box
}
from
"@mui/material"
;
import
{
memo
}
from
"react"
;
import
{
memo
}
from
"react"
;
const
DefaultTaskStyles
=
{
const
Month
DefaultTaskStyles
=
{
position
:
'relative'
,
position
:
'relative'
,
height
:
'30px'
,
height
:
'30px'
,
backgroundColor
:
'lightgreen'
,
backgroundColor
:
'lightgreen'
,
...
@@ -16,12 +16,26 @@ const DefaultTaskStyles = {
...
@@ -16,12 +16,26 @@ const DefaultTaskStyles = {
paddingLeft
:
'5px'
,
paddingLeft
:
'5px'
,
zIndex
:
'5'
zIndex
:
'5'
}
}
const
WeekDefaultTaskStyles
=
{
boxSizing
:
'border-box'
,
padding
:
'0 5px'
,
borderRadius
:
'2px'
,
border
:
'1px solid white'
,
backgroundColor
:
'lightgreen'
,
height
:
`100%`
,
width
:
`100%`
,
zIndex
:
5
,
textAlign
:
'left'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
}
const
DefaultTask
=
({
})
=>
{
const
DefaultTask
=
({
week
})
=>
{
return
(
<>
return
(
<>
<
Box
<
Box
sx
=
{
DefaultTaskStyles
}
sx
=
{
week
?
WeekDefaultTaskStyles
:
Month
DefaultTaskStyles
}
>
>
<
span
>
<
span
>
Задача
Задача
...
...
planner-front/src/components/Calendars/MonthCalendar/MonthCalendarBody/CalendarRowDay/EmptyBox/EmptyBox.js
View file @
6b4eb850
import
{
Grid
}
from
"@mui/material"
;
import
{
Grid
}
from
"@mui/material"
;
import
React
,
{
memo
,
useEffect
,
useState
}
from
"react"
;
import
React
,
{
memo
,
useEffect
,
useState
}
from
"react"
;
import
DefaultTask
from
"../../DefaultTask/DefaultTask"
;
import
DefaultTask
from
"../../
../../
DefaultTask/DefaultTask"
;
const
EmptyBox
=
({
hourNumber
,
handleOpen
,
dayNumber
,
xs
,
dragTaskHandler
,
modal
,
createTaskInCellHandler
,
copyTask
,
createCopyTask
})
=>
{
const
EmptyBox
=
({
hourNumber
,
handleOpen
,
dayNumber
,
xs
,
dragTaskHandler
,
modal
,
createTaskInCellHandler
,
copyTask
,
createCopyTask
})
=>
{
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarColumnDayWeek.js
View file @
6b4eb850
...
@@ -7,7 +7,7 @@ import CalendarWeekTask from "./CalendarWeekTask/CalendarWeekTask";
...
@@ -7,7 +7,7 @@ import CalendarWeekTask from "./CalendarWeekTask/CalendarWeekTask";
function
CalendarColumnDayWeek
({
hoursInDay
,
tasks
,
month
,
year
,
day
,
hourFormat
,
handleOpen
,
setCurrentTask
})
{
function
CalendarColumnDayWeek
({
hoursInDay
,
tasks
,
month
,
year
,
day
,
hourFormat
,
handleOpen
,
setCurrentTask
,
copyTask
,
createCopyTask
,
createTaskInCellHandler
,
modal
})
{
const
[
columnDayHeight
,
setColumnDayHeight
]
=
useState
(
0
)
const
[
columnDayHeight
,
setColumnDayHeight
]
=
useState
(
0
)
const
dayColumnRef
=
useRef
(
''
)
const
dayColumnRef
=
useRef
(
''
)
...
@@ -34,7 +34,6 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -34,7 +34,6 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
const
getBoxesInLine
=
(
line
,
hoursInDay
,
sortedTasks
,
linesInDay
)
=>
{
const
getBoxesInLine
=
(
line
,
hoursInDay
,
sortedTasks
,
linesInDay
)
=>
{
if
(
line
)
{
if
(
line
)
{
let
xs
=
12
/
hoursInDay
.
length
const
boxes
=
[]
const
boxes
=
[]
for
(
let
i
=
0
;
i
<
line
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
line
.
length
;
i
++
)
{
if
(
!
isNaN
(
line
[
i
]))
{
if
(
!
isNaN
(
line
[
i
]))
{
...
@@ -48,6 +47,15 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -48,6 +47,15 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
if
(
taskIsThere
)
{
if
(
taskIsThere
)
{
taskIsThere
.
lastHour
=
i
taskIsThere
.
lastHour
=
i
taskIsThere
.
height
+=
step
taskIsThere
.
height
+=
step
let
tasksInHour
=
0
for
(
let
line
of
linesInDay
)
{
if
(
isNaN
(
line
[
i
]))
{
tasksInHour
++
}
}
if
(
tasksInHour
>
taskIsThere
.
tasksInHour
)
{
taskIsThere
.
tasksInHour
=
tasksInHour
}
}
else
{
}
else
{
let
tasksInHour
=
0
let
tasksInHour
=
0
for
(
let
line
of
linesInDay
)
{
for
(
let
line
of
linesInDay
)
{
...
@@ -70,18 +78,18 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -70,18 +78,18 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
}
}
}
}
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
)
=>
{
const
boxes
=
getBoxesInLine
(
line
,
hoursInDay
,
sortedTasks
,
linesInDay
)
const
boxes
=
getBoxesInLine
(
line
,
hoursInDay
,
sortedTasks
,
linesInDay
)
return
(
<>
return
(
<>
{
boxes
.
map
((
task
,
index
)
=>
{
{
boxes
.
map
((
task
,
index
)
=>
{
const
amount
=
task
.
tasksInHour
const
amount
=
task
.
tasksInHour
const
oneTaskPrecentWidth
=
100
/
amount
const
oneTaskPrecentWidth
=
100
/
amount
const
left
=
oneTaskPrecentWidth
*
dayColumnRef
.
current
.
offsetWidth
/
100
*
i
const
left
=
oneTaskPrecentWidth
*
dayColumnRef
.
current
.
offsetWidth
/
100
*
i
const
oneTaskWidth
=
dayColumnRef
.
current
.
offsetWidth
-
(
oneTaskPrecentWidth
*
dayColumnRef
.
current
.
offsetWidth
/
100
)
*
i
const
zIndex
=
10
+
i
const
zIndex
=
10
+
i
const
oneTaskWidth
=
dayColumnRef
.
current
.
offsetWidth
-
(
oneTaskPrecentWidth
*
dayColumnRef
.
current
.
offsetWidth
/
100
)
*
i
return
(
return
(
<
CalendarWeekTask
<
CalendarWeekTask
key
=
{
index
}
key
=
{
index
}
...
@@ -93,6 +101,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -93,6 +101,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
zIndex
=
{
zIndex
}
zIndex
=
{
zIndex
}
handleOpen
=
{
handleOpen
}
handleOpen
=
{
handleOpen
}
setCurrentTask
=
{
setCurrentTask
}
setCurrentTask
=
{
setCurrentTask
}
modal
=
{
modal
}
>
>
<
/CalendarWeekTask
>
<
/CalendarWeekTask
>
...
@@ -105,7 +114,15 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
...
@@ -105,7 +114,15 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
})}
})}
{
hoursInDay
?.
map
((
hour
,
i
)
=>
{
{
hoursInDay
?.
map
((
hour
,
i
)
=>
{
return
(
return
(
<
CalendarStandartCell
key
=
{
i
}
week
=
{
true
}
>
<
CalendarStandartCell
key
=
{
i
}
week
=
{
true
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
handleOpen
=
{
handleOpen
}
dayNumber
=
{
day
}
hours
=
{
hour
}
modal
=
{
modal
}
>
<
/CalendarStandartCell
>
<
/CalendarStandartCell
>
)
)
})}
})}
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/CalendarColumnDayWeek/CalendarWeekTask/CalendarWeekTask.js
View file @
6b4eb850
...
@@ -2,8 +2,8 @@ import { Box } from "@mui/material"
...
@@ -2,8 +2,8 @@ import { Box } from "@mui/material"
import
{
useEffect
,
useState
}
from
"react"
import
{
useEffect
,
useState
}
from
"react"
function
CalendarWeekTask
({
height
,
width
,
left
,
top
,
task
,
zIndex
,
handleOpen
,
setCurrentTask
})
{
function
CalendarWeekTask
({
height
,
width
,
left
,
top
,
task
,
zIndex
,
handleOpen
,
setCurrentTask
,
modal
})
{
const
[
zIndexStyle
,
setZIndexStyle
]
=
useState
(
10
)
const
[
color
,
setColor
]
=
useState
(
''
)
const
[
color
,
setColor
]
=
useState
(
''
)
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
task
.
priority
)
{
if
(
task
.
priority
)
{
...
@@ -13,8 +13,15 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
...
@@ -13,8 +13,15 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
}
else
{
}
else
{
setColor
(
'rgb(171, 157, 157);'
)
setColor
(
'rgb(171, 157, 157);'
)
}
}
setZIndexStyle
(
zIndex
)
},
[
task
])
},
[
task
])
useEffect
(()
=>
{
if
(
!
modal
)
{
setZIndexStyle
(
zIndex
)
}
},
[
modal
])
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
e
.
stopPropagation
();
e
.
stopPropagation
();
setCurrentTask
((
prevState
)
=>
{
setCurrentTask
((
prevState
)
=>
{
...
@@ -26,19 +33,21 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
...
@@ -26,19 +33,21 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
}
}
}
}
});
});
setZIndexStyle
(
100
)
handleOpen
(
e
)
handleOpen
(
e
)
}
}
const
styles
=
{
const
styles
=
{
borderRadius
:
'5px'
,
boxSizing
:
'border-box'
,
borderRadius
:
'3px'
,
border
:
'1px solid white'
,
border
:
'1px solid white'
,
backgroundColor
:
color
,
backgroundColor
:
color
,
height
:
`
${
height
}
px`
,
height
:
`
${
height
-
1
}
px`
,
width
:
`
${
width
}
px`
,
width
:
`
${
width
-
1
}
px`
,
position
:
'absolute'
,
position
:
'absolute'
,
left
:
`
${
left
}
px`
,
left
:
left
,
top
:
top
,
top
:
top
,
zIndex
:
zIndex
,
zIndex
:
zIndex
Style
,
textAlign
:
'left'
,
textAlign
:
'left'
,
overflow
:
'hidden'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
textOverflow
:
'ellipsis'
,
...
@@ -46,9 +55,6 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
...
@@ -46,9 +55,6 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
cursor
:
'pointer'
,
cursor
:
'pointer'
,
boxShadow
:
'inset 0 0 100px 100px rgba(255, 255, 255, 0.3)'
boxShadow
:
'inset 0 0 100px 100px rgba(255, 255, 255, 0.3)'
},
},
"&:active"
:
{
zIndex
:
100
}
}
}
return
(
return
(
...
...
planner-front/src/components/Calendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
View file @
6b4eb850
...
@@ -9,7 +9,7 @@ import CalendarStandartCell from "../../CalendarStandartCell/CalendarStandartCel
...
@@ -9,7 +9,7 @@ import CalendarStandartCell from "../../CalendarStandartCell/CalendarStandartCel
import
CalendarColumnDayWeek
from
"./CalendarColumnDayWeek/CalendarColumnDayWeek"
;
import
CalendarColumnDayWeek
from
"./CalendarColumnDayWeek/CalendarColumnDayWeek"
;
import
{
getCurrentWeekDayString
}
from
"./Helpers"
;
import
{
getCurrentWeekDayString
}
from
"./Helpers"
;
function
WeekCalendarBody
({
week
,
hoursInDay
,
hourFormat
,
setHourFormat
,
date
,
tasks
,
currentTask
,
setCurrentTask
,
onChangeCurrentTaskHandler
,
deleteTaskHandler
,
sendNewTaskHandler
})
{
function
WeekCalendarBody
({
week
,
hoursInDay
,
hourFormat
,
setHourFormat
,
date
,
tasks
,
currentTask
,
setCurrentTask
,
onChangeCurrentTaskHandler
,
deleteTaskHandler
,
sendNewTaskHandler
,
createTaskInCellHandler
})
{
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,
});
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,
});
const
handleOpen
=
(
e
)
=>
{
const
handleOpen
=
(
e
)
=>
{
setModal
({
setModal
({
...
@@ -28,7 +28,6 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
...
@@ -28,7 +28,6 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
setCurrentTask
({})
setCurrentTask
({})
};
};
return
(
return
(
<>
<>
<
Box
style
=
{{
marginBottom
:
'30px'
}}
>
<
Box
style
=
{{
marginBottom
:
'30px'
}}
>
...
@@ -78,6 +77,8 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
...
@@ -78,6 +77,8 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
hourFormat
=
{
hourFormat
}
hourFormat
=
{
hourFormat
}
setCurrentTask
=
{
setCurrentTask
}
setCurrentTask
=
{
setCurrentTask
}
handleOpen
=
{
handleOpen
}
handleOpen
=
{
handleOpen
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
modal
=
{
modal
.
open
}
/
>
/
>
)
)
})}
})}
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
View file @
6b4eb850
...
@@ -79,6 +79,34 @@ function WeekCalendar() {
...
@@ -79,6 +79,34 @@ function WeekCalendar() {
}
}
},
[]);
},
[]);
const
createTaskInCellHandler
=
(
dayNumber
,
dayHour
)
=>
{
let
hour
if
(
!
isNaN
(
dayHour
))
{
hour
=
dayHour
}
else
{
hour
=
parseInt
(
dayHour
.
split
(
':'
)[
0
])
}
let
hourDue
if
(
hourFormat
)
{
hourDue
=
hour
+
1
}
else
{
hourDue
=
hour
+
2
}
const
newTask
=
{
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
)),
infoForCell
:
{
startHour
:
hour
,
endHour
:
hourDue
,
startDay
:
dayNumber
}
}
setCurrentTask
((
newTask
))
}
const
sendNewTaskHandler
=
async
()
=>
{
const
sendNewTaskHandler
=
async
()
=>
{
const
timeEndHour
=
currentTask
.
infoForCell
.
endHour
const
timeEndHour
=
currentTask
.
infoForCell
.
endHour
const
timeStartHour
=
currentTask
.
infoForCell
.
startHour
const
timeStartHour
=
currentTask
.
infoForCell
.
startHour
...
@@ -132,6 +160,7 @@ function WeekCalendar() {
...
@@ -132,6 +160,7 @@ function WeekCalendar() {
hourFormat
=
{
hourFormat
}
hourFormat
=
{
hourFormat
}
setHourFormat
=
{
setHourFormat
}
setHourFormat
=
{
setHourFormat
}
hoursInDay
=
{
hoursInDay
}
hoursInDay
=
{
hoursInDay
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
/
>
/
>
<
/
>
<
/
>
);
);
...
...
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