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
90a7ba1d
Commit
90a7ba1d
authored
Dec 12, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added personal project creation if project not given at all
parent
8f1aa7fe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
16 deletions
+60
-16
Project.ts
planner-api/src/models/Project.ts
+0
-4
copyTasks.ts
planner-api/src/routers/copyTasks.ts
+8
-11
tasks.ts
planner-api/src/routers/tasks.ts
+52
-1
No files found.
planner-api/src/models/Project.ts
View file @
90a7ba1d
...
...
@@ -4,12 +4,8 @@ import {
PrimaryGeneratedColumn
,
CreateDateColumn
,
BaseEntity
,
ManyToOne
,
ManyToMany
,
OneToMany
,
JoinTable
}
from
'typeorm'
;
// import {User} from './User';
import
{
Task
}
from
'./Task'
;
import
{
Member
}
from
'./Member'
;
...
...
planner-api/src/routers/copyTasks.ts
View file @
90a7ba1d
...
...
@@ -2,24 +2,21 @@ import express,{Router, Request, Response } from 'express';
import
{
Task
}
from
'../models/Task'
;
import
{
myDataSource
}
from
'../app-data-source'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
auth
,
authAuthorOrExecutorOfDateTimeTask
,
authAuthorOrExecutorOfTask
,
taskFinderById
}
from
'../helpers'
;
import
{
info
}
from
'console'
;
import
{
authAuthorOrExecutorOfDateTimeTask
,
authAuthorOrExecutorOfTask
}
from
'../helpers'
;
const
router
:
Router
=
express
.
Router
();
const
dataSource
=
myDataSource
;
/** make copy of task in calendar view */
router
.
post
(
"/make-copy"
,
authAuthorOrExecutorOfTask
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
taskId
,
dateTimeDue
,
dateTimeStart
}
=
req
.
body
;
const
task
=
await
taskFinderById
(
taskId
);
const
{
taskId
,
dateTimeDue
,
dateTimeStart
,
authorStatus
,
executorStatus
,
task
}
=
req
.
body
;
if
(
!
task
)
return
res
.
status
(
401
).
send
({
message
:
'task with possible user involved is not found'
})
const
newDateTimeTask
=
new
DateTimeTask
();
newDateTimeTask
.
dateTimeStart
=
dateTimeStart
;
newDateTimeTask
.
dateTimeDue
=
dateTimeDue
;
newDateTimeTask
.
task
=
taskId
;
await
newDateTimeTask
.
save
();
return
res
.
send
({
task
})
const
newDateTimeTask
=
new
DateTimeTask
();
newDateTimeTask
.
dateTimeStart
=
dateTimeStart
;
newDateTimeTask
.
dateTimeDue
=
dateTimeDue
;
newDateTimeTask
.
task
=
taskId
;
await
newDateTimeTask
.
save
();
return
res
.
send
({
task
,
message
:
"copyTask created!"
})
}
)
/** change date time of copy of task in calendar view */
...
...
planner-api/src/routers/tasks.ts
View file @
90a7ba1d
...
...
@@ -2,10 +2,11 @@ import express,{Router, Request, Response } from 'express';
import
{
Task
}
from
'../models/Task'
;
import
{
myDataSource
}
from
'../app-data-source'
;
import
{
User
}
from
'../models/User'
;
import
{
Member
}
from
'../models/Member'
;
import
{
Member
,
MemberRole
}
from
'../models/Member'
;
import
{
In
}
from
'typeorm'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
auth
,
authAuthorOrExecutorOfTask
,
taskFinderById
}
from
'../helpers'
;
import
{
Project
}
from
'../models/Project'
;
const
router
:
Router
=
express
.
Router
();
const
dataSource
=
myDataSource
;
...
...
@@ -29,7 +30,57 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
const
newTask
=
new
Task
();
newTask
.
title
=
title
;
newTask
.
description
=
description
;
if
(
project
)
{
const
watcherOfProject
=
await
dataSource
.
getRepository
(
Project
)
.
findOne
({
relations
:{
members
:
true
,
},
where
:
{
id
:
project
.
id
,
members
:
{
user
:{
id
:
user
.
id
},
roleProject
:
MemberRole
.
WATCHER
,
},
}
})
console
.
log
(
'watcherOfProject '
,
watcherOfProject
)
if
(
watcherOfProject
)
return
res
.
send
({
message
:
"watcher could nt make tasks"
})
newTask
.
project
=
project
;
}
else
{
const
personalProject
=
await
dataSource
.
getRepository
(
Project
)
.
findOne
({
where
:{
members
:{
user
:{
id
:
user
.
id
},
},
title
:
"Личные дела"
}
})
if
(
personalProject
){
newTask
.
project
=
personalProject
;
}
else
{
const
newPersonalProject
=
new
Project
();
newPersonalProject
.
title
=
"Личные дела"
;
newPersonalProject
.
color
=
"green"
;
await
newPersonalProject
.
save
()
newTask
.
project
=
newPersonalProject
;
const
newMember
=
new
Member
();
newMember
.
user
=
user
;
newMember
.
project
=
newPersonalProject
;
newMember
.
roleProject
=
MemberRole
.
ADMIN
;
await
newMember
.
save
();
console
.
log
(
'newPersonalProject '
,
newPersonalProject
)
}
}
newTask
.
dateTimeDeadLine
=
dateTimeDeadLine
;
newTask
.
author
=
user
;
newTask
.
executor
=
executor
;
...
...
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