diff --git a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts
index 8821b604a..e29a141bb 100644
--- a/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts
+++ b/apps/red-ui/src/app/modules/admin/screens/user-listing/user-listing-screen.component.ts
@@ -6,23 +6,22 @@ import { AdminDialogService } from '../../services/admin-dialog.service';
import { TranslateService } from '@ngx-translate/core';
import { DoughnutChartConfig } from '@shared/components/simple-doughnut-chart/simple-doughnut-chart.component';
import { TranslateChartService } from '@services/translate-chart.service';
-import { BaseListingComponent } from '@shared/base/base-listing.component';
import { LoadingService } from '../../../../services/loading.service';
import { InitialsAvatarComponent } from '../../../shared/components/initials-avatar/initials-avatar.component';
import { FilterService } from '../../../shared/services/filter.service';
import { SearchService } from '../../../shared/services/search.service';
import { ScreenStateService } from '../../../shared/services/screen-state.service';
import { SortingService } from '../../../../services/sorting.service';
+import { NewBaseListingComponent } from '../../../shared/base/new-base-listing.component';
@Component({
templateUrl: './user-listing-screen.component.html',
styleUrls: ['./user-listing-screen.component.scss'],
providers: [FilterService, SearchService, ScreenStateService, SortingService]
})
-export class UserListingScreenComponent extends BaseListingComponent implements OnInit {
+export class UserListingScreenComponent extends NewBaseListingComponent implements OnInit {
collapsedDetails = false;
chartData: DoughnutChartConfig[] = [];
- protected readonly _selectionKey = 'userId';
@ViewChildren(InitialsAvatarComponent)
private readonly _avatars: QueryList;
@@ -37,10 +36,11 @@ export class UserListingScreenComponent extends BaseListingComponent imple
protected readonly _injector: Injector
) {
super(_injector);
+ this._screenStateService.setIdKey('userId');
}
get canDeleteSelected(): boolean {
- return this.selectedEntitiesIds.indexOf(this.userService.userId) === -1;
+ return this._screenStateService.selectedEntitiesIds.indexOf(this.userService.userId) === -1;
}
async ngOnInit() {
@@ -79,7 +79,9 @@ export class UserListingScreenComponent extends BaseListingComponent imple
}
async bulkDelete() {
- this.openDeleteUsersDialog(this.allEntities.filter(u => this.isSelected(u)));
+ this.openDeleteUsersDialog(
+ this._screenStateService.entities.filter(u => this.isSelected(u))
+ );
}
trackById(index: number, user: User) {
@@ -91,9 +93,11 @@ export class UserListingScreenComponent extends BaseListingComponent imple
}
private async _loadData() {
- this.allEntities = await this._userControllerService.getAllUsers().toPromise();
+ this._screenStateService.setEntities(
+ await this._userControllerService.getAllUsers().toPromise()
+ );
await this.userService.loadAllUsers();
- this._executeSearchImmediately();
+ this.filterService.filterEntities();
this._computeStats();
this._loadingService.stop();
}
diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.html
index fcf01bb2a..bd5fec96a 100644
--- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.html
+++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.html
@@ -5,7 +5,7 @@
[searchPlaceholder]="'dossier-overview.search' | translate"
>
diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers.service.ts
index 554967f65..df92dfe8f 100644
--- a/apps/red-ui/src/app/modules/dossier/services/dossiers.service.ts
+++ b/apps/red-ui/src/app/modules/dossier/services/dossiers.service.ts
@@ -9,13 +9,11 @@ export class DossiersService {
return this._dossierControllerService.getDeletedDossiers().toPromise();
}
- restore(dossierIds: string | Array
): Promise {
- if (typeof dossierIds === 'string') dossierIds = [dossierIds];
+ restore(dossierIds: Array): Promise {
return this._dossierControllerService.restoreDossiers(dossierIds).toPromise();
}
- hardDelete(dossierIds: string | Array): Promise {
- if (typeof dossierIds === 'string') dossierIds = [dossierIds];
+ hardDelete(dossierIds: Array): Promise {
return this._dossierControllerService.hardDeleteDossiers(dossierIds).toPromise();
}
}
diff --git a/apps/red-ui/src/app/modules/shared/base/new-base-listing.component.ts b/apps/red-ui/src/app/modules/shared/base/new-base-listing.component.ts
index 2c2ac8e6c..d288708b2 100644
--- a/apps/red-ui/src/app/modules/shared/base/new-base-listing.component.ts
+++ b/apps/red-ui/src/app/modules/shared/base/new-base-listing.component.ts
@@ -37,12 +37,16 @@ export abstract class NewBaseListingComponent {
return this._screenStateService.entities$;
}
+ get allEntities(): T[] {
+ return this._screenStateService.entities;
+ }
+
get areAllEntitiesSelected() {
return this._screenStateService.areAllEntitiesSelected;
}
- get areSomeEntitiesSelected() {
- return this._screenStateService.areSomeEntitiesSelected;
+ get areSomeEntitiesSelected$() {
+ return this._screenStateService.areSomeEntitiesSelected$;
}
get sortingOption(): SortingOption {
@@ -53,8 +57,8 @@ export abstract class NewBaseListingComponent {
return this.filterService.getFilter$(slug);
}
- protected get _filters(): FilterWrapper[] {
- return [];
+ get searchForm() {
+ return this._searchService.searchForm;
}
resetFilters() {
diff --git a/apps/red-ui/src/app/modules/shared/services/filter.service.ts b/apps/red-ui/src/app/modules/shared/services/filter.service.ts
index 3d53004a8..172f17ef4 100644
--- a/apps/red-ui/src/app/modules/shared/services/filter.service.ts
+++ b/apps/red-ui/src/app/modules/shared/services/filter.service.ts
@@ -68,11 +68,14 @@ export class FilterService {
}
getFilter$(slug: string): Observable {
- return this.getFilterWrapper$(slug).pipe(map(f => f.values));
+ return this.getFilterWrapper$(slug).pipe(
+ filter(f => f !== null && f !== undefined),
+ map(f => f?.values)
+ );
}
getFilterWrapper$(slug: string): Observable {
- return this.allFilters$.pipe(map(all => all.find(f => f.slug === slug)));
+ return this.allFilters$.pipe(map(all => all.find(f => f?.slug === slug)));
}
get allFilters$(): Observable {
@@ -90,6 +93,7 @@ export class FilterService {
});
});
});
+ this._allFilters$.next(this.filters);
this.filterEntities();
}
diff --git a/apps/red-ui/src/app/modules/shared/services/screen-state.service.ts b/apps/red-ui/src/app/modules/shared/services/screen-state.service.ts
index 3801c992a..a8bc4cfe7 100644
--- a/apps/red-ui/src/app/modules/shared/services/screen-state.service.ts
+++ b/apps/red-ui/src/app/modules/shared/services/screen-state.service.ts
@@ -61,8 +61,8 @@ export class ScreenStateService {
);
}
- get areSomeEntitiesSelected(): boolean {
- return this.selectedEntitiesIds.length > 0;
+ get areSomeEntitiesSelected$(): Observable {
+ return this.selectedEntitiesIds$.pipe(map(all => all.length > 0));
}
isSelected(entity: T): boolean {
@@ -81,7 +81,7 @@ export class ScreenStateService {
}
toggleSelectAll(): void {
- if (this.areSomeEntitiesSelected) return this.selectedEntitiesIds$.next([]);
+ if (this.areSomeEntitiesSelected$) return this.selectedEntitiesIds$.next([]);
this.setSelectedEntitiesIds(this._displayedEntitiesIds);
}