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
Show 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";
...
@@ -2,7 +2,7 @@ import { myDataSource } from "./app-data-source";
import
{
User
,
UserRole
}
from
"./models/User"
;
import
{
User
,
UserRole
}
from
"./models/User"
;
import
{
faker
}
from
'@faker-js/faker'
;
import
{
faker
}
from
'@faker-js/faker'
;
import
{
Task
}
from
"./models/Task"
;
import
{
priorityType
,
Task
,
taskFinishType
}
from
"./models/Task"
;
import
{
Project
}
from
"./models/Project"
;
import
{
Project
}
from
"./models/Project"
;
import
{
Member
,
MemberRole
}
from
"./models/Member"
;
import
{
Member
,
MemberRole
}
from
"./models/Member"
;
...
@@ -45,10 +45,8 @@ const loadFixtures = async () => {
...
@@ -45,10 +45,8 @@ const loadFixtures = async () => {
}
}
const
tasks
:
Task
[]
=
[]
const
tasks
:
Task
[]
=
[]
type
taskFinishType
=
"opened"
|
"done"
|
"failed"
;
type
priorityType
=
"A"
|
"B"
|
"C"
;
const
priorities
:
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
++
)
{
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
if
(
i
<=
15
)
{
if
(
i
<=
15
)
{
const
newTask
=
new
Task
();
const
newTask
=
new
Task
();
...
...
planner-api/src/models/Task.ts
View file @
db6eba31
...
@@ -13,8 +13,8 @@ import {
...
@@ -13,8 +13,8 @@ import {
import
{
Project
}
from
'./Project'
;
import
{
Project
}
from
'./Project'
;
import
{
DateTimeTask
}
from
'./DateTimeTask'
;
import
{
DateTimeTask
}
from
'./DateTimeTask'
;
type
taskFinishType
=
"opened"
|
"done"
|
"failed"
;
export
type
taskFinishType
=
"opened"
|
"in-progress"
|
"done"
|
"failed"
;
type
priorityType
=
"A"
|
"B"
|
"C"
;
export
type
priorityType
=
"A"
|
"B"
|
"C"
;
interface
ITask
{
interface
ITask
{
id
:
string
;
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>=>
...
@@ -184,7 +184,6 @@ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>
/**modification of task by task id */
/**modification of task by task id */
router
.
put
(
'/'
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
router
.
put
(
'/'
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
const
token
=
req
.
get
(
'Authorization'
);
const
token
=
req
.
get
(
'Authorization'
);
const
user
=
await
dataSource
const
user
=
await
dataSource
.
createQueryBuilder
()
.
createQueryBuilder
()
.
select
(
"user"
)
.
select
(
"user"
)
...
@@ -192,22 +191,31 @@ router.put('/',async(req:Request, res:Response)=> {
...
@@ -192,22 +191,31 @@ router.put('/',async(req:Request, res:Response)=> {
.
where
(
"user.token = :token"
,
{
token
:
token
})
.
where
(
"user.token = :token"
,
{
token
:
token
})
.
getOne
()
.
getOne
()
if
(
!
user
)
return
res
.
status
(
404
).
send
({
Message
:
'user not found'
})
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
const
task
=
await
dataSource
.
createQueryBuilder
()
.
createQueryBuilder
()
.
select
(
"task"
)
.
select
(
"task"
)
.
from
(
Task
,
"task"
)
.
from
(
Task
,
"task"
)
.
where
(
"task.id = :id"
,
{
id
})
.
where
(
"task.id = :id"
,
{
id
})
.
getOne
()
.
getOne
()
if
(
!
task
)
return
res
.
status
(
404
).
send
({
Message
:
'task not found'
})
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
.
title
=
title
task
.
description
=
description
task
.
description
=
description
task
.
project
=
project
task
.
project
=
project
task
.
dateTime
Due
=
dateTimeDue
task
.
dateTime
Tasks
=
dateTimeArray
;
task
.
dateTime
Start
=
dateTimeStart
task
.
dateTime
DeadLine
=
dateTimeDeadLine
;
task
.
author
=
user
task
.
author
=
user
// task.executors=executors
task
.
executor
=
executor
task
.
accomplish
=
accomplish
task
.
accomplish
=
accomplish
task
.
priority
=
priority
task
.
priority
=
priority
await
task
.
save
()
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