User listing fixes
This commit is contained in:
parent
85d3c2b378
commit
882ecd30fe
@ -123,7 +123,7 @@ export class UserDetailsComponent implements OnInit {
|
||||
}
|
||||
|
||||
delete() {
|
||||
this._dialogService.openDialog('deleteUsers', null, [this.user], () => {
|
||||
this._dialogService.openDialog('deleteUsers', null, [this.user.id], () => {
|
||||
this.closeDialog.emit(true);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
<section class="dialog">
|
||||
<div [translateParams]="{ usersCount: users.length }" [translate]="'confirm-delete-users.title'" class="dialog-header heading-l"></div>
|
||||
<div
|
||||
[translateParams]="{ usersCount: userIds.length }"
|
||||
[translate]="'confirm-delete-users.title'"
|
||||
class="dialog-header heading-l"
|
||||
></div>
|
||||
|
||||
<div *ngIf="showToast" class="inline-dialog-toast toast-error">
|
||||
<div translate="confirm-delete-users.toast-error"></div>
|
||||
@ -22,7 +26,7 @@
|
||||
| translate
|
||||
: {
|
||||
dossiersCount: dossiersCount,
|
||||
usersCount: users.length
|
||||
usersCount: userIds.length
|
||||
}
|
||||
}}
|
||||
</mat-checkbox>
|
||||
@ -30,11 +34,11 @@
|
||||
|
||||
<div class="dialog-actions">
|
||||
<button (click)="deleteUser()" color="primary" mat-flat-button>
|
||||
{{ 'confirm-delete-users.delete' | translate: { usersCount: users.length } }}
|
||||
{{ 'confirm-delete-users.delete' | translate: { usersCount: userIds.length } }}
|
||||
</button>
|
||||
<div
|
||||
(click)="cancel()"
|
||||
[translateParams]="{ usersCount: users.length }"
|
||||
[translateParams]="{ usersCount: userIds.length }"
|
||||
[translate]="'confirm-delete-users.cancel'"
|
||||
class="all-caps-label cancel"
|
||||
></div>
|
||||
|
||||
@ -2,7 +2,6 @@ import { Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { List, LoadingService } from '@iqser/common-ui';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { User } from '@models/user';
|
||||
import { DossiersService } from '../../../dossier/services/dossiers.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
|
||||
@ -23,17 +22,12 @@ export class ConfirmDeleteUsersDialogComponent {
|
||||
private readonly _userService: UserService,
|
||||
private readonly _loadingService: LoadingService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
@Inject(MAT_DIALOG_DATA) readonly users: List<User>,
|
||||
@Inject(MAT_DIALOG_DATA) readonly userIds: List<string>,
|
||||
readonly dialogRef: MatDialogRef<ConfirmDeleteUsersDialogComponent>,
|
||||
) {
|
||||
this.dossiersCount = this._dossiersService.all.filter(dw => {
|
||||
for (const user of this.users) {
|
||||
if (dw.memberIds.indexOf(user.id) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).length;
|
||||
this.dossiersCount = this._dossiersService.all.filter(dw =>
|
||||
this.userIds.reduce((prev, userId) => prev || dw.memberIds.includes(userId), false),
|
||||
).length;
|
||||
}
|
||||
|
||||
get valid() {
|
||||
@ -43,7 +37,7 @@ export class ConfirmDeleteUsersDialogComponent {
|
||||
async deleteUser() {
|
||||
if (this.valid) {
|
||||
this._loadingService.start();
|
||||
await this._userService.delete(this.users.map(u => u.id)).toPromise();
|
||||
await this._userService.delete(this.userIds).toPromise();
|
||||
this.dialogRef.close(true);
|
||||
} else {
|
||||
this.showToast = true;
|
||||
|
||||
@ -93,7 +93,7 @@
|
||||
icon="iqser:edit"
|
||||
></iqser-circle-button>
|
||||
<iqser-circle-button
|
||||
(action)="openDeleteUsersDialog([user], $event)"
|
||||
(action)="openDeleteUsersDialog([user.id], $event)"
|
||||
[disabled]="user.id === userService.currentUser.id"
|
||||
[tooltip]="'user-listing.action.delete' | translate"
|
||||
[type]="circleButtonTypes.dark"
|
||||
|
||||
@ -77,9 +77,10 @@ export class UserListingScreenComponent extends ListingComponent<User> implement
|
||||
});
|
||||
}
|
||||
|
||||
openDeleteUsersDialog(users: User[], $event?: MouseEvent) {
|
||||
this._dialogService.openDialog('deleteUsers', $event, users, async () => {
|
||||
openDeleteUsersDialog(userIds: string[], $event?: MouseEvent) {
|
||||
this._dialogService.openDialog('deleteUsers', $event, userIds, async () => {
|
||||
await this._loadData();
|
||||
this.listingService.updateSelection();
|
||||
});
|
||||
}
|
||||
|
||||
@ -99,7 +100,7 @@ export class UserListingScreenComponent extends ListingComponent<User> implement
|
||||
}
|
||||
|
||||
bulkDelete() {
|
||||
this.openDeleteUsersDialog(this.entitiesService.all.filter(u => this.isSelected(u)));
|
||||
this.openDeleteUsersDialog(this.listingService.selectedIds as string[]);
|
||||
}
|
||||
|
||||
private async _loadData() {
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit ed518bbfd4ec827b7849d9badd55fc38ed6bc1ee
|
||||
Subproject commit 6a13ac5e483eee3438982bacdb38d3345614e1f3
|
||||
Loading…
x
Reference in New Issue
Block a user