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
550447c8
Commit
550447c8
authored
Dec 11, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#94
added modal window swithcuser with options to choose user
parent
b2d180f0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
163 additions
and
15 deletions
+163
-15
projects.ts
planner-api/src/routers/projects.ts
+1
-1
MemberForm.js
planner-front/src/components/MemberForm/MemberForm.js
+1
-1
ProfileBlock.js
...r-front/src/components/Menus/ProfileBlock/ProfileBlock.js
+5
-4
SwitchUserForm.js
...mponents/SwitchUserModal/SwitchUserForm/SwitchUserForm.js
+90
-0
SwitchUserModal.js
...r-front/src/components/SwitchUserModal/SwitchUserModal.js
+25
-9
SwitchUserTable.js
...onents/SwitchUserModal/SwitchUserTable/SwitchUserTable.js
+41
-0
No files found.
planner-api/src/routers/projects.ts
View file @
550447c8
planner-front/src/components/MemberForm/MemberForm.js
View file @
550447c8
...
@@ -10,7 +10,7 @@ import { useParams } from "react-router-dom";
...
@@ -10,7 +10,7 @@ import { useParams } from "react-router-dom";
import
PersonAddIcon
from
'@mui/icons-material/PersonAdd'
;
import
PersonAddIcon
from
'@mui/icons-material/PersonAdd'
;
const
style
=
{
const
style
=
{
position
:
'
absolut
e'
,
position
:
'
relativ
e'
,
top
:
'50%'
,
top
:
'50%'
,
left
:
'50%'
,
left
:
'50%'
,
transform
:
'translate(-50%, -50%)'
,
transform
:
'translate(-50%, -50%)'
,
...
...
planner-front/src/components/Menus/ProfileBlock/ProfileBlock.js
View file @
550447c8
import
{
Button
,
Menu
,
MenuItem
}
from
"@mui/material"
;
import
{
Button
,
Menu
,
MenuItem
}
from
"@mui/material"
;
import
{
useState
}
from
"react"
;
import
{
useState
,
useEffect
}
from
"react"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
NavLink
,
useNavigate
}
from
"react-router-dom"
;
import
{
NavLink
,
useNavigate
}
from
"react-router-dom"
;
import
{
fetchUsersAllFields
,
logoutUser
}
from
"../../../store/actions/usersActions"
;
import
{
fetchUsersAllFields
,
fetchUsers
,
logoutUser
}
from
"../../../store/actions/usersActions"
;
import
SwitchUserModal
from
"../../SwitchUserModal/SwitchUserModal"
;
import
SwitchUserModal
from
"../../SwitchUserModal/SwitchUserModal"
;
const
ProfileBlock
=
()
=>
{
const
ProfileBlock
=
()
=>
{
...
@@ -15,7 +15,6 @@ const ProfileBlock = () => {
...
@@ -15,7 +15,6 @@ const ProfileBlock = () => {
const
[
openSwitchUser
,
setOpenSwitchUser
]
=
useState
(
false
);
const
[
openSwitchUser
,
setOpenSwitchUser
]
=
useState
(
false
);
const
handleCloseSwitchUser
=
()
=>
setOpenSwitchUser
(
false
);
const
handleCloseSwitchUser
=
()
=>
setOpenSwitchUser
(
false
);
const
handleClick
=
(
event
)
=>
{
const
handleClick
=
(
event
)
=>
{
setAnchorEl
(
event
.
currentTarget
);
setAnchorEl
(
event
.
currentTarget
);
};
};
...
@@ -31,10 +30,12 @@ const ProfileBlock = () => {
...
@@ -31,10 +30,12 @@ const ProfileBlock = () => {
}
}
const
switchUser
=
()
=>
{
const
switchUser
=
()
=>
{
dispatch
(
fetchUsersAllFields
());
dispatch
(
fetchUsersAllFields
());
// dispatch(fetchUsers())
handleClose
()
handleClose
()
handleOpenSwitchUser
()
handleOpenSwitchUser
()
}
}
return
<>
return
<>
<
Button
<
Button
color
=
"inherit"
color
=
"inherit"
...
...
planner-front/src/components/SwitchUserModal/SwitchUserForm/SwitchUserForm.js
0 → 100644
View file @
550447c8
import
React
,{
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Grid
,
Typography
,
Autocomplete
,
TextField
}
from
"@mui/material"
;
import
SwitchUserTable
from
'../SwitchUserTable/SwitchUserTable'
;
const
SwitchUserForm
=
({
submitFormHandler
,
users
})
=>
{
const
[
currentUser
,
setCurrentUser
]
=
useState
(
null
);
const
[
projectsRoles
,
setProjectsRole
]
=
useState
([])
const
onChangeHandle
=
(
user
)
=>
{
setCurrentUser
(
user
)
setProjectsRole
([])
}
useEffect
(()
=>
{
if
(
currentUser
?.
members
.
length
>
0
)
{
for
(
let
member
of
currentUser
.
members
)
{
const
newProjectRole
=
{
"projectName"
:
member
.
project
.
title
,
"roleName"
:
member
.
roleProject
}
setProjectsRole
([...
projectsRoles
,
newProjectRole
])
}
}
},[
currentUser
])
return
(
<>
{
/* <Box sx={style}> */
}
{
users
?
<
form
onSubmit
=
{
submitFormHandler
}
>
<
Grid
container
direction
=
"column"
spacing
=
{
2
}
>
<
Typography
variant
=
"h5"
style
=
{{
margin
:
"5px"
,
textAlign
:
"center"
}}
>
Выберите
юзера
<
/Typography
>
<
Autocomplete
options
=
{
users
}
onChange
=
{(
event
,
user
)
=>
onChangeHandle
(
user
)
}
getOptionLabel
=
{(
option
)
=>
option
.
displayName
}
renderInput
=
{(
params
)
=>
<
TextField
style
=
{{
margin
:
"5px"
}}
label
=
{
"Юзер"
}
{...
params
}
/>
}
/>
{
projectsRoles
.
length
>
0
?
<
Grid
item
>
<
SwitchUserTable
projectsRoles
=
{
projectsRoles
}
/
>
<
/Grid
>
:
<><
/>
}
<
Grid
container
direction
=
"row"
spacing
=
{
2
}
>
<
Grid
item
>
<
Button
type
=
"submit"
color
=
"primary"
variant
=
"contained"
sx
=
{{
margin
:
1
}}
>
ОК
<
/Button
>
<
/Grid
>
{
/* <Grid item>
<Button
onClick={()=>console.log('cancel form')}
color="primary"
variant="contained"
>
Отмена
</Button>
</Grid> */
}
<
/Grid
>
<
/Grid
>
<
/form
>
:
<><
/>
}
{
/* </Box> */
}
<
/
>
)
}
export
default
SwitchUserForm
;
planner-front/src/components/SwitchUserModal/SwitchUserModal.js
View file @
550447c8
import
*
as
React
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
Box
from
'@mui/material/Box'
;
import
Box
from
'@mui/material/Box'
;
import
Button
from
'@mui/material/Button'
;
import
Button
from
'@mui/material/Button'
;
import
Typography
from
'@mui/material/Typography'
;
import
Typography
from
'@mui/material/Typography'
;
import
Modal
from
'@mui/material/Modal'
;
import
Modal
from
'@mui/material/Modal'
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
fetchUsersAllFields
}
from
'../../store/actions/usersActions'
;
import
SwitchUserTable
from
'./SwitchUserTable/SwitchUserTable'
;
import
SwitchUserForm
from
'./SwitchUserForm/SwitchUserForm'
;
const
style
=
{
const
style
=
{
position
:
'absolute'
,
position
:
'absolute'
,
top
:
'50%'
,
top
:
'50%'
,
left
:
'50%'
,
left
:
'50%'
,
transform
:
'translate(-50%, -50%)'
,
transform
:
'translate(-50%, -50%)'
,
width
:
400
,
width
:
'fit-content'
,
bgcolor
:
'background.paper'
,
bgcolor
:
'background.paper'
,
border
:
'2px solid #000'
,
border
:
'2px solid #000'
,
boxShadow
:
24
,
boxShadow
:
24
,
...
@@ -17,6 +23,14 @@ const style = {
...
@@ -17,6 +23,14 @@ const style = {
};
};
const
SwitchUserModal
=
({
open
,
handleClose
})
=>
{
const
SwitchUserModal
=
({
open
,
handleClose
})
=>
{
const
usersAllFields
=
useSelector
(
state
=>
state
.
users
.
usersAllFields
)
const
submitFormHandler
=
(
e
)
=>
{
e
.
preventDefault
();
console
.
log
(
'submitFormHandler'
,
'e.target.name '
,
e
.
target
.
name
,
'e.target.value '
,
e
.
target
.
value
)
}
return
(
return
(
<
div
>
<
div
>
...
@@ -27,14 +41,16 @@ const SwitchUserModal= ({open, handleClose})=> {
...
@@ -27,14 +41,16 @@ const SwitchUserModal= ({open, handleClose})=> {
aria
-
describedby
=
"modal-modal-description"
aria
-
describedby
=
"modal-modal-description"
>
>
<
Box
sx
=
{
style
}
>
<
Box
sx
=
{
style
}
>
<
Typography
id
=
"modal-modal-title"
variant
=
"h6"
component
=
"h2"
>
Text
in
a
modal
<
SwitchUserForm
<
/Typography
>
<
Typography
id
=
"modal-modal-description"
sx
=
{{
mt
:
2
}}
>
submitFormHandler
=
{
submitFormHandler
}
Duis
mollis
,
est
non
commodo
luctus
,
nisi
erat
porttitor
ligula
.
users
=
{
usersAllFields
}
<
/Typography
>
/
>
<
/Box
>
<
/Box
>
<
/Modal
>
<
/Modal
>
<
/div
>
<
/div
>
);
);
}
}
...
...
planner-front/src/components/SwitchUserModal/SwitchUserTable/SwitchUserTable.js
0 → 100644
View file @
550447c8
import
*
as
React
from
'react'
;
import
Table
from
'@mui/material/Table'
;
import
TableBody
from
'@mui/material/TableBody'
;
import
TableCell
from
'@mui/material/TableCell'
;
import
TableContainer
from
'@mui/material/TableContainer'
;
import
TableHead
from
'@mui/material/TableHead'
;
import
TableRow
from
'@mui/material/TableRow'
;
import
Paper
from
'@mui/material/Paper'
;
const
SwitchUserTable
=
({
projectsRoles
})
=>
{
return
(
<
TableContainer
component
=
{
Paper
}
>
<
Table
sx
=
{{
minWidth
:
450
}}
aria
-
label
=
"simple table"
>
<
TableHead
>
<
TableRow
>
<
TableCell
>
Проекты
<
/TableCell
>
<
TableCell
align
=
"right"
>
Роли
<
/TableCell
>
<
/TableRow
>
<
/TableHead
>
<
TableBody
>
{
projectsRoles
.
map
((
projectRole
,
index
)
=>
(
<
TableRow
key
=
{
index
}
sx
=
{{
'&:last-child td, &:last-child th'
:
{
border
:
0
}
}}
>
<
TableCell
component
=
"th"
scope
=
"row"
>
{
projectRole
.
projectName
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
projectRole
.
roleName
}
<
/TableCell
>
<
/TableRow
>
))}
<
/TableBody
>
<
/Table
>
<
/TableContainer
>
)
}
export
default
SwitchUserTable
;
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