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
db6eba31
Commit
db6eba31
authored
Nov 26, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#68
inplement dateTimeTask approach in put request for task edit
parent
a1c61e19
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
12 deletions
+18
-12
fixtures.ts
planner-api/src/fixtures.ts
+2
-4
Task.ts
planner-api/src/models/Task.ts
+2
-2
tasks.ts
planner-api/src/routers/tasks.ts
+14
-6
No files found.
planner-api/src/fixtures.ts
View file @
db6eba31
...
...
@@ -2,7 +2,7 @@ import { myDataSource } from "./app-data-source";
import
{
User
,
UserRole
}
from
"./models/User"
;
import
{
faker
}
from
'@faker-js/faker'
;
import
{
Task
}
from
"./models/Task"
;
import
{
priorityType
,
Task
,
taskFinishType
}
from
"./models/Task"
;
import
{
Project
}
from
"./models/Project"
;
import
{
Member
,
MemberRole
}
from
"./models/Member"
;
...
...
@@ -45,10 +45,8 @@ const loadFixtures = async () => {
}
const
tasks
:
Task
[]
=
[]
type
taskFinishType
=
"opened"
|
"done"
|
"failed"
;
type
priorityType
=
"A"
|
"B"
|
"C"
;
const
priorities
:
priorityType
[]
=
[
"A"
,
"B"
,
"C"
]
const
accomplish
:
taskFinishType
[]
=
[
"opened"
,
"done"
,
"failed"
]
const
accomplish
:
taskFinishType
[]
=
[
"opened"
,
"in-progress"
,
"done"
,
"failed"
]
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
if
(
i
<=
15
)
{
const
newTask
=
new
Task
();
...
...
planner-api/src/models/Task.ts
View file @
db6eba31
...
...
@@ -13,8 +13,8 @@ import {
import
{
Project
}
from
'./Project'
;
import
{
DateTimeTask
}
from
'./DateTimeTask'
;
type
taskFinishType
=
"opened"
|
"done"
|
"failed"
;
type
priorityType
=
"A"
|
"B"
|
"C"
;
export
type
taskFinishType
=
"opened"
|
"in-progress"
|
"done"
|
"failed"
;
export
type
priorityType
=
"A"
|
"B"
|
"C"
;
interface
ITask
{
id
:
string
;
...
...
planner-api/src/routers/tasks.ts
View file @
db6eba31
...
...
@@ -184,7 +184,6 @@ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>
/**modification of task by task id */
router
.
put
(
'/'
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
const
token
=
req
.
get
(
'Authorization'
);
const
user
=
await
dataSource
.
createQueryBuilder
()
.
select
(
"user"
)
...
...
@@ -192,22 +191,31 @@ router.put('/',async(req:Request, res:Response)=> {
.
where
(
"user.token = :token"
,
{
token
:
token
})
.
getOne
()
if
(
!
user
)
return
res
.
status
(
404
).
send
({
Message
:
'user not found'
})
const
{
id
,
title
,
description
,
project
,
dateTime
Due
,
dateTimeStart
,
executors
,
accomplish
,
priority
}
=
req
.
body
;
const
{
id
,
title
,
description
,
project
,
dateTime
TaskArray
,
executor
,
accomplish
,
dateTimeDeadLine
,
priority
}
=
req
.
body
;
const
task
=
await
dataSource
.
createQueryBuilder
()
.
select
(
"task"
)
.
from
(
Task
,
"task"
)
.
where
(
"task.id = :id"
,
{
id
})
.
getOne
()
if
(
!
task
)
return
res
.
status
(
404
).
send
({
Message
:
'task not found'
})
const
dateTimeArray
=
[];
if
(
dateTimeTaskArray
&&
dateTimeTaskArray
.
length
>
0
){
for
(
let
dateTimeStartDue
of
dateTimeTaskArray
){
const
newDateTimeTask
=
new
DateTimeTask
();
newDateTimeTask
.
dateTimeStart
=
dateTimeStartDue
.
dateTimeStart
;
newDateTimeTask
.
dateTimeDue
=
dateTimeStartDue
.
dateTimeDue
;
await
newDateTimeTask
.
save
();
dateTimeArray
.
push
(
newDateTimeTask
);
}
}
task
.
title
=
title
task
.
description
=
description
task
.
project
=
project
task
.
dateTime
Due
=
dateTimeDue
task
.
dateTime
Start
=
dateTimeStart
task
.
dateTime
Tasks
=
dateTimeArray
;
task
.
dateTime
DeadLine
=
dateTimeDeadLine
;
task
.
author
=
user
// task.executors=executors
task
.
executor
=
executor
task
.
accomplish
=
accomplish
task
.
priority
=
priority
await
task
.
save
()
...
...
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