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
Show 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';
import
{
myDataSource
}
from
'../app-data-source'
;
import
{
User
}
from
'../models/User'
;
import
{
Member
,
MemberRole
}
from
'../models/Member'
;
import
{
In
}
from
'typeorm'
;
import
{
In
,
Not
}
from
'typeorm'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
auth
,
authAuthorOrExecutorOfTask
,
taskFinderById
}
from
'../helpers'
;
import
{
Project
}
from
'../models/Project'
;
...
...
@@ -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*/
router
.
get
(
'/users-tasks'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
user
}
=
req
.
body
const
projects
=
await
dataSource
const
projects
WithTasks
=
await
dataSource
.
getRepository
(
Project
)
.
find
(
{
relations
:{
...
...
@@ -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
[]
=
[]
if
(
projects
.
length
>
0
)
{
for
(
let
project
of
projects
){
if
(
projects
WithTasks
.
length
>
0
)
{
for
(
let
project
of
projects
WithTasks
){
if
(
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
})
})
...
...
planner-front/src/containers/UsersTasks/UsersTasks.js
View file @
c79bfce2
...
...
@@ -12,7 +12,7 @@ import { useDispatch, useSelector } from "react-redux";
import
TaskModal
from
"../../components/UsersTasksCompoments/TaskModal/TaskModal"
;
import
moment
from
"moment"
;
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
TableRowTask
from
"../../components/UsersTasksCompoments/TableRowTask/TableRowTask"
;
import
UsersTasksHeader
from
"./UsersTasksHeader/UsersTasksHeader"
;
...
...
@@ -23,9 +23,10 @@ export default function UsersTasks() {
const
dispatch
=
useDispatch
();
const
tasks
=
useSelector
((
state
)
=>
state
.
tasks
.
tasks
);
const
projects
=
useSelector
((
state
)
=>
state
.
tasks
.
projects
);
const
user
=
useSelector
((
state
)
=>
state
.
users
.
user
);
const
[
executors
,
setExecutors
]
=
useState
([])
const
[
projects
,
setProjects
]
=
useState
([])
const
[
currentProject
,
setCurrentProject
]
=
useState
(
null
);
const
[
recievedTasks
,
setRecievedTasks
]
=
useState
([]);
const
[
addTaskForm
,
setAddTaskForm
]
=
useState
(
false
);
...
...
@@ -40,15 +41,14 @@ export default function UsersTasks() {
useEffect
(()
=>
{
dispatch
(
fetchAllTasks
());
filterProjectsNamesFromTasks
()
dispatch
(
fetchAllTasksByMembership
());
if
(
tasks
&&
tasks
?.
length
>
0
)
{
setRecievedTasks
(
tasks
);
}
},
[
dispatch
,
tasks
?.
length
]);
useEffect
(()
=>
{
dispatch
(
fetchAllTasks
());
dispatch
(
fetchAllTasks
ByMembership
());
},
[
addTaskForm
,
setAddTaskForm
]);
...
...
@@ -112,7 +112,8 @@ useEffect(() => {
const
onProjectChange
=
(
e
,
task
)
=>
{
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
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
...
...
@@ -218,20 +219,20 @@ useEffect(() => {
const
rawProjects
=
tasks
?.
map
(
task
=>
task
.
project
)
const
filterProjectsNamesFromTasks
=
()
=>
{
if
(
tasks
&&
tasks
?.
length
>
0
)
{
//
const filterProjectsNamesFromTasks = ()=>{
//
if (tasks && tasks?.length > 0) {
let
rawSetProjectNames
=
[]
for
(
let
project
of
rawProjects
){
if
(
project
===
null
){
}
else
{
rawSetProjectNames
.
push
(
project
.
title
)
}
}
let
uniqueTitlesProjects
=
[...
new
Set
(
rawSetProjectNames
)];
setProjects
(
uniqueTitlesProjects
)
}
}
//
let rawSetProjectNames = []
//
for (let project of rawProjects){
//
if (project===null){
//
} else{
//
rawSetProjectNames.push(project.title)
//
}
//
}
//
let uniqueTitlesProjects = [...new Set(rawSetProjectNames)];
//
setProjects(uniqueTitlesProjects)
//
}
//
}
const
uniqueProjects
=
rawProjects
?.
reduce
((
results
,
value
,
index
)
=>
{
const
exist
=
results
.
find
((
v
)
=>
{
...
...
@@ -265,7 +266,8 @@ console.log('tasks', tasks)
{
addTaskForm
?
(
<
NewTaskForm
projects
=
{
uniqueProjects
}
projects
=
{
projects
}
setCurrentProject
=
{
setCurrentProject
}
currentProject
=
{
currentProject
}
setAddTaskForm
=
{()
=>
setAddTaskForm
(
false
)}
/
>
...
...
planner-front/src/store/actions/tasksActions.js
View file @
c79bfce2
...
...
@@ -18,6 +18,7 @@ import {
DELETE_DATETIMETASK_FAILURE
,
DELETE_DATETIMETASK_SUCCESS
,
DELETE_DATETIMETASK_REQUEST
,
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
import
axios
from
'../../axiosPlanner'
...
...
@@ -64,17 +65,12 @@ export const fetchAllTasks = () => {
//**fetch tasks for table UsersTasks, start*/
const
fetchAllTasksByMembershipSuccess
=
(
tasks
)
=>
{
return
{
type
:
FETCH_ALL_TASKS_SUCCESS
,
tasks
}
return
{
type
:
FETCH_ALL_TASKS_
BY_MEMBERSHIP_
SUCCESS
,
tasks
}
};
const
fetchUsersTasksFailure
=
(
error
)
=>
{
return
{
type
:
FETCH_CALENDAR_TASKS_FAILURE
,
error
}
};
export
const
fetcAllTasksByMembership
=
()
=>
{
export
const
fetchAllTasksByMembership
=
()
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
fetchCalendarTasksRequest
());
try
{
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
c79bfce2
...
...
@@ -17,7 +17,8 @@ import {
FETCH_TASKS_BY_PROJECT_FAILURE
,
DELETE_DATETIMETASK_FAILURE
,
DELETE_DATETIMETASK_SUCCESS
,
DELETE_DATETIMETASK_REQUEST
DELETE_DATETIMETASK_REQUEST
,
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
const
initialState
=
{
...
...
@@ -78,6 +79,8 @@ const tasksReduсer = (state = initialState, action) => {
return
{...
state
,
loading
:
false
,
calendarTasks
:
newTasksWithInfoForCell
};
case
FETCH_ALL_TASKS_SUCCESS
:
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
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
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