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
923dc0c1
Commit
923dc0c1
authored
Nov 29, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#78
Реализовал отображение и редактирования времени задач
parent
ef9b5054
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
55 deletions
+89
-55
helpers.ts
planner-api/src/helpers.ts
+0
-1
copyTasks.ts
planner-api/src/routers/copyTasks.ts
+18
-17
tasks.ts
planner-api/src/routers/tasks.ts
+7
-2
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+3
-1
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+18
-4
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+43
-30
No files found.
planner-api/src/helpers.ts
View file @
923dc0c1
...
...
@@ -27,7 +27,6 @@ export const authAuthorOrExecutorOfTask = async(req: Request,res: Response, next
if
(
!
token
)
return
res
.
status
(
401
).
send
({
Message
:
'token not exists'
})
req
.
body
=
{...
req
.
body
,
executorStatus
:
false
}
req
.
body
=
{...
req
.
body
,
authorStatus
:
false
}
const
executor
=
await
dataSource
.
createQueryBuilder
()
.
select
(
"user"
)
...
...
planner-api/src/routers/copyTasks.ts
View file @
923dc0c1
...
...
@@ -43,23 +43,24 @@ router.post("/make-copy",authAuthorOrExecutorOfTask, async(req:Request, res:Resp
}
)
/** change date time of copy of task in calendar view */
router
.
put
(
"change-copy"
,
authAuthorOrExecutorOfTask
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
executorStatus
,
dateTimeTaskId
,
taskId
,
start
,
due
}
=
req
.
body
if
(
executorStatus
){
const
dateTimeTask
=
await
dataSource
.
createQueryBuilder
()
.
select
(
'dateTikeTask'
)
.
from
(
DateTimeTask
,
'dateTimeTask'
)
.
where
(
"dateTimeTask.id = :dateTimeTaskId"
,{
dateTimeTaskId
})
.
getOne
()
if
(
!
dateTimeTask
)
return
res
.
send
({
message
:
"such dateTimeTask does not exists"
})
dateTimeTask
.
dateTimeStart
=
start
dateTimeTask
.
dateTimeDue
=
due
await
dateTimeTask
.
save
()
const
task
=
taskFinderById
(
taskId
)
return
res
.
send
({
task
})
}
return
res
.
send
({
message
:
"Something wrong in make-copy router"
})
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
)
const
dateTimeTask
=
await
dataSource
.
createQueryBuilder
()
.
select
(
'dateTimeTask'
)
.
from
(
DateTimeTask
,
'dateTimeTask'
)
.
where
(
"dateTimeTask.id = :dateTimeTaskId"
,{
dateTimeTaskId
})
.
getOne
()
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
)
return
res
.
send
({
task
})
})
export
default
router
;
planner-api/src/routers/tasks.ts
View file @
923dc0c1
...
...
@@ -25,7 +25,7 @@ router.get('/', async(req:Request, res:Response):Promise<Response> => {
/**create new task */
router
.
post
(
'/'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
user
,
title
,
description
,
project
,
executor
,
dateTimeDeadLine
,
priority
}
=
req
.
body
;
const
{
user
,
title
,
description
,
project
,
executor
,
dateTimeDeadLine
,
priority
,
dateTimeStart
,
dateTimeDue
}
=
req
.
body
;
const
newTask
=
new
Task
();
newTask
.
title
=
title
;
newTask
.
description
=
description
;
...
...
@@ -34,7 +34,12 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
newTask
.
author
=
user
;
newTask
.
executor
=
executor
;
newTask
.
priority
=
priority
;
await
newTask
.
save
();
await
newTask
.
save
();
const
newDateTimeTask
=
new
DateTimeTask
();
newDateTimeTask
.
dateTimeStart
=
dateTimeStart
newDateTimeTask
.
dateTimeDue
=
dateTimeDue
newDateTimeTask
.
task
=
newTask
await
newDateTimeTask
.
save
()
return
res
.
send
({
newTask
});
})
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
923dc0c1
...
...
@@ -153,11 +153,13 @@ function MonthCalendar() {
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
day
,
timeStartHour
,
0
))
const
newTask
=
{
...
currentTask
,
dateTimeTaskId
:
currentTask
.
id
,
dateTimeStart
:
start
,
dateTimeDue
:
due
}
delete
newTask
.
id
delete
newTask
.
infoForCell
if
(
currentTask
.
i
d
)
{
if
(
newTask
.
dateTimeTaskI
d
)
{
await
dispatch
(
editCalendarTask
(
newTask
))
}
else
{
await
dispatch
(
addCalendarTask
(
newTask
))
...
...
planner-front/src/store/actions/tasksActions.js
View file @
923dc0c1
...
...
@@ -74,9 +74,10 @@ export const addCalendarTask = (task) => {
return
async
(
dispatch
,
getState
)
=>
{
dispatch
(
addTaskRequest
());
try
{
await
axios
.
post
(
"/tasks"
,
task
);
const
response
=
await
axios
.
post
(
"/tasks"
,
task
);
dispatch
(
addTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
console
.
log
(
response
.
data
)
}
catch
(
error
)
{
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
...
...
@@ -84,7 +85,20 @@ export const addCalendarTask = (task) => {
}
export
const
addTask
=
(
task
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
addTaskRequest
());
try
{
await
axios
.
post
(
"/tasks"
,
task
);
dispatch
(
addTaskSuccess
())
dispatch
(
fetchAllTasks
())
}
catch
(
error
)
{
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
}
}
export
const
addCopyTask
=
(
task
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
addTaskRequest
());
try
{
await
axios
.
post
(
"/tasks"
,
task
);
...
...
@@ -112,7 +126,7 @@ export const editTask = (task) => {
return
async
(
dispatch
,
getState
)
=>
{
dispatch
(
editTaskRequest
());
try
{
await
axios
.
put
(
"/
tasks
"
,
task
);
await
axios
.
put
(
"/
change-copy
"
,
task
);
dispatch
(
editTaskSuccess
())
dispatch
(
fetchAllTasks
())
}
catch
(
error
)
{
...
...
@@ -125,7 +139,7 @@ export const editCalendarTask = (task) => {
return
async
(
dispatch
,
getState
)
=>
{
dispatch
(
editTaskRequest
());
try
{
await
axios
.
put
(
"/
tasks
"
,
task
);
await
axios
.
put
(
"/
copy-tasks/change-copy
"
,
task
);
dispatch
(
editTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
}
catch
(
error
)
{
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
923dc0c1
...
...
@@ -29,37 +29,50 @@ const tasksReduсer = (state = initialState, action) => {
case
FETCH_CALENDAR_TASKS_REQUEST
:
return
{...
state
,
loading
:
true
};
case
FETCH_CALENDAR_TASKS_SUCCESS
:
const
newArr
=
[]
action
.
tasks
.
forEach
((
task
)
=>
{
if
(
task
.
dateTimeStart
&&
task
.
dateTimeDue
)
{
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
timeStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
1
]
const
timeEnd
=
task
.
dateTimeDue
.
split
(
'T'
)[
1
]
const
dayStart
=
parseInt
(
dateStart
.
split
(
'-'
)[
2
])
const
monthStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
1
])
const
yearStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
0
])
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
const
timeEndHour
=
parseInt
(
timeEnd
.
split
(
':'
)[
0
])
const
timeStartMinute
=
parseInt
(
timeStart
.
split
(
':'
)[
1
])
const
timeEndMinute
=
parseInt
(
timeEnd
.
split
(
':'
)[
1
])
const
newObj
=
{...
task
,
infoForCell
:
{
startDay
:
dayStart
,
startHour
:
timeStartHour
,
startMonth
:
monthStartNumber
,
startYear
:
yearStartNumber
,
startMinute
:
timeStartMinute
,
endHour
:
timeEndHour
,
endMinute
:
timeEndMinute
,
}
}
newArr
.
push
(
newObj
)
}
}
const
newTasksWithoutInfoForCell
=
[]
const
newTasksWithInfoForCell
=
[]
for
(
let
task
of
action
.
tasks
)
{
for
(
let
copy
of
task
.
dateTimeTasks
)
{
newTasksWithoutInfoForCell
.
push
({
...
copy
,
executor
:
task
.
executor
,
author
:
task
.
author
,
priority
:
task
.
priority
,
title
:
task
.
title
,
description
:
task
.
description
})
return
{...
state
,
loading
:
false
,
calendarTasks
:
newArr
};
}
}
newTasksWithoutInfoForCell
.
forEach
((
task
)
=>
{
if
(
task
.
dateTimeStart
&&
task
.
dateTimeDue
)
{
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
timeStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
1
]
const
timeEnd
=
task
.
dateTimeDue
.
split
(
'T'
)[
1
]
const
dayStart
=
parseInt
(
dateStart
.
split
(
'-'
)[
2
])
const
monthStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
1
])
const
yearStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
0
])
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
const
timeEndHour
=
parseInt
(
timeEnd
.
split
(
':'
)[
0
])
const
timeStartMinute
=
parseInt
(
timeStart
.
split
(
':'
)[
1
])
const
timeEndMinute
=
parseInt
(
timeEnd
.
split
(
':'
)[
1
])
const
newObj
=
{...
task
,
infoForCell
:
{
startDay
:
dayStart
,
startHour
:
timeStartHour
,
startMonth
:
monthStartNumber
,
startYear
:
yearStartNumber
,
startMinute
:
timeStartMinute
,
endHour
:
timeEndHour
,
endMinute
:
timeEndMinute
,
}
}
newTasksWithInfoForCell
.
push
(
newObj
)
}
}
})
return
{...
state
,
loading
:
false
,
calendarTasks
:
newTasksWithInfoForCell
};
case
FETCH_ALL_TASKS_SUCCESS
:
return
{...
state
,
loading
:
false
,
tasks
:
action
.
tasks
};
case
FETCH_CALENDAR_TASKS_FAILURE
:
...
...
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