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
676a167d
Commit
676a167d
authored
Nov 22, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'task-54-feature/resize_tasks' into 'development'
Task 54 feature/resize tasks See merge request
!37
parents
6a213935
29c816db
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
158 additions
and
17 deletions
+158
-17
CalendarRowDay.js
...onents/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
+4
-3
CalendarTask.css
...omponents/MonthCalendarBody/CalendarTask/CalendarTask.css
+30
-0
CalendarTask.js
...components/MonthCalendarBody/CalendarTask/CalendarTask.js
+48
-10
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+3
-1
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+71
-2
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+2
-1
No files found.
planner-front/src/components/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
View file @
676a167d
...
@@ -4,7 +4,7 @@ import CalendarStandartCell from "../CalendarStandartCell.js/CalendarStandartCel
...
@@ -4,7 +4,7 @@ import CalendarStandartCell from "../CalendarStandartCell.js/CalendarStandartCel
import
CalendarTask
from
"../CalendarTask/CalendarTask"
;
import
CalendarTask
from
"../CalendarTask/CalendarTask"
;
import
EmptyBox
from
"./EmptyBox/EmptyBox"
;
import
EmptyBox
from
"./EmptyBox/EmptyBox"
;
const
CalendarRowDay
=
({
xs
,
hoursInDay
,
createTaskInCellHandler
,
currentTask
,
handleOpen
,
modal
,
setCurrentTask
,
year
,
month
,
tasks
,
day
,
hourFormat
,
setCurrentLine
,
currentLine
,
dragTaskHandler
})
=>
{
const
CalendarRowDay
=
({
xs
,
hoursInDay
,
createTaskInCellHandler
,
currentTask
,
handleOpen
,
modal
,
setCurrentTask
,
year
,
month
,
tasks
,
day
,
hourFormat
,
setCurrentLine
,
currentLine
,
dragTaskHandler
,
increaseTaskHandler
,
reduceTaskHandler
})
=>
{
const
hours
=
useMemo
(()
=>
{
const
hours
=
useMemo
(()
=>
{
return
hoursInDay
.
map
((
hour
)
=>
parseInt
(
hour
.
split
(
':'
)[
0
]))},
return
hoursInDay
.
map
((
hour
)
=>
parseInt
(
hour
.
split
(
':'
)[
0
]))},
...
@@ -163,7 +163,6 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
...
@@ -163,7 +163,6 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
{
boxes
.
map
((
box
,
index
)
=>
{
{
boxes
.
map
((
box
,
index
)
=>
{
if
(
box
.
task
)
{
if
(
box
.
task
)
{
return
(
<
Grid
return
(
<
Grid
key
=
{
i
}
item
xs
=
{
box
.
xs
}
item
xs
=
{
box
.
xs
}
sx
=
{{
height
:
'35px'
,
marginBottom
:
'5px'
}}
sx
=
{{
height
:
'35px'
,
marginBottom
:
'5px'
}}
>
>
...
@@ -175,13 +174,15 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
...
@@ -175,13 +174,15 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
hour
=
{
parseInt
(
hours
[
index
])}
hour
=
{
parseInt
(
hours
[
index
])}
line
=
{
day
.
dayNumber
}
line
=
{
day
.
dayNumber
}
task
=
{
box
.
task
}
task
=
{
box
.
task
}
hourFormat
=
{
hourFormat
}
setCurrentTask
=
{
setCurrentTask
}
setCurrentTask
=
{
setCurrentTask
}
handleOpen
=
{
handleOpen
}
handleOpen
=
{
handleOpen
}
increaseTaskHandler
=
{
increaseTaskHandler
}
reduceTaskHandler
=
{
reduceTaskHandler
}
/
>
/
>
<
/Grid>
)
<
/Grid>
)
}
else
{
}
else
{
return
(
<
EmptyBox
return
(
<
EmptyBox
key
=
{
i
}
modal
=
{
modal
}
modal
=
{
modal
}
dayNumber
=
{
day
.
dayNumber
}
dayNumber
=
{
day
.
dayNumber
}
hourNumber
=
{
box
.
hour
}
hourNumber
=
{
box
.
hour
}
...
...
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.css
0 → 100644
View file @
676a167d
.resizeable
{
border
:
2px
solid
#533535
;
border-radius
:
3px
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
min-width
:
15px
;
min-height
:
15px
;
}
.resizer
{
position
:
absolute
;
background
:
black
;
}
.resizer-r
{
cursor
:
col-resize
;
height
:
100%
;
right
:
0
;
top
:
0
;
width
:
5px
;
}
.resizer-l
{
cursor
:
col-resize
;
height
:
100%
;
left
:
0
;
top
:
0
;
width
:
5px
;
}
\ No newline at end of file
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
676a167d
import
{
Grid
}
from
"@mui/material"
;
import
{
Grid
}
from
"@mui/material"
;
import
React
,
{
memo
,
useEffect
,
useState
}
from
"react"
;
import
React
,
{
memo
,
useEffect
,
useRef
,
useState
}
from
"react"
;
import
ArrowBackIcon
from
'@mui/icons-material/ArrowBack'
;
import
ArrowForwardIcon
from
'@mui/icons-material/ArrowForward'
;
const
arrowClass
=
{
height
:
'20px'
,
cursor
:
'pointer'
,
transition
:
'0.5s'
,
"&:hover"
:
{
transition
:
'0.5s'
,
transform
:
'scale(1.2)'
}
}
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
,
line
,
setCurrentLine
,
currentLine
,
currentTask
,
dragTaskHandler
,
hour
})
=>
{
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
,
line
,
setCurrentLine
,
increaseTaskHandler
,
reduceTaskHandler
,
hourFormat
})
=>
{
const
[
color
,
setColor
]
=
useState
(
''
)
const
[
color
,
setColor
]
=
useState
(
''
)
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -16,13 +26,12 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, c
...
@@ -16,13 +26,12 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, c
}
}
},
[
task
])
},
[
task
])
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
e
.
stopPropagation
();
e
.
stopPropagation
();
setCurrentTask
(
task
);
setCurrentTask
(
task
);
handleOpen
(
e
)
handleOpen
(
e
)
}
}
const
dragLeaveHandler
=
(
e
)
=>
{
const
dragLeaveHandler
=
(
e
)
=>
{
e
.
target
.
style
.
boxShadow
=
'none'
e
.
target
.
style
.
boxShadow
=
'none'
}
}
...
@@ -37,16 +46,45 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, c
...
@@ -37,16 +46,45 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, c
return
(
<>
return
(
<>
<
Grid
<
Grid
draggable
=
{
true
}
draggable
=
{
true
}
onDragLeave
=
{(
e
)
=>
{
dragLeaveHandler
(
e
)}}
onDragLeave
=
{(
e
)
=>
{
dragLeaveHandler
(
e
)}}
onDragStart
=
{(
e
)
=>
{
dragStartHandler
(
e
,
line
,
task
)}}
onDragStart
=
{(
e
)
=>
{
dragStartHandler
(
e
,
line
,
task
)}}
onDragEnd
=
{(
e
)
=>
{
dragEndHandler
(
e
)}}
onDragEnd
=
{(
e
)
=>
{
dragEndHandler
(
e
)}}
sx
=
{{
position
:
'relative'
,
height
:
'30px'
,
backgroundColor
:
color
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
borderRadius
:
'10px'
,
margin
:
'5px 10px'
,
display
:
'flex'
,
justifyContent
:
'flex-start'
,
alignItems
:
'center'
,
paddingLeft
:
'5px'
,
zIndex
:
'5'
}}
sx
=
{{
position
:
'relative'
,
height
:
'30px'
,
backgroundColor
:
color
,
whiteSpace
:
'nowrap'
,
overflow
:
'hidden'
,
textOverflow
:
'ellipsis'
,
borderRadius
:
'10px'
,
margin
:
'5px 10px'
,
display
:
'flex'
,
justifyContent
:
'flex-start'
,
alignItems
:
'center'
,
paddingLeft
:
'5px'
,
zIndex
:
'5'
,
justifyContent
:
'space-between'
}}
onClick
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
onClick
=
{(
e
)
=>
{
onClickTaskHandler
(
e
,
task
)}}
>
>
<
span
>
{
task
.
infoForCell
.
endHour
===
task
.
infoForCell
.
startHour
&&
hourFormat
?
{
task
.
title
}
<>
<
/span
>
<
div
tyle
=
{{
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
div
style
=
{{
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
ArrowBackIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
increaseTaskHandler
(
line
,
task
,
true
)}}
/
>
<
ArrowForwardIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
reduceTaskHandler
(
line
,
task
,
true
)}}
/
>
<
ArrowBackIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
reduceTaskHandler
(
line
,
task
,
false
)}}
/
>
<
ArrowForwardIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
increaseTaskHandler
(
line
,
task
,
false
)}}
/
>
<
/div
>
<
/div
>
<
div
>
<
span
>
{
task
.
title
}
<
/span
>
<
/div
>
<
/
>
:
<>
<
div
style
=
{{
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
ArrowBackIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
increaseTaskHandler
(
line
,
task
,
true
)}}
/
>
<
ArrowForwardIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
reduceTaskHandler
(
line
,
task
,
true
)}}
/
>
<
/div
>
<
span
>
{
task
.
title
}
<
/span
>
<
div
style
=
{{
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
ArrowBackIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
reduceTaskHandler
(
line
,
task
,
false
)}}
/
>
<
ArrowForwardIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
increaseTaskHandler
(
line
,
task
,
false
)}}
/
>
<
/div
>
<
/
>
}
<
/Grid
>
<
/Grid
>
<
/>
)
<
/>
)
};
};
...
...
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
676a167d
...
@@ -8,7 +8,7 @@ import MonthCalendarModalContent from "../MonthCalendarModalContent/MonthCalenda
...
@@ -8,7 +8,7 @@ import MonthCalendarModalContent from "../MonthCalendarModalContent/MonthCalenda
import
CalendarRowDay
from
"./CalendarRowDay/CalendarRowDay"
;
import
CalendarRowDay
from
"./CalendarRowDay/CalendarRowDay"
;
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
currentTask
,
setCurrentTask
,
hourFormat
,
setHourFormat
,
onChangeCurrentTaskHandler
,
sendNewTaskHandler
,
deleteTaskHandler
,
cellSizes
,
hoursInDay
,
daysInMonth
,
dragTaskHandler
})
{
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
currentTask
,
setCurrentTask
,
hourFormat
,
setHourFormat
,
onChangeCurrentTaskHandler
,
sendNewTaskHandler
,
deleteTaskHandler
,
cellSizes
,
hoursInDay
,
daysInMonth
,
dragTaskHandler
,
increaseTaskHandler
,
reduceTaskHandler
})
{
const
[
currentLine
,
setCurrentLine
]
=
useState
(
''
)
const
[
currentLine
,
setCurrentLine
]
=
useState
(
''
)
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,});
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,});
...
@@ -83,6 +83,8 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
...
@@ -83,6 +83,8 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
tasks
=
{
tasks
}
tasks
=
{
tasks
}
day
=
{
day
}
day
=
{
day
}
hourFormat
=
{
hourFormat
}
hourFormat
=
{
hourFormat
}
increaseTaskHandler
=
{
increaseTaskHandler
}
reduceTaskHandler
=
{
reduceTaskHandler
}
>
>
<
/CalendarRowDay
>
<
/CalendarRowDay
>
<
/CalendarRow
>
<
/CalendarRow
>
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
676a167d
...
@@ -133,12 +133,79 @@ function MonthCalendar() {
...
@@ -133,12 +133,79 @@ function MonthCalendar() {
const
hourDiff
=
timeEndHour
-
timeStartHour
const
hourDiff
=
timeEndHour
-
timeStartHour
const
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
+
hourDiff
,
59
))
const
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
+
hourDiff
,
59
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
,
0
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
,
0
))
await
dispatch
(
editTask
(
{
const
newObj
=
{
...
currentTask
,
...
currentTask
,
dateTimeStart
:
start
,
dateTimeStart
:
start
,
dateTimeDue
:
due
dateTimeDue
:
due
}))
}
delete
newObj
.
infoForCell
await
dispatch
(
editTask
(
newObj
))
setCurrentTask
({})
}
const
increaseTaskHandler
=
async
(
dayNumber
,
task
,
isStartTask
)
=>
{
const
timeEnd
=
task
.
dateTimeDue
.
split
(
'T'
)[
1
]
const
timeEndHour
=
parseInt
(
timeEnd
.
split
(
':'
)[
0
])
const
timeStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
1
]
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
let
hourDiff
if
(
hourFormat
)
{
hourDiff
=
1
}
else
{
hourDiff
=
2
}
let
due
let
start
if
(
isStartTask
)
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
,
59
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
-
hourDiff
,
0
))
}
else
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
+
hourDiff
,
59
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
,
0
))
}
const
newObj
=
{
...
task
,
dateTimeStart
:
start
,
dateTimeDue
:
due
}
delete
newObj
.
infoForCell
await
dispatch
(
editTask
(
newObj
))
setCurrentTask
({})
setCurrentTask
({})
}
const
reduceTaskHandler
=
async
(
dayNumber
,
task
,
isStartTask
)
=>
{
const
timeEnd
=
task
.
dateTimeDue
.
split
(
'T'
)[
1
]
const
timeEndHour
=
parseInt
(
timeEnd
.
split
(
':'
)[
0
])
const
timeStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
1
]
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
let
hourDiff
let
hourDiffCheck
if
(
hourFormat
)
{
hourDiff
=
1
hourDiffCheck
=
0
}
else
{
hourDiff
=
2
hourDiffCheck
=
1
}
let
due
let
start
if
(
task
.
infoForCell
.
endHour
-
task
.
infoForCell
.
startHour
-
hourDiffCheck
!==
0
)
{
if
(
isStartTask
)
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
,
59
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
+
hourDiff
,
0
))
}
else
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
-
hourDiff
,
59
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
,
0
))
}
const
newObj
=
{
...
task
,
dateTimeStart
:
start
,
dateTimeDue
:
due
}
delete
newObj
.
infoForCell
await
dispatch
(
editTask
(
newObj
))
setCurrentTask
({})
}
}
}
const
sendNewTaskHandler
=
async
()
=>
{
const
sendNewTaskHandler
=
async
()
=>
{
...
@@ -193,6 +260,8 @@ function MonthCalendar() {
...
@@ -193,6 +260,8 @@ function MonthCalendar() {
hoursInDay
=
{
hoursInDay
}
hoursInDay
=
{
hoursInDay
}
daysInMonth
=
{
daysInMonth
}
daysInMonth
=
{
daysInMonth
}
dragTaskHandler
=
{
dragTaskHandler
}
dragTaskHandler
=
{
dragTaskHandler
}
increaseTaskHandler
=
{
increaseTaskHandler
}
reduceTaskHandler
=
{
reduceTaskHandler
}
/
>
/
>
<
/
>
<
/
>
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
676a167d
...
@@ -32,7 +32,8 @@ const tasksReduсer = (state = initialState, action) => {
...
@@ -32,7 +32,8 @@ const tasksReduсer = (state = initialState, action) => {
const
newArr
=
[]
const
newArr
=
[]
action
.
tasks
.
forEach
((
task
)
=>
{
action
.
tasks
.
forEach
((
task
)
=>
{
if
(
task
.
dateTimeStart
&&
task
.
dateTimeDue
)
{
if
(
task
.
dateTimeStart
&&
task
.
dateTimeDue
)
{
if
(
new
Date
(
task
.
dateTimeDue
).
getTime
()
-
new
Date
(
task
.
dateTimeStart
).
getTime
()
<
(
10
*
3600000
))
{
if
(
new
Date
(
task
.
dateTimeDue
).
getTime
()
-
new
Date
(
task
.
dateTimeStart
).
getTime
()
<
(
24
*
3600000
)
&&
new
Date
(
task
.
dateTimeDue
).
getTime
()
-
new
Date
(
task
.
dateTimeStart
).
getTime
()
>
0
)
{
const
dateStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
0
]
const
dateStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
0
]
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
]
...
...
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