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
53b62eba
Commit
53b62eba
authored
Nov 09, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#30
Реализовал оторажение модального окна рядом с задачей
parent
bd90d3e8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
19 deletions
+73
-19
CalendarTask.js
...components/MonthCalendarBody/CalendarTask/CalendarTask.js
+17
-17
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+23
-1
ModalTask.js
planner-front/src/components/UI/ModalTask/ModalTask.js
+32
-0
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+1
-1
No files found.
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
53b62eba
import
{
Grid
,
TextField
}
from
"@mui/material"
;
import
{
Grid
,
TextField
}
from
"@mui/material"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
const
CalendarTask
=
({
year
,
month
,
tasks
,
day
,
hours
,
setCurrentTask
,
onChange
,
hourFormat
})
=>
{
const
CalendarTask
=
({
year
,
month
,
tasks
,
day
,
hours
,
setCurrentTask
,
onChange
,
hourFormat
,
handleOpen
})
=>
{
const
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
const
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
const
hour
=
parseInt
(
hours
.
split
(
':'
)[
0
])
const
hour
=
parseInt
(
hours
.
split
(
':'
)[
0
])
let
hourDiffEnd
let
hourDiffEnd
let
hourDiffStart
if
(
hourFormat
)
{
if
(
hourFormat
)
{
hourDiffEnd
=
hour
+
1
hourDiffEnd
=
hour
+
1
}
else
{
}
else
{
hourDiffEnd
=
hour
+
2
hourDiffEnd
=
hour
+
2
}
}
if
(
hourFormat
)
{
hourDiffStart
=
hour
-
1
}
else
{
hourDiffStart
=
hour
-
2
}
const
tasksCell
=
tasks
.
filter
(
task
=>
{
const
tasksCell
=
tasks
.
filter
(
task
=>
{
if
(
year
===
task
.
infoForCell
.
startYear
)
{
if
(
year
===
task
.
infoForCell
.
startYear
)
{
if
(
month
+
1
===
task
.
infoForCell
.
startMonth
)
{
if
(
month
+
1
===
task
.
infoForCell
.
startMonth
)
{
...
@@ -39,17 +34,22 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, onChange,
...
@@ -39,17 +34,22 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, onChange,
{
tasksCell
.
length
?
tasksCell
.
map
((
task
,
i
)
=>
{
tasksCell
.
length
?
tasksCell
.
map
((
task
,
i
)
=>
{
{
return
(
return
(
<
Grid
key
=
{
task
.
id
}
sx
=
{{
backgroundColor
:
'lightgreen'
}}
>
<
Grid
<
TextField
key
=
{
task
.
id
}
id
=
{
task
.
title
}
sx
=
{{
backgroundColor
:
'lightgreen'
}}
variant
=
"standard"
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCurrentTask
(
task
);
handleOpen
(
e
)}}
value
=
{
task
.
title
}
>
name
=
'title'
<
TextField
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCurrentTask
(
task
)}}
id
=
{
task
.
title
}
onChange
=
{
onChange
}
>
variant
=
"standard"
<
/TextField
>
value
=
{
task
.
title
}
<
/Grid>
)
}
name
=
'title'
onChange
=
{
onChange
}
>
<
/TextField
>
<
/Grid
>
)}
)
:
null
}
)
:
null
}
<
/>
)
<
/>
)
};
};
...
...
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
53b62eba
...
@@ -4,12 +4,29 @@ import CalendarRow from "./CalendarRow/CalendarRow";
...
@@ -4,12 +4,29 @@ 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"
;
import
CalendarTask
from
"./CalendarTask/CalendarTask"
;
import
CalendarTask
from
"./CalendarTask/CalendarTask"
;
import
ModalTask
from
"../UI/ModalTask/ModalTask"
;
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
onChangeCellTaskTitle
,
setCurrentTask
,
hourFormat
,
setHourFormat
})
{
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
onChangeCellTaskTitle
,
setCurrentTask
,
hourFormat
,
setHourFormat
})
{
const
[
hoursInDay
,
setHoursInDay
]
=
useState
([
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
])
const
[
hoursInDay
,
setHoursInDay
]
=
useState
([
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
])
const
[
daysInMonth
,
setDaysInMonth
]
=
useState
([])
const
[
daysInMonth
,
setDaysInMonth
]
=
useState
([])
const
[
cellSizes
,
setCellSizes
]
=
useState
({})
const
[
cellSizes
,
setCellSizes
]
=
useState
({})
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,});
const
handleOpen
=
(
e
)
=>
{
console
.
log
(
e
.
nativeEvent
.
offsetX
)
setModal
(
{...
modal
,
open
:
true
,
yPage
:
e
.
pageY
,
xPage
:
e
.
pageX
,
yDivClick
:
e
.
nativeEvent
.
offsetY
,
xDivClick
:
e
.
nativeEvent
.
offsetX
,
yDiv
:
e
.
target
.
offsetHeight
,
xDiv
:
e
.
target
.
offsetWidth
,
})
};
const
handleClose
=
()
=>
setModal
({...
modal
,
open
:
false
});
useEffect
(()
=>
{
useEffect
(()
=>
{
const
cells
=
hoursInDay
.
length
const
cells
=
hoursInDay
.
length
const
xs
=
10.8
/
cells
const
xs
=
10.8
/
cells
...
@@ -105,13 +122,18 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang
...
@@ -105,13 +122,18 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang
day
=
{
day
}
day
=
{
day
}
hours
=
{
hours
}
hours
=
{
hours
}
hourFormat
=
{
hourFormat
}
hourFormat
=
{
hourFormat
}
/
>
handleOpen
=
{
handleOpen
}
/>
<
/CalendarStandartCell
>
<
/CalendarStandartCell
>
)
)
})}
})}
<
/CalendarRow
>
<
/CalendarRow
>
)
)
})}
})}
<
ModalTask
modal
=
{
modal
}
handleClose
=
{()
=>
{
handleClose
()}}
/
>
<
/
>
<
/
>
);
);
}
}
...
...
planner-front/src/components/UI/ModalTask/ModalTask.js
0 → 100644
View file @
53b62eba
import
Box
from
'@mui/material/Box'
;
import
Modal
from
'@mui/material/Modal'
;
export
default
function
ModalTask
({
modal
,
handleClose
,
children
})
{
const
style
=
{
position
:
'absolute'
,
top
:
modal
.
yPage
-
modal
.
yDiv
-
modal
.
yDivClick
,
left
:
modal
.
xPage
+
modal
.
xDiv
-
modal
.
xDivClick
+
10
,
width
:
250
,
height
:
300
,
bgcolor
:
'background.paper'
,
border
:
'2px solid #000'
,
boxShadow
:
24
,
p
:
4
,
};
return
(
<
div
>
<
Modal
open
=
{
modal
.
open
}
onClose
=
{
handleClose
}
aria
-
labelledby
=
"modal-modal-title"
aria
-
describedby
=
"modal-modal-description"
BackdropProps
=
{{
style
:
{
backgroundColor
:
'rgba(255,255,255, 0)'
}
}}
>
<
Box
sx
=
{
style
}
>
{
children
}
<
/Box
>
<
/Modal
>
<
/div
>
);
}
\ No newline at end of file
planner-front/src/store/actions/tasksActions.js
View file @
53b62eba
...
@@ -44,7 +44,7 @@ export const addTask = (task) => {
...
@@ -44,7 +44,7 @@ export const addTask = (task) => {
try
{
try
{
await
axios
.
post
(
"/tasks"
,
task
,
{
await
axios
.
post
(
"/tasks"
,
task
,
{
headers
:
{
headers
:
{
'Authorization'
:
'
yjBjcPCQwytwrYo9rRuiK
'
'Authorization'
:
'
5uJ4ub517ba9IReG6ltFR
'
}
}
});
});
dispatch
(
addTaskSuccess
())
dispatch
(
addTaskSuccess
())
...
...
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