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
213b15cc
Commit
213b15cc
authored
Nov 21, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#54
Реализовал изменение размера задачи через кнопки
parent
7f789605
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
98 deletions
+47
-98
CalendarTask.js
...components/MonthCalendarBody/CalendarTask/CalendarTask.js
+23
-81
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+22
-16
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+2
-1
No files found.
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
213b15cc
import
{
Grid
}
from
"@mui/material"
;
import
{
Grid
}
from
"@mui/material"
;
import
React
,
{
memo
,
useEffect
,
useRef
,
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
,
increaseTaskHandler
,
reduceTaskHandler
})
=>
{
const
CalendarTask
=
({
setCurrentTask
,
handleOpen
,
task
,
line
,
setCurrentLine
,
increaseTaskHandler
,
reduceTaskHandler
})
=>
{
...
@@ -15,80 +26,6 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, i
...
@@ -15,80 +26,6 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, i
}
}
},
[
task
])
},
[
task
])
const
ref
=
useRef
(
null
);
const
refLeft
=
useRef
(
null
);
const
refRight
=
useRef
(
null
);
useEffect
(()
=>
{
const
resizeableEle
=
ref
.
current
;
const
styles
=
window
.
getComputedStyle
(
resizeableEle
);
let
width
=
parseInt
(
styles
.
width
,
10
);
let
x
=
0
;
const
lastPoint
=
{
x
:
null
,
y
:
null
}
const
onMouseMoveRightResize
=
(
event
)
=>
{
event
.
stopPropagation
()
const
leftOrRight
=
(
event
.
clientX
>
lastPoint
.
x
?
'right'
:
event
.
clientX
<
lastPoint
.
x
?
'left'
:
'none'
)
if
(
leftOrRight
===
'right'
)
{
increaseTaskHandler
(
line
,
task
,
false
)
}
lastPoint
.
x
=
event
.
clientX
lastPoint
.
y
=
event
.
clientY
};
const
onMouseUpRightResize
=
(
event
)
=>
{
event
.
stopPropagation
()
document
.
removeEventListener
(
"mousemove"
,
onMouseMoveRightResize
);
};
const
onMouseDownRightResize
=
(
event
)
=>
{
event
.
stopPropagation
()
x
=
event
.
clientX
;
resizeableEle
.
style
.
left
=
styles
.
left
;
resizeableEle
.
style
.
right
=
null
;
document
.
addEventListener
(
"mousemove"
,
onMouseMoveRightResize
);
document
.
addEventListener
(
"mouseup"
,
onMouseUpRightResize
);
};
// Left resize
const
onMouseMoveLeftResize
=
(
event
)
=>
{
event
.
stopPropagation
()
const
dx
=
event
.
clientX
-
x
;
x
=
event
.
clientX
;
width
=
width
-
dx
;
resizeableEle
.
style
.
width
=
`
${
width
}
px`
;
};
const
onMouseUpLeftResize
=
(
event
)
=>
{
event
.
stopPropagation
()
document
.
removeEventListener
(
"mousemove"
,
onMouseMoveLeftResize
);
};
const
onMouseDownLeftResize
=
(
event
)
=>
{
event
.
stopPropagation
()
x
=
event
.
clientX
;
resizeableEle
.
style
.
right
=
styles
.
right
;
resizeableEle
.
style
.
left
=
null
;
document
.
addEventListener
(
"mousemove"
,
onMouseMoveLeftResize
);
document
.
addEventListener
(
"mouseup"
,
onMouseUpLeftResize
);
};
// Add mouse down event listener
const
resizerRight
=
refRight
.
current
;
resizerRight
.
addEventListener
(
"mousedown"
,
onMouseDownRightResize
);
const
resizerLeft
=
refLeft
.
current
;
resizerLeft
.
addEventListener
(
"mousedown"
,
onMouseDownLeftResize
);
return
()
=>
{
resizerRight
.
removeEventListener
(
"mousedown"
,
onMouseDownRightResize
);
resizerLeft
.
removeEventListener
(
"mousedown"
,
onMouseDownLeftResize
);
};
},
[]);
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
const
onClickTaskHandler
=
(
e
,
task
)
=>
{
e
.
stopPropagation
();
e
.
stopPropagation
();
setCurrentTask
(
task
);
setCurrentTask
(
task
);
...
@@ -109,18 +46,23 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, i
...
@@ -109,18 +46,23 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, i
return
(
<>
return
(
<>
<
Grid
<
Grid
draggable
=
{
true
}
draggable
=
{
true
}
ref
=
{
ref
}
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
)}}
>
>
<
div
ref
=
{
refLeft
}
style
=
{{
cursor
:
'col-resize'
,
height
:
'100%'
,
left
:
'0'
,
top
:
'0'
,
width
:
'5px'
,
backgroundColor
:
'grey'
}}
><
/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
>
<
span
>
{
task
.
title
}
{
task
.
title
}
<
/span
>
<
/span
>
<
div
ref
=
{
refRight
}
style
=
{{
cursor
:
'col-resize'
,
height
:
'100%'
,
right
:
'0'
,
top
:
'0'
,
width
:
'5px'
,
backgroundColor
:
'grey'
}}
><
/div
>
<
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/containers/MonthCalendar/MonthCalendar.js
View file @
213b15cc
...
@@ -157,7 +157,7 @@ function MonthCalendar() {
...
@@ -157,7 +157,7 @@ function MonthCalendar() {
let
start
let
start
if
(
isStartTask
)
{
if
(
isStartTask
)
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
,
59
))
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
,
59
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
+
hourDiff
,
0
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
-
hourDiff
,
0
))
}
else
{
}
else
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
+
hourDiff
,
59
))
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
+
hourDiff
,
59
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
,
0
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
,
0
))
...
@@ -170,6 +170,7 @@ function MonthCalendar() {
...
@@ -170,6 +170,7 @@ function MonthCalendar() {
delete
newObj
.
infoForCell
delete
newObj
.
infoForCell
await
dispatch
(
editTask
(
newObj
))
await
dispatch
(
editTask
(
newObj
))
setCurrentTask
({})
setCurrentTask
({})
}
}
const
reduceTaskHandler
=
async
(
dayNumber
,
task
,
isStartTask
)
=>
{
const
reduceTaskHandler
=
async
(
dayNumber
,
task
,
isStartTask
)
=>
{
...
@@ -178,16 +179,20 @@ function MonthCalendar() {
...
@@ -178,16 +179,20 @@ function MonthCalendar() {
const
timeStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
1
]
const
timeStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
1
]
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
let
hourDiff
let
hourDiff
let
hourDiffCheck
if
(
hourFormat
)
{
if
(
hourFormat
)
{
hourDiff
=
1
hourDiff
=
1
hourDiffCheck
=
0
}
else
{
}
else
{
hourDiff
=
2
hourDiff
=
2
hourDiffCheck
=
1
}
}
let
due
let
due
let
start
let
start
if
(
task
.
infoForCell
.
endHour
-
task
.
infoForCell
.
startHour
-
hourDiffCheck
!==
0
)
{
if
(
isStartTask
)
{
if
(
isStartTask
)
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
,
59
))
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
,
59
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
-
hourDiff
,
0
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
+
hourDiff
,
0
))
}
else
{
}
else
{
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
-
hourDiff
,
59
))
due
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeEndHour
-
hourDiff
,
59
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
,
0
))
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
timeStartHour
,
0
))
...
@@ -201,6 +206,7 @@ function MonthCalendar() {
...
@@ -201,6 +206,7 @@ function MonthCalendar() {
await
dispatch
(
editTask
(
newObj
))
await
dispatch
(
editTask
(
newObj
))
setCurrentTask
({})
setCurrentTask
({})
}
}
}
const
sendNewTaskHandler
=
async
()
=>
{
const
sendNewTaskHandler
=
async
()
=>
{
if
(
currentTask
.
id
)
{
if
(
currentTask
.
id
)
{
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
213b15cc
...
@@ -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