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
8d1eb887
Commit
8d1eb887
authored
Nov 08, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#29
Реализовал свитч, который меняет часы
parent
d10cdbd9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
14 deletions
+53
-14
Task.ts
planner-api/src/models/Task.ts
+2
-2
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+32
-7
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+19
-5
No files found.
planner-api/src/models/Task.ts
View file @
8d1eb887
...
@@ -36,9 +36,9 @@ import {
...
@@ -36,9 +36,9 @@ import {
description
!
:
string
description
!
:
string
@
CreateDateColumn
({
name
:
'created_at'
,
type
:
Date
,
default
:
new
Date
()
})
@
CreateDateColumn
({
name
:
'created_at'
,
type
:
Date
,
default
:
new
Date
()
})
createdAt
!
:
Date
;
createdAt
!
:
Date
;
@
Column
({
name
:
'dateTimeStart'
,
type
:
'varchar'
,
nullable
:
true
})
@
Column
({
name
:
'dateTimeStart'
,
type
:
Date
,
nullable
:
true
})
dateTimeStart
!
:
Date
|
null
;
dateTimeStart
!
:
Date
|
null
;
@
Column
({
name
:
'dateTimeDue'
,
type
:
'varchar'
,
nullable
:
true
})
@
Column
({
name
:
'dateTimeDue'
,
type
:
Date
,
nullable
:
true
})
dateTimeDue
!
:
Date
|
null
;
dateTimeDue
!
:
Date
|
null
;
@
Column
({
@
Column
({
type
:
"enum"
,
type
:
"enum"
,
...
...
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
8d1eb887
import
{
FormControlLabel
,
Switch
}
from
"@mui/material"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
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"
;
import
CalendarTask
from
"./CalendarTask/CalendarTask"
;
import
CalendarTask
from
"./CalendarTask/CalendarTask"
;
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
onChangeCellTaskTitle
,
setCurrentTask
})
{
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'
,
'6:00'
])
const
[
hoursInDay
,
setHoursInDay
]
=
useState
([
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
,
'6:00'
])
const
[
daysInMonth
,
setDaysInMonth
]
=
useState
([])
const
[
daysInMonth
,
setDaysInMonth
]
=
useState
([])
const
[
cellSizes
,
setCellSizes
]
=
useState
({})
const
[
cellSizes
,
setCellSizes
]
=
useState
({})
useEffect
(()
=>
{
useEffect
(()
=>
{
const
cells
=
hoursInDay
.
length
const
cells
=
hoursInDay
.
length
const
xs
=
1
1
/
cells
const
xs
=
1
0.8
/
cells
setCellSizes
(()
=>
{
setCellSizes
(()
=>
{
return
{
smallCell
:
0.
5
,
standarCell
:
xs
}
return
{
smallCell
:
0.
6
,
standarCell
:
xs
}
})
})
},
[])
},
[])
useEffect
(()
=>
{
if
(
hourFormat
)
{
const
arr
=
[
'8:00'
,
'9:00'
,
'10:00'
,
'11:00'
,
'12:00'
,
'13:00'
,
'14:00'
,
'15:00'
,
'17:00'
,
'18:00'
,
'19:00'
,
'20:00'
,
'21:00'
,
'22:00'
,
'23:00'
,
'7:00'
]
const
cells
=
arr
.
length
const
xs
=
10.8
/
cells
setCellSizes
(()
=>
{
return
{
smallCell
:
0.6
,
standarCell
:
xs
}
})
setHoursInDay
(()
=>
arr
)
}
else
{
const
arr
=
[
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
,
'24:00'
,
'7:00'
]
const
cells
=
arr
.
length
const
xs
=
10.8
/
cells
setCellSizes
(()
=>
{
return
{
smallCell
:
0.6
,
standarCell
:
xs
}
})
setHoursInDay
(()
=>
arr
)
}
},
[
hourFormat
])
useEffect
(()
=>
{
useEffect
(()
=>
{
setNewMonthDays
()
setNewMonthDays
()
},
[
month
])
},
[
month
])
...
@@ -46,9 +66,14 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang
...
@@ -46,9 +66,14 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, onChang
return
(
return
(
<>
<>
<
CalendarRow
<
CalendarRow
>
>
<
CalendarSmallCell
xs
=
{
cellSizes
.
smallCell
}
/
>
<
CalendarSmallCell
xs
=
{
1.2
}
>
<
CalendarSmallCell
xs
=
{
cellSizes
.
smallCell
}
/
>
<
FormControlLabel
control
=
{
<
Switch
color
=
"primary"
checked
=
{
hourFormat
}
onChange
=
{()
=>
{
setHourFormat
(()
=>!
hourFormat
)}}
/>
}
label
=
"1 час"
labelPlacement
=
"end"
/>
<
/CalendarSmallCell
>
{
hoursInDay
.
map
((
hours
,
i
)
=>
{
{
hoursInDay
.
map
((
hours
,
i
)
=>
{
return
(
return
(
<
CalendarStandartCell
key
=
{
i
}
xs
=
{
cellSizes
.
standarCell
}
>
<
CalendarStandartCell
key
=
{
i
}
xs
=
{
cellSizes
.
standarCell
}
>
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
8d1eb887
...
@@ -9,6 +9,7 @@ function MonthCalendar() {
...
@@ -9,6 +9,7 @@ function MonthCalendar() {
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
const
{
tasks
}
=
useSelector
(
state
=>
state
.
tasks
);
const
{
tasks
}
=
useSelector
(
state
=>
state
.
tasks
);
const
[
hourFormat
,
setHourFormat
]
=
useState
(
false
);
const
[
month
,
setMonth
]
=
useState
(
''
)
const
[
month
,
setMonth
]
=
useState
(
''
)
const
[
year
,
setYear
]
=
useState
(
''
)
const
[
year
,
setYear
]
=
useState
(
''
)
const
[
worker
,
setWorker
]
=
useState
(
''
);
const
[
worker
,
setWorker
]
=
useState
(
''
);
...
@@ -53,18 +54,29 @@ function MonthCalendar() {
...
@@ -53,18 +54,29 @@ function MonthCalendar() {
})
})
}
}
function
dateToISOButLocal
(
date
)
{
function
dateToISOLikeButLocal
(
date
)
{
return
date
.
toLocaleString
(
'sv'
).
replace
(
' '
,
'T'
);
const
offsetMs
=
date
.
getTimezoneOffset
()
*
60
*
1000
;
}
const
msLocal
=
date
.
getTime
()
-
offsetMs
;
const
dateLocal
=
new
Date
(
msLocal
);
const
iso
=
dateLocal
.
toISOString
();
return
iso
;
}
const
createTaskInCellHandler
=
(
dayNumber
,
dayHour
)
=>
{
const
createTaskInCellHandler
=
(
dayNumber
,
dayHour
)
=>
{
const
hour
=
parseInt
(
dayHour
.
split
(
':'
)[
0
])
const
hour
=
parseInt
(
dayHour
.
split
(
':'
)[
0
])
let
hourDue
if
(
hourFormat
)
{
hourDue
=
hour
+
1
}
else
{
hourDue
=
hour
+
2
}
const
newTask
=
{
const
newTask
=
{
title
:
"Задача"
,
title
:
"Задача"
,
description
:
"описание"
,
description
:
"описание"
,
dateTimeStart
:
dateToISOButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
)),
dateTimeStart
:
dateToISO
Like
ButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
)),
dateTimeDue
:
dateToISO
ButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
+
2
)),
dateTimeDue
:
dateToISO
LikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hourDue
)),
}
}
console
.
log
(
newTask
)
dispatch
(
addTask
(
newTask
))
dispatch
(
addTask
(
newTask
))
setCurrentTask
((
newTask
))
setCurrentTask
((
newTask
))
}
}
...
@@ -97,6 +109,8 @@ function MonthCalendar() {
...
@@ -97,6 +109,8 @@ function MonthCalendar() {
createTaskInCellHandler
=
{
createTaskInCellHandler
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
onChangeCellTaskTitle
=
{
onChangeCellTaskTitle
}
onChangeCellTaskTitle
=
{
onChangeCellTaskTitle
}
setCurrentTask
=
{
setCurrentTask
}
setCurrentTask
=
{
setCurrentTask
}
hourFormat
=
{
hourFormat
}
setHourFormat
=
{
setHourFormat
}
/
>
/
>
<
/Container
>
<
/Container
>
<
/
>
<
/
>
...
...
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