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
896a638c
Commit
896a638c
authored
Nov 07, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#28
Разделил части таблицы на разные компоненты
parent
cce9a6c8
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
121 additions
and
63 deletions
+121
-63
CalendarRow.js
...c/components/MonthCalendarBody/CalendarRow/CalendarRow.js
+17
-0
CalendarSmallCell.js
.../MonthCalendarBody/CalendarSmallCell/CalendarSmallCell.js
+11
-0
CalendarStandartCell.js
...endarBody/CalendarStandartCell.js/CalendarStandartCell.js
+14
-0
CalendarTask.js
...components/MonthCalendarBody/CalendarTask/CalendarTask.js
+39
-0
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+39
-58
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+1
-2
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+0
-3
No files found.
planner-front/src/components/MonthCalendarBody/CalendarRow/CalendarRow.js
0 → 100644
View file @
896a638c
import
{
Grid
}
from
"@mui/material"
;
const
CalendarRow
=
({
children
})
=>
{
return
<>
<
Grid
container
align
=
'center'
sx
=
{{
borderBottom
:
'1px solid black'
,
borderRight
:
'1px solid black'
,
borderLeft
:
'1px solid black'
}}
>
{
children
}
<
/Grid
>
<
/
>
};
export
default
CalendarRow
;
planner-front/src/components/MonthCalendarBody/CalendarSmallCell/CalendarSmallCell.js
0 → 100644
View file @
896a638c
import
{
Grid
}
from
"@mui/material"
;
const
CalendarSmallCell
=
({
children
,
xs
})
=>
{
return
<>
<
Grid
align
=
'center'
item
xs
=
{
xs
}
sx
=
{{
borderRight
:
'1px solid black'
}}
>
{
children
}
<
/Grid
>
<
/
>
};
export
default
CalendarSmallCell
;
\ No newline at end of file
planner-front/src/components/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell.js
0 → 100644
View file @
896a638c
import
{
Grid
}
from
"@mui/material"
;
const
CalendarStandartCell
=
({
children
,
xs
,
onClick
})
=>
{
return
<>
<
Grid
item
xs
=
{
xs
}
sx
=
{{
borderRight
:
'1px solid black'
}}
onClick
=
{
onClick
}
>
{
children
}
<
/Grid
>
<
/
>
};
export
default
CalendarStandartCell
;
\ No newline at end of file
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.js
0 → 100644
View file @
896a638c
import
{
Grid
,
TextField
}
from
"@mui/material"
;
import
{
useEffect
,
useState
}
from
"react"
;
const
CalendarTask
=
({
year
,
month
,
tasks
,
day
,
hours
,
setCurrentTask
,
onChange
})
=>
{
const
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
const
task
=
tasks
.
find
(
task
=>
{
if
(
year
===
task
.
infoForCell
.
startYear
)
{
if
(
month
+
1
===
task
.
infoForCell
.
startMonth
)
{
if
(
day
.
dayNumber
===
task
.
infoForCell
.
startDay
)
{
if
((
task
.
infoForCell
.
endHour
<=
parseInt
(
hours
.
split
(
':'
)[
0
])
||
task
.
infoForCell
.
startHour
<=
parseInt
(
hours
.
split
(
':'
)[
0
]))
&&
(
task
.
infoForCell
.
endHour
>
parseInt
(
hours
.
split
(
':'
)[
0
])))
{
return
task
}
}
}
}
})
return
task
}
let
task
=
getTaskInDayCell
(
tasks
,
day
,
hours
)
return
(
<>
{
task
?
<
Grid
sx
=
{{
backgroundColor
:
'lightgreen'
}}
>
<
TextField
id
=
{
task
.
title
}
variant
=
"standard"
value
=
{
task
.
title
}
name
=
'title'
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCurrentTask
(
task
)}}
onChange
=
{
onChange
}
>
<
/TextField
>
<
/Grid
>
:
null
}
<
/>
)
};
export
default
CalendarTask
;
\ No newline at end of file
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
896a638c
import
{
Grid
,
TextField
}
from
"@mui/material"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
CalendarRow
from
"./CalendarRow/CalendarRow"
;
import
CalendarSmallCell
from
"./CalendarSmallCell/CalendarSmallCell"
;
import
CalendarStandartCell
from
"./CalendarStandartCell.js/CalendarStandartCell"
;
import
CalendarTask
from
"./CalendarTask/CalendarTask"
;
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
onChangeCellTaskTitle
,
setCurrentTask
})
{
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
onChangeCellTaskTitle
,
setCurrentTask
})
{
const
[
hoursInDay
,
setHoursInDay
]
=
useState
([
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
,
'6:00'
])
const
[
hoursInDay
,
setHoursInDay
]
=
useState
([
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
,
'6:00'
])
const
[
daysInMonth
,
setDaysInMonth
]
=
useState
([])
const
[
daysInMonth
,
setDaysInMonth
]
=
useState
([])
const
[
cellSizes
,
setCellSizes
]
=
useState
({})
useEffect
(()
=>
{
const
cells
=
hoursInDay
.
length
const
xs
=
11
/
cells
setCellSizes
(()
=>
{
return
{
smallCell
:
0.5
,
standarCell
:
xs
}
})
},
[])
useEffect
(()
=>
{
useEffect
(()
=>
{
setNewMonthDays
()
setNewMonthDays
()
},
[
month
,
year
])
},
[
month
])
const
getDaysInMonth
=
()
=>
{
const
getDaysInMonth
=
()
=>
{
return
new
Date
(
year
,
month
+
1
,
0
).
getDate
();
return
new
Date
(
year
,
month
+
1
,
0
).
getDate
();
...
@@ -28,81 +40,50 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang
...
@@ -28,81 +40,50 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang
const
dayOfWeekNumber
=
getDayOfWeekNumber
(
i
)
const
dayOfWeekNumber
=
getDayOfWeekNumber
(
i
)
newDaysInMonth
.
push
({
dayNumber
:
i
,
dayOfWeek
:
getDayOfWeekString
(
dayOfWeekNumber
)})
newDaysInMonth
.
push
({
dayNumber
:
i
,
dayOfWeek
:
getDayOfWeekString
(
dayOfWeekNumber
)})
}
}
setDaysInMonth
(
newDaysInMonth
)
setDaysInMonth
(
prevState
=>
newDaysInMonth
)
}
const
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
const
task
=
tasks
.
find
(
task
=>
{
if
(
year
===
task
.
infoForCell
.
startYear
)
{
if
(
month
+
1
===
task
.
infoForCell
.
startMonth
)
{
if
(
day
.
dayNumber
===
task
.
infoForCell
.
startDay
&&
task
.
infoForCell
.
startDayOfWeek
===
day
.
dayOfWeek
)
{
if
((
task
.
infoForCell
.
endHour
<=
parseInt
(
hours
.
split
(
':'
)[
0
])
||
task
.
infoForCell
.
startHour
<=
parseInt
(
hours
.
split
(
':'
)[
0
]))
&&
(
task
.
infoForCell
.
endHour
>
parseInt
(
hours
.
split
(
':'
)[
0
])))
{
return
task
}
}
}
}
})
return
task
}
}
return
(
return
(
<>
<>
<
Grid
<
CalendarRow
container
align
=
'center'
sx
=
{{
borderBottom
:
'1px solid black'
,
borderRight
:
'1px solid black'
,
borderLeft
:
'1px solid black'
}}
>
>
<
Grid
align
=
'center'
item
xs
=
{
0.5
}
sx
=
{{
borderRight
:
'1px solid black'
}}
>
<
CalendarSmallCell
xs
=
{
cellSizes
.
smallCell
}
/
>
{
' '
}
<
CalendarSmallCell
xs
=
{
cellSizes
.
smallCell
}
/
>
<
/Grid
>
<
Grid
align
=
'center'
item
xs
=
{
0.5
}
sx
=
{{
borderRight
:
'1px solid black'
}}
>
{
' '
}
<
/Grid
>
{
hoursInDay
.
map
((
hours
,
i
)
=>
{
{
hoursInDay
.
map
((
hours
,
i
)
=>
{
return
(
return
(
<
Grid
key
=
{
i
}
item
xs
=
{
1.2222
}
sx
=
{{
borderRight
:
'1px solid black'
}
}
>
<
CalendarStandartCell
key
=
{
i
}
xs
=
{
cellSizes
.
standarCell
}
>
{
hours
}
{
hours
}
<
/
Grid
>
<
/
CalendarStandartCell
>
)
)
})}
})}
<
/
Grid
>
<
/
CalendarRow
>
{
daysInMonth
.
map
((
day
,
i
)
=>
{
{
daysInMonth
.
map
((
day
,
i
)
=>
{
return
(
return
(
<
Grid
<
CalendarRow
key
=
{
i
}
key
=
{
i
}
container
align
=
'center'
sx
=
{{
borderBottom
:
'1px solid black'
,
borderRight
:
'1px solid black'
,
borderLeft
:
'1px solid black'
}}
>
>
<
Grid
align
=
'center'
item
xs
=
{
0.5
}
sx
=
{{
borderRight
:
'1px solid black'
}}
>
<
CalendarSmallCell
xs
=
{
cellSizes
.
smallCell
}
>
{
day
.
dayNumber
}
<
/CalendarSmallCell
>
{
day
.
dayNumber
}
<
CalendarSmallCell
xs
=
{
cellSizes
.
smallCell
}
>
{
day
.
dayOfWeek
}
<
/CalendarSmallCell
>
<
/Grid
>
<
Grid
align
=
'center'
item
xs
=
{
0.5
}
sx
=
{{
borderRight
:
'1px solid black'
}}
>
{
day
.
dayOfWeek
}
<
/Grid
>
{
hoursInDay
.
map
((
hours
,
i
)
=>
{
{
hoursInDay
.
map
((
hours
,
i
)
=>
{
const
task
=
getTaskInDayCell
(
tasks
,
day
,
hours
)
return
(
return
(
<
Grid
<
CalendarStandartCell
key
=
{
i
}
key
=
{
i
}
item
xs
=
{
1.2222
}
item
xs
=
{
cellSizes
.
standarCell
}
sx
=
{{
borderRight
:
'1px solid black'
}}
onClick
=
{()
=>
{
createTaskInCellHandler
(
day
.
dayNumber
,
hours
)}}
onClick
=
{()
=>
{
createTaskInCellHandler
(
day
.
dayNumber
,
hours
)}}
>
>
{
task
?
<
CalendarTask
<
Grid
key
=
{
i
}
sx
=
{{
backgroundColor
:
'lightgreen'
}}
>
setCurrentTask
=
{
setCurrentTask
}
<
TextField
onChange
=
{(
e
)
=>
{
onChangeCellTaskTitle
(
e
)}}
id
=
{
task
.
title
}
year
=
{
year
}
variant
=
"standard"
month
=
{
month
}
value
=
{
task
.
title
}
tasks
=
{
tasks
}
name
=
'title'
day
=
{
day
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCurrentTask
(
task
)}}
hours
=
{
hours
}
onChange
=
{(
e
)
=>
{
onChangeCellTaskTitle
(
e
)}}
><
/TextField
>
/
>
<
/Grid> : null
}
<
/CalendarStandartCell
>
<
/Grid
>
)
)
})}
})}
<
/
Grid
>
<
/
CalendarRow
>
)
)
})}
})}
<
/
>
<
/
>
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
896a638c
import
{
Container
}
from
'@mui/material'
;
import
{
Container
}
from
'@mui/material'
;
import
moment
from
'moment'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
MonthCalendarBody
from
'../../components/MonthCalendarBody/MonthCalendarBody'
;
import
MonthCalendarBody
from
'../../components/MonthCalendarBody/MonthCalendarBody'
;
...
@@ -76,7 +75,7 @@ function MonthCalendar() {
...
@@ -76,7 +75,7 @@ function MonthCalendar() {
const
name
=
e
.
target
.
name
;
const
name
=
e
.
target
.
name
;
setCurrentTask
({
...
currentTask
,
[
name
]:
value
})
setCurrentTask
({
...
currentTask
,
[
name
]:
value
})
}
}
console
.
log
(
tasks
)
return
(
return
(
<>
<>
<
Container
>
<
Container
>
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
896a638c
...
@@ -18,15 +18,12 @@ const tasksReduсer = (state = initialState, action) => {
...
@@ -18,15 +18,12 @@ const tasksReduсer = (state = initialState, action) => {
const
timeStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
1
]
const
timeStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
1
]
const
timeEnd
=
task
.
dateTimeDue
.
split
(
'T'
)[
1
]
const
timeEnd
=
task
.
dateTimeDue
.
split
(
'T'
)[
1
]
const
dayStart
=
parseInt
(
dateStart
.
split
(
'-'
)[
2
])
const
dayStart
=
parseInt
(
dateStart
.
split
(
'-'
)[
2
])
const
dayOfWeekStartNumber
=
new
Date
(
new
Date
().
getFullYear
(),
new
Date
().
getMonth
(),
dayStart
).
getDay
()
const
dayOfWeekStartString
=
[
"ВС"
,
"ПН"
,
"ВТ"
,
"СР"
,
"ЧТ"
,
"ПТ"
,
"СБ"
][
dayOfWeekStartNumber
]
const
monthStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
1
])
const
monthStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
1
])
const
yearStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
0
])
const
yearStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
0
])
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
const
timeEndHour
=
parseInt
(
timeEnd
.
split
(
':'
)[
0
])
const
timeEndHour
=
parseInt
(
timeEnd
.
split
(
':'
)[
0
])
newArr
.
push
({...
task
,
infoForCell
:
{
newArr
.
push
({...
task
,
infoForCell
:
{
startDay
:
dayStart
,
startDay
:
dayStart
,
startDayOfWeek
:
dayOfWeekStartString
,
startHour
:
timeStartHour
,
startHour
:
timeStartHour
,
startMonth
:
monthStartNumber
,
startMonth
:
monthStartNumber
,
startYear
:
yearStartNumber
,
startYear
:
yearStartNumber
,
...
...
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