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
346a5a8c
Commit
346a5a8c
authored
Nov 30, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#78
Небольшие фиксы\
parent
6ab13d0f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
42 deletions
+45
-42
copyTasks.ts
planner-api/src/routers/copyTasks.ts
+19
-20
CalendarStandartCell.js
...endarBody/CalendarStandartCell.js/CalendarStandartCell.js
+1
-1
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+13
-9
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+11
-12
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+1
-0
No files found.
planner-api/src/routers/copyTasks.ts
View file @
346a5a8c
...
...
@@ -28,25 +28,21 @@ const taskFinderById = async (taskId:string):Promise<null | Task>=>{
}
/** make copy of task in calendar view */
router
.
post
(
"/make-copy"
,
authAuthorOrExecutorOfTask
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
executorStatus
,
taskId
,
start
,
due
}
=
req
.
body
if
(
executorStatus
){
router
.
post
(
"/make-copy"
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
taskId
,
dateTimeDue
,
dateTimeStart
}
=
req
.
body
const
newDateTimeTask
=
new
DateTimeTask
();
newDateTimeTask
.
dateTimeStart
=
s
tart
newDateTimeTask
.
dateTimeDue
=
d
ue
newDateTimeTask
.
dateTimeStart
=
dateTimeS
tart
newDateTimeTask
.
dateTimeDue
=
dateTimeD
ue
newDateTimeTask
.
task
=
taskId
await
newDateTimeTask
.
save
()
const
task
=
taskFinderById
(
taskId
)
return
res
.
send
({
task
})
}
return
res
.
send
({
message
:
"Something wrong in make-copy router"
})
}
)
/** change date time of copy of task in calendar view */
router
.
put
(
"/change-copy"
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
console
.
log
(
'change'
)
const
{
dateTimeTaskId
,
taskId
,
dateTimeStart
,
dateTimeDue
}
=
req
.
body
console
.
log
(
req
.
body
)
router
.
put
(
"/change-copy"
,
authAuthorOrExecutorOfTask
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
dateTimeTaskId
,
taskId
,
dateTimeStart
,
dateTimeDue
,
description
,
title
,
priority
}
=
req
.
body
const
dateTimeTask
=
await
dataSource
.
createQueryBuilder
()
.
select
(
'dateTimeTask'
)
...
...
@@ -56,11 +52,14 @@ router.put("/change-copy", async(req:Request, res: Response):Promise<Response>=>
if
(
!
dateTimeTask
)
return
res
.
send
({
message
:
"such dateTimeTask does not exists"
})
dateTimeTask
.
dateTimeStart
=
dateTimeStart
dateTimeTask
.
dateTimeDue
=
dateTimeDue
console
.
log
(
dateTimeTask
)
await
dateTimeTask
.
save
()
const
task
=
taskFinderById
(
taskId
)
const
task
=
await
taskFinderById
(
taskId
)
if
(
!
task
)
return
res
.
status
(
404
).
send
({
Message
:
'task not found'
})
task
.
title
=
title
;
task
.
description
=
description
;
task
.
priority
=
priority
;
await
task
.
save
()
return
res
.
send
({
task
})
})
export
default
router
;
planner-front/src/components/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell.js
View file @
346a5a8c
...
...
@@ -8,7 +8,7 @@ const CalendarStandartCell = ({children, xs, hours, dayNumber, createTaskInCell
const
[
isThisCell
,
setIsThisCell
]
=
useState
(
false
)
const
cellClass
=
{
position
:
'relative'
,
height
:
linesInDay
?.
length
?
`
${
40
*
linesInDay
.
length
+
35
}
px`
:
`
${
35
+
35
}
px`
,
height
:
linesInDay
?.
length
?
`
${
40
*
linesInDay
.
length
+
35
}
px`
:
`
${
35
}
px`
,
borderRight
:
'1px solid black'
,
}
useEffect
(()
=>
{
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
346a5a8c
...
...
@@ -3,7 +3,7 @@ import { useDispatch, useSelector } from 'react-redux';
import
MonthCalendarBody
from
'../../components/MonthCalendarBody/MonthCalendarBody'
;
import
MonthCalendarHeader
from
'../../components/MonthCalendarHeader/MonthCalendarHeader'
;
import
{
dateToISOLikeButLocal
,
getCurrentMonthString
,
getDaysInMonth
}
from
'../../helpers/CalendarHelpers'
;
import
{
addCalendarTask
,
deleteCalendarTask
,
editCalendarTask
,
fetchCalendarTasks
}
from
'../../store/actions/tasksActions'
;
import
{
addCalendarTask
,
addCopyCalendarTask
,
deleteCalendarTask
,
editCalendarTask
,
fetchCalendarTasks
}
from
'../../store/actions/tasksActions'
;
function
MonthCalendar
()
{
const
dispatch
=
useDispatch
();
...
...
@@ -65,7 +65,6 @@ function MonthCalendar() {
return
{...
prevState
,
month
:
prevState
.
month
+
1
}
})
},
[])
console
.
log
(
currentTask
)
const
decrementMonth
=
useCallback
(()
=>
{
setDateNow
((
prevState
)
=>
{
if
(
prevState
.
month
-
1
===
-
1
)
{
...
...
@@ -135,13 +134,15 @@ function MonthCalendar() {
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
new
Obj
=
{
const
new
Task
=
{
...
currentTask
,
dateTimeTaskId
:
currentTask
.
id
,
dateTimeStart
:
start
,
dateTimeDue
:
due
}
delete
newObj
.
infoForCell
await
dispatch
(
editCalendarTask
(
newObj
))
delete
newTask
.
id
delete
newTask
.
infoForCell
await
dispatch
(
editCalendarTask
(
newTask
))
setCurrentTask
({})
}
...
...
@@ -153,18 +154,20 @@ function MonthCalendar() {
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
day
,
timeStartHour
,
0
))
const
newTask
=
{
...
currentTask
,
dateTimeTaskId
:
currentTask
.
id
,
dateTimeStart
:
start
,
dateTimeDue
:
due
dateTimeDue
:
due
,
dateTimeTaskId
:
currentTask
.
id
,
taskId
:
currentTask
.
mainTaskId
}
delete
newTask
.
id
delete
newTask
.
infoForCell
delete
newTask
.
id
if
(
newTask
.
dateTimeTaskId
)
{
await
dispatch
(
editCalendarTask
(
newTask
))
}
else
{
await
dispatch
(
addCalendarTask
(
newTask
))
}
}
console
.
log
(
currentTask
)
const
createCopyTask
=
async
(
dayNumber
,
hour
)
=>
{
const
hourDiff
=
copyTask
.
infoForCell
.
endHour
-
copyTask
.
infoForCell
.
startHour
...
...
@@ -180,10 +183,11 @@ function MonthCalendar() {
...
copyTask
,
dateTimeStart
:
start
,
dateTimeDue
:
due
,
taskId
:
copyTask
.
mainTaskId
}
delete
newTask
.
infoForCell
delete
newTask
.
id
await
dispatch
(
addCalendarTask
(
newTask
))
await
dispatch
(
addC
opyC
alendarTask
(
newTask
))
setCopyTask
(
null
)
}
...
...
planner-front/src/store/actions/tasksActions.js
View file @
346a5a8c
...
...
@@ -71,33 +71,32 @@ const addTaskFailure = (error) => {
};
export
const
addCalendarTask
=
(
task
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
addTaskRequest
());
try
{
const
response
=
await
axios
.
post
(
"/tasks"
,
task
);
dispatch
(
addTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
console
.
log
(
response
.
data
)
}
catch
(
error
)
{
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
}
}
export
const
addTask
=
(
task
)
=>
{
export
const
add
CopyCalendar
Task
=
(
task
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
addTaskRequest
());
try
{
await
axios
.
post
(
"/tasks
"
,
task
);
const
response
=
await
axios
.
post
(
"/copy-tasks/make-copy
"
,
task
);
dispatch
(
addTaskSuccess
())
dispatch
(
fetch
All
Tasks
())
dispatch
(
fetch
Calendar
Tasks
())
}
catch
(
error
)
{
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
}
}
export
const
add
Copy
Task
=
(
task
)
=>
{
export
const
addTask
=
(
task
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
addTaskRequest
());
try
{
...
...
@@ -123,10 +122,10 @@ const editTaskFailure = (error) => {
};
export
const
editTask
=
(
task
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
editTaskRequest
());
try
{
await
axios
.
put
(
"/
change-copy
"
,
task
);
await
axios
.
put
(
"/
tasks
"
,
task
);
dispatch
(
editTaskSuccess
())
dispatch
(
fetchAllTasks
())
}
catch
(
error
)
{
...
...
@@ -136,7 +135,7 @@ export const editTask = (task) => {
}
export
const
editCalendarTask
=
(
task
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
editTaskRequest
());
try
{
await
axios
.
put
(
"/copy-tasks/change-copy"
,
task
);
...
...
@@ -161,7 +160,7 @@ const deleteTaskFailure = (error) => {
};
export
const
deleteTask
=
(
taskId
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
deleteTaskRequest
());
try
{
await
axios
.
delete
(
`/tasks/
${
taskId
}
`
);
...
...
@@ -174,10 +173,10 @@ export const deleteTask = (taskId) => {
}
export
const
deleteCalendarTask
=
(
taskId
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
deleteTaskRequest
());
try
{
await
axios
.
delete
(
`/tasks/
${
taskId
}
`
);
await
axios
.
delete
(
`/
copy-
tasks/
${
taskId
}
`
);
dispatch
(
deleteTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
}
catch
(
error
)
{
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
346a5a8c
...
...
@@ -35,6 +35,7 @@ const tasksReduсer = (state = initialState, action) => {
for
(
let
copy
of
task
.
dateTimeTasks
)
{
newTasksWithoutInfoForCell
.
push
({
...
copy
,
mainTaskId
:
task
.
id
,
executor
:
task
.
executor
,
author
:
task
.
author
,
priority
:
task
.
priority
,
...
...
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