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
ce84932b
Commit
ce84932b
authored
Nov 14, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#38
Получилось отобразить задачи в часовом формате без нюансов
parent
36e04fb1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
10 deletions
+95
-10
CalendarTask.js
...components/MonthCalendarBody/CalendarTask/CalendarTask.js
+95
-10
No files found.
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
ce84932b
import
{
Grid
,
TextField
,
Typography
}
from
"@mui/material"
;
import
React
,
{
memo
,
useState
,
useEffect
}
from
"react"
;
const
TaskDefault
=
({
task
,
onClickTaskHandler
})
=>
{
return
(
<
Grid
sx
=
{{
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'10px'
,
borderBottom
:
'1px solid rgb(29, 161, 51)'
,
borderRadius
:
'10px'
,
margin
:
"5px 10px"
}}
onClick
=
{
onClickTaskHandler
}
>
<
span
>
{
task
.
title
}
<
/span
>
<
/Grid>
)
}
const
TaskWithNoStartAndAllEnd
=
({
task
,
onClickTaskHandler
})
=>
{
return
(
<
Grid
sx
=
{{
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
padding
:
'10px'
,
borderBottom
:
'1px solid rgb(29, 161, 51)'
,
borderTopLeftRadius
:
'10px'
,
borderBottomLeftRadius
:
'10px'
,
margin
:
"5px -1px 5px 10px"
,
position
:
'relative'
}}
onClick
=
{
onClickTaskHandler
}
>
<
span
>
{
task
.
title
}
<
/span
>
<
/Grid>
)
}
const
TaskWithAllStartAndNoEnd
=
({
task
,
onClickTaskHandler
})
=>
{
return
(
<
Grid
sx
=
{{
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'10px'
,
borderBottom
:
'1px solid rgb(29, 161, 51)'
,
borderTopRightRadius
:
'10px'
,
borderBottomRightRadius
:
'10px'
,
margin
:
"5px 10px 5px -1px"
}}
onClick
=
{
onClickTaskHandler
}
>
<
span
>
&
#
8291
;
<
/span
>
<
/Grid>
)
}
const
TaskWithAllStartAndAllEnd
=
({
task
,
onClickTaskHandler
})
=>
{
return
(
<
Grid
sx
=
{{
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'10px'
,
borderBottom
:
'1px solid rgb(29, 161, 51)'
,
margin
:
"5px -1px"
}}
onClick
=
{
onClickTaskHandler
}
>
<
span
>
&
#
8291
;
<
/span
>
<
/Grid>
)
}
const
CalendarTask
=
({
year
,
month
,
tasks
,
day
,
hours
,
setCurrentTask
,
hourFormat
,
handleOpen
,
currentTask
})
=>
{
const
[
thisCellCurrentTask
,
setThisCellCurrentTask
]
=
useState
({})
const
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
const
hour
=
parseInt
(
hours
.
split
(
':'
)[
0
])
const
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
let
hourDiffEnd
if
(
hourFormat
)
{
hourDiffEnd
=
hour
+
1
...
...
@@ -24,8 +71,14 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
}
}
})
tasksCell
.
sort
(
function
(
a
,
b
){
const
durattionFirstDate
=
new
Date
(
a
.
dateTimeDue
).
getTime
()
-
new
Date
(
a
.
dateTimeStart
).
getTime
()
const
durattionSecondDate
=
new
Date
(
b
.
dateTimeDue
).
getTime
()
-
new
Date
(
b
.
dateTimeStart
).
getTime
()
return
durattionSecondDate
-
durattionFirstDate
;
});
return
tasksCell
}
const
tasksCell
=
getTaskInDayCell
(
tasks
,
day
,
hours
)
useEffect
(()
=>
{
...
...
@@ -34,18 +87,50 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
}
},
[
currentTask
])
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
e
.
stopPropagation
();
setCurrentTask
(
task
);
handleOpen
(
e
)
}
return
(
<>
{
tasksCell
.
length
?
tasksCell
.
map
((
task
,
i
)
=>
{
if
(
task
.
infoForCell
.
endHour
>
hour
&&
task
.
infoForCell
.
startHour
===
hour
&&
hourFormat
)
{
return
(
<
Grid
<
TaskWithNoStartAndAllEnd
key
=
{
task
.
id
}
sx
=
{{
backgroundColor
:
'lightgreen'
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
padding
:
'10px'
,
borderBottom
:
'1px solid rgb(29, 161, 51);;'
}}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCurrentTask
(
task
);
handleOpen
(
e
)}}
>
{
task
.
title
}
<
/Grid
>
task
=
{
task
}
onClickTaskHandler
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
/
>
)
}
if
(
task
.
infoForCell
.
startHour
<
hour
&&
task
.
infoForCell
.
endHour
>
hour
)
{
return
(
<
TaskWithAllStartAndAllEnd
key
=
{
task
.
id
}
task
=
{
task
}
onClickTaskHandler
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
/
>
)
}
if
(
task
.
infoForCell
.
endMinute
===
59
&&
task
.
infoForCell
.
startHour
<
hour
)
{
return
(
<
TaskWithAllStartAndNoEnd
key
=
{
task
.
id
}
task
=
{
task
}
onClickTaskHandler
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
/
>
)
}
return
(
<
TaskDefault
key
=
{
task
.
id
}
task
=
{
task
}
onClickTaskHandler
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
/
>
)}
)
:
null
}
...
...
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