-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#931: new component DeleteUserComponent
- Loading branch information
1 parent
d70bdbf
commit 7b82381
Showing
5 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
frontend/src/app/team-management/delete-user/delete-user.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<ng-container> | ||
<button | ||
(click)="deleteUser()" | ||
[attr.data-testId]="'delete-user'" | ||
class="mdc-button px-0 pe-2" | ||
color="primary" | ||
mat-button | ||
> | ||
<span class="d-flex align-items-center fw-bold add-text"> | ||
<img alt="Delete user button" class="add-cross-button" src="/assets/icons/delete-icon.svg" /> | ||
Member löschen | ||
</span> | ||
</button> | ||
</ng-container> |
9 changes: 9 additions & 0 deletions
9
frontend/src/app/team-management/delete-user/delete-user.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.new-team { | ||
display: flex; | ||
|
||
> mat-form-field { | ||
flex: 0 0 calc(35% + 1rem); | ||
padding-right: 1rem; | ||
box-sizing: border-box; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
frontend/src/app/team-management/delete-user/delete-user.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
describe('DeleteUserComponent', () => { | ||
it('todo write tests', () => {}); | ||
}); |
54 changes: 54 additions & 0 deletions
54
frontend/src/app/team-management/delete-user/delete-user.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { UserService } from '../../services/user.service'; | ||
import { User } from '../../shared/types/model/User'; | ||
import { Location } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'app-delete-user', | ||
templateUrl: './delete-user.component.html', | ||
styleUrl: './delete-user.component.scss', | ||
}) | ||
export class DeleteUserComponent implements OnInit { | ||
@Input({ required: true }) user!: User; | ||
|
||
private isUserMemberOfTeams: boolean = false; | ||
private isUserOwnerOfKeyResults: boolean = false; | ||
|
||
constructor( | ||
private readonly userService: UserService, | ||
private readonly location: Location, | ||
) {} | ||
|
||
ngOnInit() { | ||
this.memberOfTeams(this.user.id); | ||
this.ownerOfKeyResults(this.user.id); | ||
} | ||
|
||
memberOfTeams(userId: number) { | ||
this.isUserMemberOfTeams = this.user.userTeamList != null && this.user.userTeamList.length > 0; | ||
console.log('### member_of_teams', userId, this.isUserMemberOfTeams); | ||
} | ||
|
||
ownerOfKeyResults(userId: number) { | ||
this.isUserMemberOfTeams = this.user.userTeamList.length > 0; | ||
this.userService.isUserOwnerOfKeyResults(this.user).subscribe((booleanAsObject) => { | ||
this.isUserOwnerOfKeyResults = !!booleanAsObject; | ||
console.log('### key_result', userId, !!booleanAsObject); | ||
}); | ||
} | ||
|
||
deleteUser() { | ||
if (this.isUserMemberOfTeams) { | ||
alert('user is member of team'); | ||
return; | ||
} | ||
if (this.isUserOwnerOfKeyResults) { | ||
alert('user is owner of key results'); | ||
return; | ||
} | ||
|
||
this.userService.deleteUser(this.user).subscribe((v) => { | ||
this.location.back(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters