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
c79bfce2
Commit
c79bfce2
authored
Dec 17, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#110
added setup on non watcher users in user-task request
parent
0f1d3b06
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
34 deletions
+49
-34
tasks.ts
planner-api/src/routers/tasks.ts
+20
-6
UsersTasks.js
planner-front/src/containers/UsersTasks/UsersTasks.js
+22
-20
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+3
-7
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+4
-1
No files found.
planner-api/src/routers/tasks.ts
View file @
c79bfce2
...
@@ -3,7 +3,7 @@ import {Task} from '../models/Task';
...
@@ -3,7 +3,7 @@ import {Task} from '../models/Task';
import
{
myDataSource
}
from
'../app-data-source'
;
import
{
myDataSource
}
from
'../app-data-source'
;
import
{
User
}
from
'../models/User'
;
import
{
User
}
from
'../models/User'
;
import
{
Member
,
MemberRole
}
from
'../models/Member'
;
import
{
Member
,
MemberRole
}
from
'../models/Member'
;
import
{
In
}
from
'typeorm'
;
import
{
In
,
Not
}
from
'typeorm'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
auth
,
authAuthorOrExecutorOfTask
,
taskFinderById
}
from
'../helpers'
;
import
{
auth
,
authAuthorOrExecutorOfTask
,
taskFinderById
}
from
'../helpers'
;
import
{
Project
}
from
'../models/Project'
;
import
{
Project
}
from
'../models/Project'
;
...
@@ -341,7 +341,7 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{
...
@@ -341,7 +341,7 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{
/**check other users tasks that are related to the user through common projects, by user token*/
/**check other users tasks that are related to the user through common projects, by user token*/
router
.
get
(
'/users-tasks'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
router
.
get
(
'/users-tasks'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
user
}
=
req
.
body
const
{
user
}
=
req
.
body
const
projects
=
await
dataSource
const
projects
WithTasks
=
await
dataSource
.
getRepository
(
Project
)
.
getRepository
(
Project
)
.
find
(
.
find
(
{
relations
:{
{
relations
:{
...
@@ -358,18 +358,32 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
...
@@ -358,18 +358,32 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
}
}
}
}
}})
}})
if
(
!
projects
)
return
res
.
status
(
404
).
send
({
Message
:
'projects not found'
})
if
(
!
projects
WithTasks
)
return
res
.
status
(
404
).
send
({
Message
:
'projects not found'
})
let
tasks
:
Task
[]
=
[]
let
tasks
:
Task
[]
=
[]
if
(
projects
.
length
>
0
)
{
if
(
projects
WithTasks
.
length
>
0
)
{
for
(
let
project
of
projects
){
for
(
let
project
of
projects
WithTasks
){
if
(
project
?.
tasks
)
{
if
(
project
?.
tasks
)
{
tasks
=
tasks
.
concat
(
project
.
tasks
)
tasks
=
tasks
.
concat
(
project
.
tasks
)
}
}
}
}
}
}
const
projectIds
=
projectsWithTasks
.
map
(
project
=>
{
if
(
project
.
title
!==
"Личные дела"
)
return
project
.
id
})
const
projects
=
await
dataSource
.
getRepository
(
Project
)
.
find
({
relations
:{
members
:{
user
:
true
}},
where
:{
id
:
In
(
projectIds
),
members
:{
roleProject
:
Not
(
MemberRole
.
WATCHER
)
}
},
})
return
res
.
send
({
projects
,
tasks
})
return
res
.
send
({
projects
,
tasks
})
})
})
...
...
planner-front/src/containers/UsersTasks/UsersTasks.js
View file @
c79bfce2
...
@@ -12,7 +12,7 @@ import { useDispatch, useSelector } from "react-redux";
...
@@ -12,7 +12,7 @@ import { useDispatch, useSelector } from "react-redux";
import
TaskModal
from
"../../components/UsersTasksCompoments/TaskModal/TaskModal"
;
import
TaskModal
from
"../../components/UsersTasksCompoments/TaskModal/TaskModal"
;
import
moment
from
"moment"
;
import
moment
from
"moment"
;
import
MyTaskToolBar
from
"../../components/UsersTasksCompoments/UsersTaskToolBar"
;
import
MyTaskToolBar
from
"../../components/UsersTasksCompoments/UsersTaskToolBar"
;
import
{
fetchAllTasks
,
deleteTask
,
editTask
,
deleteDateTimeTask
}
from
"../../store/actions/tasksActions"
;
import
{
fetchAllTasks
,
deleteTask
,
editTask
,
deleteDateTimeTask
,
fetchAllTasksByMembership
}
from
"../../store/actions/tasksActions"
;
import
NewTaskForm
from
"../../components/UsersTasksCompoments/NewTaskForm"
;
import
NewTaskForm
from
"../../components/UsersTasksCompoments/NewTaskForm"
;
import
TableRowTask
from
"../../components/UsersTasksCompoments/TableRowTask/TableRowTask"
;
import
TableRowTask
from
"../../components/UsersTasksCompoments/TableRowTask/TableRowTask"
;
import
UsersTasksHeader
from
"./UsersTasksHeader/UsersTasksHeader"
;
import
UsersTasksHeader
from
"./UsersTasksHeader/UsersTasksHeader"
;
...
@@ -23,9 +23,10 @@ export default function UsersTasks() {
...
@@ -23,9 +23,10 @@ export default function UsersTasks() {
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
const
tasks
=
useSelector
((
state
)
=>
state
.
tasks
.
tasks
);
const
tasks
=
useSelector
((
state
)
=>
state
.
tasks
.
tasks
);
const
projects
=
useSelector
((
state
)
=>
state
.
tasks
.
projects
);
const
user
=
useSelector
((
state
)
=>
state
.
users
.
user
);
const
user
=
useSelector
((
state
)
=>
state
.
users
.
user
);
const
[
executors
,
setExecutors
]
=
useState
([])
const
[
executors
,
setExecutors
]
=
useState
([])
const
[
projects
,
setProjects
]
=
useState
([])
const
[
currentProject
,
setCurrentProject
]
=
useState
(
null
);
const
[
currentProject
,
setCurrentProject
]
=
useState
(
null
);
const
[
recievedTasks
,
setRecievedTasks
]
=
useState
([]);
const
[
recievedTasks
,
setRecievedTasks
]
=
useState
([]);
const
[
addTaskForm
,
setAddTaskForm
]
=
useState
(
false
);
const
[
addTaskForm
,
setAddTaskForm
]
=
useState
(
false
);
...
@@ -40,15 +41,14 @@ export default function UsersTasks() {
...
@@ -40,15 +41,14 @@ export default function UsersTasks() {
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
fetchAllTasks
());
dispatch
(
fetchAllTasksByMembership
());
filterProjectsNamesFromTasks
()
if
(
tasks
&&
tasks
?.
length
>
0
)
{
if
(
tasks
&&
tasks
?.
length
>
0
)
{
setRecievedTasks
(
tasks
);
setRecievedTasks
(
tasks
);
}
}
},
[
dispatch
,
tasks
?.
length
]);
},
[
dispatch
,
tasks
?.
length
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
fetchAllTasks
());
dispatch
(
fetchAllTasks
ByMembership
());
},
[
addTaskForm
,
setAddTaskForm
]);
},
[
addTaskForm
,
setAddTaskForm
]);
...
@@ -112,7 +112,8 @@ useEffect(() => {
...
@@ -112,7 +112,8 @@ useEffect(() => {
const
onProjectChange
=
(
e
,
task
)
=>
{
const
onProjectChange
=
(
e
,
task
)
=>
{
const
projectId
=
e
.
target
.
value
;
const
projectId
=
e
.
target
.
value
;
const
project
=
uniqueProjects
.
find
((
uniqueProject
)
=>
uniqueProject
.
id
===
projectId
);
const
project
=
projects
.
find
((
uniqueProject
)
=>
uniqueProject
.
id
===
projectId
);
setCurrentProject
(
project
)
const
{
id
}
=
task
;
const
{
id
}
=
task
;
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
if
(
task
.
id
===
id
)
{
...
@@ -218,20 +219,20 @@ useEffect(() => {
...
@@ -218,20 +219,20 @@ useEffect(() => {
const
rawProjects
=
tasks
?.
map
(
task
=>
task
.
project
)
const
rawProjects
=
tasks
?.
map
(
task
=>
task
.
project
)
const
filterProjectsNamesFromTasks
=
()
=>
{
//
const filterProjectsNamesFromTasks = ()=>{
if
(
tasks
&&
tasks
?.
length
>
0
)
{
//
if (tasks && tasks?.length > 0) {
let
rawSetProjectNames
=
[]
//
let rawSetProjectNames = []
for
(
let
project
of
rawProjects
){
//
for (let project of rawProjects){
if
(
project
===
null
){
//
if (project===null){
}
else
{
//
} else{
rawSetProjectNames
.
push
(
project
.
title
)
//
rawSetProjectNames.push(project.title)
}
//
}
}
//
}
let
uniqueTitlesProjects
=
[...
new
Set
(
rawSetProjectNames
)];
//
let uniqueTitlesProjects = [...new Set(rawSetProjectNames)];
setProjects
(
uniqueTitlesProjects
)
//
setProjects(uniqueTitlesProjects)
}
//
}
}
//
}
const
uniqueProjects
=
rawProjects
?.
reduce
((
results
,
value
,
index
)
=>
{
const
uniqueProjects
=
rawProjects
?.
reduce
((
results
,
value
,
index
)
=>
{
const
exist
=
results
.
find
((
v
)
=>
{
const
exist
=
results
.
find
((
v
)
=>
{
...
@@ -265,7 +266,8 @@ console.log('tasks', tasks)
...
@@ -265,7 +266,8 @@ console.log('tasks', tasks)
{
addTaskForm
?
(
{
addTaskForm
?
(
<
NewTaskForm
<
NewTaskForm
projects
=
{
uniqueProjects
}
projects
=
{
projects
}
setCurrentProject
=
{
setCurrentProject
}
currentProject
=
{
currentProject
}
currentProject
=
{
currentProject
}
setAddTaskForm
=
{()
=>
setAddTaskForm
(
false
)}
setAddTaskForm
=
{()
=>
setAddTaskForm
(
false
)}
/
>
/
>
...
...
planner-front/src/store/actions/tasksActions.js
View file @
c79bfce2
...
@@ -18,6 +18,7 @@ import {
...
@@ -18,6 +18,7 @@ import {
DELETE_DATETIMETASK_FAILURE
,
DELETE_DATETIMETASK_FAILURE
,
DELETE_DATETIMETASK_SUCCESS
,
DELETE_DATETIMETASK_SUCCESS
,
DELETE_DATETIMETASK_REQUEST
,
DELETE_DATETIMETASK_REQUEST
,
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
}
from
"../actionTypes/tasksTypes"
;
import
axios
from
'../../axiosPlanner'
import
axios
from
'../../axiosPlanner'
...
@@ -64,17 +65,12 @@ export const fetchAllTasks = () => {
...
@@ -64,17 +65,12 @@ export const fetchAllTasks = () => {
//**fetch tasks for table UsersTasks, start*/
//**fetch tasks for table UsersTasks, start*/
const
fetchAllTasksByMembershipSuccess
=
(
tasks
)
=>
{
const
fetchAllTasksByMembershipSuccess
=
(
tasks
)
=>
{
return
{
type
:
FETCH_ALL_TASKS_SUCCESS
,
tasks
}
return
{
type
:
FETCH_ALL_TASKS_
BY_MEMBERSHIP_
SUCCESS
,
tasks
}
};
};
const
fetchUsersTasksFailure
=
(
error
)
=>
{
export
const
fetchAllTasksByMembership
=
()
=>
{
return
{
type
:
FETCH_CALENDAR_TASKS_FAILURE
,
error
}
};
export
const
fetcAllTasksByMembership
=
()
=>
{
return
async
(
dispatch
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
fetchCalendarTasksRequest
());
dispatch
(
fetchCalendarTasksRequest
());
try
{
try
{
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
c79bfce2
...
@@ -17,7 +17,8 @@ import {
...
@@ -17,7 +17,8 @@ import {
FETCH_TASKS_BY_PROJECT_FAILURE
,
FETCH_TASKS_BY_PROJECT_FAILURE
,
DELETE_DATETIMETASK_FAILURE
,
DELETE_DATETIMETASK_FAILURE
,
DELETE_DATETIMETASK_SUCCESS
,
DELETE_DATETIMETASK_SUCCESS
,
DELETE_DATETIMETASK_REQUEST
DELETE_DATETIMETASK_REQUEST
,
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
}
from
"../actionTypes/tasksTypes"
;
const
initialState
=
{
const
initialState
=
{
...
@@ -78,6 +79,8 @@ const tasksReduсer = (state = initialState, action) => {
...
@@ -78,6 +79,8 @@ const tasksReduсer = (state = initialState, action) => {
return
{...
state
,
loading
:
false
,
calendarTasks
:
newTasksWithInfoForCell
};
return
{...
state
,
loading
:
false
,
calendarTasks
:
newTasksWithInfoForCell
};
case
FETCH_ALL_TASKS_SUCCESS
:
case
FETCH_ALL_TASKS_SUCCESS
:
return
{...
state
,
loading
:
false
,
tasks
:
action
.
tasks
};
return
{...
state
,
loading
:
false
,
tasks
:
action
.
tasks
};
case
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS
:
return
{...
state
,
loading
:
false
,
tasks
:
action
.
tasks
,
projects
:
action
.
projects
};
case
FETCH_CALENDAR_TASKS_FAILURE
:
case
FETCH_CALENDAR_TASKS_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
case
ADD_NEW_TASK_SUCCESS
:
case
ADD_NEW_TASK_SUCCESS
:
...
...
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