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
d9d0fd66
Commit
d9d0fd66
authored
Nov 17, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#55
Реализовал полностью логику отображения
parent
0fc9b731
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
130 deletions
+43
-130
CalendarRowDay.js
...onents/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
+12
-20
CalendarStandartCell.js
...endarBody/CalendarStandartCell.js/CalendarStandartCell.js
+9
-4
CalendarTask.js
...components/MonthCalendarBody/CalendarTask/CalendarTask.js
+9
-101
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+13
-5
No files found.
planner-front/src/components/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
View file @
d9d0fd66
...
@@ -130,12 +130,6 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
...
@@ -130,12 +130,6 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
align
=
'center'
align
=
'center'
>
>
{
hoursInDay
.
map
((
hour
,
i
)
=>
{
{
hoursInDay
.
map
((
hour
,
i
)
=>
{
const
linesForCell
=
[]
if
(
linesInDay
?.
length
)
{
for
(
let
j
=
0
;
j
<
linesInDay
.
length
;
j
++
)
{
linesForCell
.
push
(
linesInDay
[
j
][
i
])
}
}
return
(
return
(
<
CalendarStandartCell
<
CalendarStandartCell
key
=
{
i
}
key
=
{
i
}
...
@@ -147,29 +141,27 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
...
@@ -147,29 +141,27 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
handleOpen
=
{
handleOpen
}
handleOpen
=
{
handleOpen
}
modal
=
{
modal
}
modal
=
{
modal
}
>
>
{
/* <CalendarTask
setCurrentTask={setCurrentTask}
hours={hour}
modal={modal}
hourFormat={hourFormat}
handleOpen={handleOpen}
currentTask={currentTask}
linesForCell={linesForCell.length ? linesForCell : null}
sortedTasks={sortedTasks}
/> */
}
<
/CalendarStandartCell
>
<
/CalendarStandartCell
>
)
)
})}
})}
{
linesInDay
?.
map
((
line
)
=>
{
{
linesInDay
?.
map
((
line
,
i
)
=>
{
const
boxes
=
getBoxesInLine
(
line
)
const
boxes
=
getBoxesInLine
(
line
)
return
(
return
(
<
Grid
container
sx
=
{{
backgroundColor
:
'grey'
,
height
:
'40px'
,
borderBottom
:
'1px solid red
'
}}
>
<
Grid
key
=
{
i
}
container
sx
=
{{
height
:
'35px'
,
backgroundColor
:
'rgb(0,0,0,0)'
,
marginTop
:
i
===
0
?
'-35px'
:
0
,
marginBottom
:
'5px
'
}}
>
{
boxes
.
map
((
box
)
=>
{
{
boxes
.
map
((
box
)
=>
{
if
(
box
.
task
)
{
if
(
box
.
task
)
{
return
(
<
Grid
item
xs
=
{
box
.
xs
}
sx
=
{{
backgroundColor
:
'green'
,
height
:
'40px'
}}
><
/Grid>
)
return
(
<
Grid
item
xs
=
{
box
.
xs
}
sx
=
{{
height
:
'35px'
,
marginBottom
:
'5px'
}}
>
<
CalendarTask
task
=
{
box
.
task
}
setCurrentTask
=
{
setCurrentTask
}
handleOpen
=
{
handleOpen
}
/
>
<
/Grid>
)
}
else
{
}
else
{
return
(
<
Grid
item
xs
=
{
box
.
xs
}
sx
=
{{
backgroundColor
:
'white'
,
height
:
'40px'
}}
><
/Grid>
)
return
(
<
Grid
item
xs
=
{
box
.
xs
}
sx
=
{{
height
:
'35px'
,
backgroundColor
:
'rgb(0,0,0,0)'
}}
>
<
/Grid>
)
}
}
})}
})}
<
/Grid>
)
<
/Grid>
)
...
...
planner-front/src/components/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell.js
View file @
d9d0fd66
import
{
Grid
}
from
"@mui/material"
;
import
{
Grid
}
from
"@mui/material"
;
import
{
memo
,
useEffect
,
useState
}
from
"react"
;
import
{
memo
,
useEffect
,
useState
}
from
"react"
;
const
CalendarStandartCell
=
({
children
,
xs
,
hours
,
dayNumber
,
createTaskInCellHandler
,
handleOpen
,
modal
})
=>
{
const
CalendarStandartCell
=
({
children
,
xs
,
hours
,
dayNumber
,
createTaskInCellHandler
,
handleOpen
,
modal
,
divRef
})
=>
{
const
[
isThisCell
,
setIsThisCell
]
=
useState
(
false
)
const
[
isThisCell
,
setIsThisCell
]
=
useState
(
false
)
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
modal
)
{
if
(
!
modal
)
{
setIsThisCell
(
false
);
setIsThisCell
(
false
);
}
}
},
[
modal
])
},
[
modal
])
return
<>
return
<>
<
Grid
<
Grid
item
xs
=
{
xs
}
item
xs
=
{
xs
}
sx
=
{{
borderRight
:
'1px solid black'
}}
sx
=
{{
position
:
'relative'
,
height
:
'35px'
}}
onClick
=
{(
e
)
=>
{
createTaskInCellHandler
(
dayNumber
,
hours
);
setIsThisCell
(
true
);
handleOpen
(
e
)}}
>
onClick
=
{(
e
)
=>
{
createTaskInCellHandler
(
dayNumber
,
hours
);
setIsThisCell
(
true
);
handleOpen
(
e
)}}
>
{
children
}
{
children
}
{
isThisCell
?
{
isThisCell
?
<
Grid
<
Grid
sx
=
{{
height
:
'30px'
,
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'5px'
,
margin
:
"5px 10px"
,
borderRadius
:
'10px'
}}
sx
=
{{
position
:
'relative'
,
height
:
'29px'
,
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
borderRadius
:
'10px'
,
margin
:
'3px 10px'
,
display
:
'flex'
,
justifyContent
:
'flex-start'
,
alignItems
:
'center'
,
paddingLeft
:
'5px'
,
zIndex
:
'5'
}}
>
>
<
span
>
<
span
>
Задача
Задача
<
/span
>
<
/span
>
<
/Grid> : null
}
<
/Grid> : null
}
<
div
style
=
{{
position
:
'absolute'
,
height
:
children
?
divRef
:
0
,
width
:
'1px'
,
backgroundColor
:
'black'
,
right
:
'0'
,
top
:
'0'
,
zIndex
:
'3'
}}
>
<
/div
>
<
/Grid
>
<
/Grid
>
<
/
>
<
/
>
};
};
...
...
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
d9d0fd66
...
@@ -2,65 +2,10 @@ import { Grid} from "@mui/material";
...
@@ -2,65 +2,10 @@ import { Grid} from "@mui/material";
import
React
,
{
memo
}
from
"react"
;
import
React
,
{
memo
}
from
"react"
;
const
TaskDefault
=
({
task
,
onClickTaskHandler
})
=>
{
return
(
<
Grid
sx
=
{{
height
:
'30px'
,
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'5px'
,
borderBottom
:
'1px solid rgb(29, 161, 51)'
,
borderRadius
:
'10px'
,
margin
:
'5px 10px'
,
textAlign
:
'left'
}}
onClick
=
{
onClickTaskHandler
}
>
<
span
>
{
task
.
title
}
<
/span
>
<
/Grid>
)
}
const
TaskWithNoStartAndAllEnd
=
({
task
,
onClickTaskHandler
})
=>
{
return
(
<
Grid
sx
=
{{
height
:
'30px'
,
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
padding
:
'5px'
,
borderBottom
:
'1px solid rgb(29, 161, 51)'
,
borderTopLeftRadius
:
'10px'
,
borderBottomLeftRadius
:
'10px'
,
margin
:
"5px -1px 5px 10px"
,
position
:
'relative'
,
textAlign
:
'left'
}}
onClick
=
{
onClickTaskHandler
}
>
<
span
>
{
task
.
title
}
<
/span
>
<
/Grid>
)
}
const
TaskWithAllStartAndNoEnd
=
({
onClickTaskHandler
})
=>
{
return
(
<
Grid
sx
=
{{
height
:
'30px'
,
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'5px'
,
borderBottom
:
'1px solid rgb(29, 161, 51)'
,
borderTopRightRadius
:
'10px'
,
borderBottomRightRadius
:
'10px'
,
margin
:
"5px 10px 5px -1px"
}}
onClick
=
{
onClickTaskHandler
}
>
<
span
>
&
#
8291
;
<
/span
>
<
/Grid>
)
}
const
TaskWithAllStartAndAllEnd
=
({
onClickTaskHandler
})
=>
{
return
(
<
Grid
sx
=
{{
height
:
'30px'
,
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'5px'
,
borderBottom
:
'1px solid rgb(29, 161, 51)'
,
margin
:
"5px -1px"
}}
onClick
=
{
onClickTaskHandler
}
>
<
span
>
&
#
8291
;
<
/span
>
<
/Grid>
)
}
const
Empty
=
()
=>
{
return
(
<
Grid
sx
=
{{
height
:
'30px'
,
backgroundColor
:
'rgb(0,0,0,0)'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'5px'
,
margin
:
"5px -1px"
}}
>
<
span
>
&
#
8291
;
<
/span
>
<
/Grid>
)
}
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
})
=>
{
const
CalendarTask
=
({
hours
,
setCurrentTask
,
hourFormat
,
handleOpen
,
currentTask
,
linesForCell
,
sortedTasks
})
=>
{
const
hour
=
parseInt
(
hours
.
split
(
':'
)[
0
])
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
e
.
stopPropagation
();
e
.
stopPropagation
();
setCurrentTask
(
task
);
setCurrentTask
(
task
);
...
@@ -68,51 +13,14 @@ const CalendarTask = ({hours, setCurrentTask, hourFormat, handleOpen, currentTas
...
@@ -68,51 +13,14 @@ const CalendarTask = ({hours, setCurrentTask, hourFormat, handleOpen, currentTas
}
}
return
(
<>
return
(
<>
{
linesForCell
?.
length
?
linesForCell
.
map
((
line
,
i
)
=>
<
Grid
{
sx
=
{{
position
:
'relative'
,
height
:
'30px'
,
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
borderRadius
:
'10px'
,
margin
:
'5px 10px'
,
display
:
'flex'
,
justifyContent
:
'flex-start'
,
alignItems
:
'center'
,
paddingLeft
:
'5px'
,
zIndex
:
'5'
}}
if
(
isNaN
(
line
))
{
onClick
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
const
task
=
sortedTasks
[
line
.
split
(
'-'
)[
1
]]
>
if
((
hourFormat
&&
task
.
infoForCell
.
endHour
>
hour
&&
task
.
infoForCell
.
startHour
===
hour
)
<
span
>
||
(
!
hourFormat
&&
(
task
.
infoForCell
.
endHour
-
1
>
hour
)
{
task
.
title
}
&&
(
task
.
infoForCell
.
startHour
===
hour
||
task
.
infoForCell
.
startHour
===
hour
+
1
)))
{
<
/span
>
return
(
<
TaskWithNoStartAndAllEnd
<
/Grid
>
key
=
{
task
.
id
}
task
=
{
task
}
onClickTaskHandler
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
/>
)
}
if
((
hourFormat
&&
task
.
infoForCell
.
startHour
<
hour
&&
task
.
infoForCell
.
endHour
>
hour
)
||
(
!
hourFormat
&&
task
.
infoForCell
.
startHour
<
hour
&&
task
.
infoForCell
.
endHour
>
hour
+
1
))
{
return
(
<
TaskWithAllStartAndAllEnd
key
=
{
task
.
id
}
onClickTaskHandler
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
/>
)
}
if
(
task
.
infoForCell
.
endMinute
===
59
&&
task
.
infoForCell
.
startHour
<
hour
)
{
return
(
<
TaskWithAllStartAndNoEnd
key
=
{
task
.
id
}
onClickTaskHandler
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
/>
)
}
return
(
<
TaskDefault
key
=
{
task
.
id
}
task
=
{
task
}
onClickTaskHandler
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
/
>
)
}
else
{
return
(
<
Empty
/>
)
}
}
)
:
null
}
<
/>
)
<
/>
)
};
};
...
...
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
d9d0fd66
import
{
FormControlLabel
,
Switch
}
from
"@mui/material"
;
import
{
FormControlLabel
,
Switch
}
from
"@mui/material"
;
import
{
useState
}
from
"react"
;
import
{
use
Effect
,
useRef
,
use
State
}
from
"react"
;
import
CalendarRow
from
"./CalendarRow/CalendarRow"
;
import
CalendarRow
from
"./CalendarRow/CalendarRow"
;
import
CalendarSmallCell
from
"./CalendarSmallCell/CalendarSmallCell"
;
import
CalendarSmallCell
from
"./CalendarSmallCell/CalendarSmallCell"
;
import
CalendarStandartCell
from
"./CalendarStandartCell.js/CalendarStandartCell"
;
import
CalendarStandartCell
from
"./CalendarStandartCell.js/CalendarStandartCell"
;
...
@@ -25,10 +25,18 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
...
@@ -25,10 +25,18 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
setModal
({...
modal
,
open
:
false
})
setModal
({...
modal
,
open
:
false
})
setCurrentTask
({})
setCurrentTask
({})
};
};
const
divRef
=
useRef
(
null
)
const
[
divHeight
,
setDivHeight
]
=
useState
(
''
)
useEffect
(()
=>
{
if
(
divRef
)
{
setDivHeight
(()
=>
{
return
divRef
.
current
?.
offsetHeight
})
}
},
[
divRef
.
current
?.
offsetHeight
,
hourFormat
,
month
,
tasks
]);
return
(
return
(
<>
<
div
ref
=
{
divRef
}
style
=
{{
marginBottom
:
'30px'
}}
>
<
CalendarRow
<
CalendarRow
>
>
<
CalendarSmallCell
xs
=
{
1.2
}
>
<
CalendarSmallCell
xs
=
{
1.2
}
>
...
@@ -40,7 +48,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
...
@@ -40,7 +48,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
<
/CalendarSmallCell
>
<
/CalendarSmallCell
>
{
hoursInDay
?.
map
((
hours
,
i
)
=>
{
{
hoursInDay
?.
map
((
hours
,
i
)
=>
{
return
(
return
(
<
CalendarStandartCell
key
=
{
i
}
xs
=
{
cellSizes
.
standarCell
}
>
<
CalendarStandartCell
key
=
{
i
}
xs
=
{
cellSizes
.
standarCell
}
divRef
=
{
divHeight
}
>
{
hours
}
{
hours
}
<
/CalendarStandartCell
>
<
/CalendarStandartCell
>
)
)
...
@@ -83,7 +91,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
...
@@ -83,7 +91,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
deleteTaskHandler
=
{()
=>
{
deleteTaskHandler
(
currentTask
.
id
);
handleClose
()}}
deleteTaskHandler
=
{()
=>
{
deleteTaskHandler
(
currentTask
.
id
);
handleClose
()}}
/
>
/
>
<
/ModalTask
>
<
/ModalTask
>
<
/
>
<
/
div
>
);
);
}
}
...
...
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