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
c3e7626b
Commit
c3e7626b
authored
Jan 09, 2023
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#141
Добавил разные валидации на удаление\добавление
parent
f716d6d1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
18 deletions
+42
-18
NewMemberModalContent.js
...Components/NewMemberModalContent/NewMemberModalContent.js
+3
-2
helpers.js
...onents/ProjectComponents/NewMemberModalContent/helpers.js
+4
-0
ProjectInfo.js
...c/components/ProjectComponents/ProjectInfo/ProjectInfo.js
+10
-6
ProjectUsersColumn.js
...rsColumnsWrapper/ProjectUsersColumn/ProjectUsersColumn.js
+2
-1
UserItem.js
...Wrapper/ProjectUsersColumn/UsersList/UserItem/UserItem.js
+9
-6
UserList.js
...rsColumnsWrapper/ProjectUsersColumn/UsersList/UserList.js
+2
-1
ProjectUsersColumnsWrapper.js
.../ProjectUsersColumnsWrapper/ProjectUsersColumnsWrapper.js
+2
-1
FullProject.js
planner-front/src/containers/FullProject/FullProject.js
+10
-1
No files found.
planner-front/src/components/ProjectComponents/NewMemberModalContent/NewMemberModalContent.js
View file @
c3e7626b
...
...
@@ -2,10 +2,11 @@ import { Button } from "@mui/material";
import
{
memo
}
from
"react"
;
import
{
projectRoles
}
from
"../../../constants"
;
import
CustomAutocomplete
from
"../../UI/CustomAutocomplete/CustomAutocomplete"
;
import
{
isValidate
}
from
"./helpers"
;
function
NewMemberModalContent
({
users
,
onChangeNewMemberHandler
,
onChangeRoleHandler
,
newMember
,
handleClose
,
createNewMemberHandler
})
{
function
NewMemberModalContent
({
members
,
users
,
onChangeNewMemberHandler
,
onChangeRoleHandler
,
newMember
,
handleClose
,
createNewMemberHandler
})
{
return
(
<>
<
CustomAutocomplete
name
=
{
'newMember'
}
...
...
@@ -27,7 +28,7 @@ function NewMemberModalContent({ users, onChangeNewMemberHandler, onChangeRoleHa
style
=
{{
marginBottom
:
'15px'
}}
/
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'space-between'
,
margin
:
'10px 0'
}}
>
<
Button
onClick
=
{()
=>
{
createNewMemberHandler
()
}}
>
Выбрать
<
/Button
>
<
Button
onClick
=
{()
=>
{
createNewMemberHandler
()
}}
disabled
=
{
!
isValidate
(
members
,
newMember
?.
userId
,
newMember
?.
roleProject
)}
>
Выбрать
<
/Button
>
<
Button
onClick
=
{()
=>
handleClose
()}
>
Отмена
<
/Button
>
<
/div
>
...
...
planner-front/src/components/ProjectComponents/NewMemberModalContent/helpers.js
0 → 100644
View file @
c3e7626b
export
const
isValidate
=
(
members
,
userId
,
role
)
=>
{
if
(
!
userId
||
!
role
)
return
false
return
!
members
.
find
((
member
)
=>
member
?.
user
?.
id
===
userId
)
}
\ No newline at end of file
planner-front/src/components/ProjectComponents/ProjectInfo/ProjectInfo.js
View file @
c3e7626b
...
...
@@ -16,7 +16,7 @@ const styleText = {
}
const
ProjectInfo
=
({
project
,
handleOpen
})
=>
{
const
ProjectInfo
=
({
project
,
handleOpen
,
currentRoleInProject
})
=>
{
return
(
<
Box
sx
=
{
style
}
justifyContent
=
{
'space-between'
}
>
<
Typography
variant
=
"h2"
>
Проект
-
{
project
?.
title
}
<
/Typography
>
...
...
@@ -24,20 +24,24 @@ const ProjectInfo = ({ project, handleOpen }) => {
Дата
создания
проекта
:
{
moment
(
project
?.
createdAt
).
format
(
'MM.DD.YYYY'
)}
<
/Typography
>
<
Typography
variant
=
"body1"
sx
=
{
styleText
}
>
Цвет
:
{
project
?.
color
}
Цвет
:
{
project
?.
color
||
'Зеленый'
}
<
/Typography
>
<
Typography
variant
=
"body1"
sx
=
{
styleText
}
>
Автор
проекта
:
{
project
?.
members
[
0
]?.
user
.
displayName
}
<
/Typography
>
<
Typography
variant
=
"body1"
sx
=
{
styleText
}
>
Роль
в
проекте
:
{
project
?.
members
[
0
]?.
role
Project
}
Роль
в
проекте
:
{
currentRoleIn
Project
}
<
/Typography
>
<
Typography
variant
=
"body1"
sx
=
{
styleText
}
>
Задачи
:
<
/Typography
>
<
Typography
variant
=
"body1"
sx
=
{
styleText
}
>
Добавить
участника
:
<
PersonAddIcon
style
=
{{
cursor
:
'pointer'
}}
onClick
=
{()
=>
{
handleOpen
()}}
/
>
<
/Typography
>
{
currentRoleInProject
===
'admin'
?
<
Typography
variant
=
"body1"
sx
=
{
styleText
}
>
Добавить
участника
:
<
PersonAddIcon
style
=
{{
cursor
:
'pointer'
}}
onClick
=
{()
=>
{
handleOpen
()
}}
/
>
<
/Typography
>
:
null
}
<
/Box
>
);
};
...
...
planner-front/src/components/ProjectComponents/ProjectUsersColumnsWrapper/ProjectUsersColumn/ProjectUsersColumn.js
View file @
c3e7626b
...
...
@@ -13,7 +13,7 @@ const styleColumn = {
}
const
ProjectUsersColumn
=
({
role
,
members
,
deleteMemberHandler
})
=>
{
const
ProjectUsersColumn
=
({
role
,
members
,
deleteMemberHandler
,
currentRoleInProject
})
=>
{
return
(
<
Box
sx
=
{
styleColumn
}
>
<
ColumnTitle
text
=
{
role
.
text
}
/
>
...
...
@@ -22,6 +22,7 @@ const ProjectUsersColumn = ({ role, members, deleteMemberHandler }) => {
role
=
{
role
}
members
=
{
members
}
deleteMemberHandler
=
{
deleteMemberHandler
}
currentRoleInProject
=
{
currentRoleInProject
}
>
<
/UsersList
>
<
/Box
>
...
...
planner-front/src/components/ProjectComponents/ProjectUsersColumnsWrapper/ProjectUsersColumn/UsersList/UserItem/UserItem.js
View file @
c3e7626b
import
{
Grid
}
from
"@mui/material"
;
import
DeleteIcon
from
"@mui/icons-material/Delete"
;
import
{
memo
}
from
"react"
;
import
{
useSelector
}
from
"react-redux"
;
const
style
=
{
width
:
'90%'
,
...
...
@@ -12,15 +13,17 @@ const style = {
alignItems
:
'center'
}
const
ProjectMembersItem
=
({
user
,
deleteMemberHandler
})
=>
{
const
ProjectMembersItem
=
({
user
,
deleteMemberHandler
,
currentRoleInProject
})
=>
{
const
userId
=
useSelector
(
state
=>
state
.
users
.
user
.
id
);
return
<>
<
Grid
sx
=
{
style
}
>
{
user
?.
displayName
}
<
DeleteIcon
sx
=
{{
cursor
:
'pointer'
}}
onClick
=
{
deleteMemberHandler
}
/
>
{
currentRoleInProject
===
'admin'
&&
user
.
id
!==
userId
?
<
DeleteIcon
sx
=
{{
cursor
:
'pointer'
}}
onClick
=
{
deleteMemberHandler
}
/
>
:
null
}
<
/Grid
>
<
/
>
};
...
...
planner-front/src/components/ProjectComponents/ProjectUsersColumnsWrapper/ProjectUsersColumn/UsersList/UserList.js
View file @
c3e7626b
...
...
@@ -9,7 +9,7 @@ const styleList = {
alignItems
:
'center'
,
}
const
UsersList
=
({
role
,
members
,
deleteMemberHandler
})
=>
{
const
UsersList
=
({
role
,
members
,
deleteMemberHandler
,
currentRoleInProject
})
=>
{
return
(
<
Box
sx
=
{
styleList
}
>
{
members
.
map
((
member
)
=>
{
...
...
@@ -19,6 +19,7 @@ const UsersList = ({ role, members, deleteMemberHandler }) => {
key
=
{
member
.
id
}
user
=
{
member
?.
user
}
deleteMemberHandler
=
{()
=>
{
deleteMemberHandler
(
member
?.
user
?.
id
)
}}
currentRoleInProject
=
{
currentRoleInProject
}
/
>
)
}
else
{
...
...
planner-front/src/components/ProjectComponents/ProjectUsersColumnsWrapper/ProjectUsersColumnsWrapper.js
View file @
c3e7626b
...
...
@@ -13,7 +13,7 @@ const style = {
}
const
ProjectUsersColumnsWrapper
=
({
members
,
deleteMemberHandler
})
=>
{
const
ProjectUsersColumnsWrapper
=
({
members
,
deleteMemberHandler
,
currentRoleInProject
})
=>
{
return
(
<
Box
sx
=
{
style
}
justifyContent
=
{
'space-between'
}
>
{
projectRoles
.
map
((
role
,
i
)
=>
{
...
...
@@ -23,6 +23,7 @@ const ProjectUsersColumnsWrapper = ({ members, deleteMemberHandler }) => {
role
=
{
role
}
members
=
{
members
}
deleteMemberHandler
=
{
deleteMemberHandler
}
currentRoleInProject
=
{
currentRoleInProject
}
/
>
)
})}
...
...
planner-front/src/containers/FullProject/FullProject.js
View file @
c3e7626b
...
...
@@ -10,6 +10,7 @@ import DefaultModal from "../../components/UI/DefaultModal/DefaultModal"
import
NewMemberModalContent
from
"../../components/ProjectComponents/NewMemberModalContent/NewMemberModalContent"
;
const
FullProject
=
()
=>
{
const
{
project
}
=
useSelector
(
state
=>
state
.
projects
);
...
...
@@ -29,6 +30,10 @@ const FullProject = () => {
return
project
?.
project
?.
members
||
[]
},
[
project
])
const
currentRoleInProject
=
useMemo
(()
=>
{
return
members
.
find
((
member
)
=>
member
.
user
.
id
===
user
.
id
)?.
roleProject
},
[
members
,
user
.
id
])
const
onChangeRoleHandler
=
useCallback
((
e
,
value
)
=>
{
setNewMember
((
prevState
)
=>
{
return
{
...
prevState
,
roleProject
:
value
?.
value
}
});
},
[]);
...
...
@@ -49,23 +54,26 @@ const FullProject = () => {
const
createNewMemberHandler
=
useCallback
(()
=>
{
dispatch
(
createMember
({...
newMember
,
projectId
:
project
?.
project
?.
id
}))
setModal
(
false
)
setNewMember
(
null
)
},
[
dispatch
,
newMember
,
project
?.
project
?.
id
])
const
deleteMemberHandler
=
useCallback
((
id
)
=>
{
dispatch
(
deleteMember
(
id
,
project
?.
project
?.
id
))
},
[
dispatch
,
project
?.
project
?.
id
])
return
<>
<
Grid
>
<
ProjectInfo
project
=
{
project
.
project
}
handleOpen
=
{
handleOpen
}
currentRoleInProject
=
{
currentRoleInProject
}
/
>
<
ProjectUsersColumnsWrapper
members
=
{
members
}
deleteMemberHandler
=
{
deleteMemberHandler
}
currentRoleInProject
=
{
currentRoleInProject
}
/
>
<
DefaultModal
...
...
@@ -79,6 +87,7 @@ const FullProject = () => {
newMember
=
{
newMember
}
handleClose
=
{
handleClose
}
createNewMemberHandler
=
{
createNewMemberHandler
}
members
=
{
members
}
>
<
/NewMemberModalContent
>
...
...
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