Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
feat/user create group is required (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-trzewik authored Jul 29, 2021
1 parent c8ebcc1 commit 6e4176a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/components/user-management.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const UserManagement = (props: any) => {
}

const handleDeleteGroup = (group:IGroup) => {
setConfirmMessage("Wollen Sie wirklich die Gruppe "+group.name+ " löschen?")
setConfirmMessage("Wollen Sie wirklich die Gruppe \""+group.name+ "\" löschen?")
setShowConfirm(true);
const handle = () => {
if (keycloak.token && group.id) {
Expand All @@ -215,7 +215,7 @@ const UserManagement = (props: any) => {
}

const handleDeleteUser = (user:IUser) => {
setConfirmMessage("Wollen Sie wirklich den User "+user.username+ " löschen?")
setConfirmMessage("Wollen Sie wirklich den User \""+user.username+ "\" löschen?")
setShowConfirm(true);
const handle = () => {
if (keycloak.token && user.username) {
Expand Down Expand Up @@ -333,7 +333,10 @@ const UserManagement = (props: any) => {
</Card>
</Fade>
<UserModal show={isUserData}
onCancel={() => setIsUserData(false)}
onCancel={() => {
setEditUser({...emptyUser});
setIsUserData(false);
}}
groups={groupNodes}
handleOk={userUpdate}
user={editUser}
Expand Down
14 changes: 5 additions & 9 deletions src/components/user-modal.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ const UserModal = (props: any) => {
const [validated, setValidated] = React.useState(false);

React.useEffect(() => {
if (props.user.username !== user.username) {
if (!props.user.username
&& !props.user.subGroup
&& props.groups
&& props.groups.length>0) {
// props.user.subGroup = props.groups[0].group.id;
}
if (props.user.username !== user.username || !props.user.username) {
setUser(props.user);
setIsNew(!props.user.username);
}
Expand Down Expand Up @@ -86,7 +80,7 @@ const UserModal = (props: any) => {

if (!user.subGroup || !props.groups.find((groupNode: IGroupNode) => groupNode.group.id === user.subGroup)) {
user.subGroup = null;
groupOptions.push(<option key="empty" value="empty">-- leer --</option>);
groupOptions.unshift(<option key={0} value="">-- leer --</option>);
}

return (
Expand Down Expand Up @@ -146,8 +140,10 @@ const UserModal = (props: any) => {
<Col xs='7' sm='9' className='d-flex'>
<Form.Control as="select"
className={!props.value ? 'selection-placeholder qt-input' : 'qt-input'}
value={user.subGroup ? user.subGroup: 'empty'}
value={user.subGroup ? user.subGroup : ''}
placeholder="Gruppe"
onChange={(ent: any) => updateUserProp('subGroup',ent.target.value)}
required
>
{groupOptions}
</Form.Control>
Expand Down

0 comments on commit 6e4176a

Please sign in to comment.