diff --git a/packages/frontend/src/app/modules/general/components/navbar/navbar.component.html b/packages/frontend/src/app/modules/general/components/navbar/navbar.component.html index 1d7758034e..37af4e928f 100644 --- a/packages/frontend/src/app/modules/general/components/navbar/navbar.component.html +++ b/packages/frontend/src/app/modules/general/components/navbar/navbar.component.html @@ -157,19 +157,6 @@ Admin DomiFa - - - Créer une demande -
-

Domiciliés

-
- +

+ Domiciliés +

+
+ - -
-
- -
@@ -289,6 +299,7 @@

Domiciliés

(); - public usagersRadiesTotalCount = 0; + public usagers: UsagerFormModel[] = []; public filteredUsagers: UsagerFormModel[] = []; @@ -130,6 +130,7 @@ export class ManageUsagersPageComponent private subscription = new Subscription(); public selectedRefs: Set = new Set(); + public selectAllCheckboxes = false; constructor( private readonly usagerService: ManageUsagersService, @@ -149,7 +150,6 @@ export class ManageUsagersPageComponent this.filters.page = 1; this.titleService.setTitle("Gestion des domiciliés - DomiFa"); this.filters$.next(this.filters); - this.usagersRadiesTotalCount = 0; } ngAfterViewInit() { @@ -288,10 +288,10 @@ export class ManageUsagersPageComponent ) .subscribe(({ filters, usagers, usagersRadiesTotalCount }) => { if (filters && usagers) { - this.usagersRadiesTotalCount = usagersRadiesTotalCount; + this.countRadiesLoaded(usagers); this.usagersCountByStatus = calculateUsagersCountByStatus( usagers, - this.usagersRadiesTotalCount + usagersRadiesTotalCount ); this.applyFilters({ filters, allUsagers: usagers }); } @@ -343,7 +343,7 @@ export class ManageUsagersPageComponent filters: UsagersFilterCriteria ): Observable { if ( - this.usagersCountByStatus.RADIE !== this.usagersRadiesTotalCount && + this.usagersCountByStatus.RADIE !== this.usagersRadiesLoadedCount && !chargerTousRadies && (this.filters.statut === "TOUS" || this.filters.statut === "RADIE") ) { @@ -496,16 +496,7 @@ export class ManageUsagersPageComponent allUsagers: UsagerLight[]; }): void { this.searching = true; - - let radiesCount = 0; - for (const usager of allUsagers) { - if (usager.statut === "RADIE") { - radiesCount++; - } - } - - this.usagersRadiesLoadedCount = radiesCount; - + this.resetCheckboxes(); localStorage.setItem("MANAGE_USAGERS", JSON.stringify(filters)); this.filteredUsagers = usagersFilter.filter(allUsagers, { @@ -532,8 +523,20 @@ export class ManageUsagersPageComponent this.filters.interactionType = null; } + public countRadiesLoaded = ( + allUsagers: Pick[] + ): void => { + let radiesCount = 0; + for (const usager of allUsagers) { + if (usager.statut === "RADIE") { + radiesCount++; + } + } + + this.usagersRadiesLoadedCount = radiesCount; + }; private applySorting(): void { - this.selectedRefs = new Set(); + this.resetCheckboxes(); if (!this.filteredUsagers.length) { this.usagers = []; return; @@ -593,4 +596,9 @@ export class ManageUsagersPageComponent const filters = localStorage.getItem("MANAGE_USAGERS"); return filters === null ? {} : JSON.parse(filters); } + + private resetCheckboxes() { + this.selectAllCheckboxes = false; + this.selectedRefs.clear(); + } } diff --git a/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.component.ts b/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.component.ts index a935440a61..2a4fd0fee9 100644 --- a/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.component.ts +++ b/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.component.ts @@ -32,7 +32,6 @@ import { UserStructure } from "@domifa/common"; selector: "app-manage-manage-usagers-table", templateUrl: "./manage-usagers-table.html", styleUrls: ["./manage-usagers-table.scss"], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class ManageUsagersTableComponent implements OnDestroy { @@ -42,6 +41,9 @@ export class ManageUsagersTableComponent implements OnDestroy { @Input() public filters!: UsagersFilterCriteria; + @Input() + public selectAllCheckboxes = false; + @Input() public loading!: boolean; @@ -75,7 +77,7 @@ export class ManageUsagersTableComponent implements OnDestroy { } public toggleSelection(id: number) { - if (this.selectedRefs.has(id)) { + if (!this.selectedRefs.has(id)) { this.selectedRefs.add(id); } else { this.selectedRefs.delete(id); @@ -103,7 +105,7 @@ export class ManageUsagersTableComponent implements OnDestroy { this.subscription.unsubscribe(); } - getVisibleCheckboxIds(): void { + public getVisibleCheckboxIds(): void { const checkboxes = document.querySelectorAll( 'table input[type="checkbox"]' ); @@ -118,7 +120,6 @@ export class ManageUsagersTableComponent implements OnDestroy { ) { const rect = checkbox.getBoundingClientRect(); - // Vérifie si la checkbox est dans le viewport if (rect.top >= 0 && rect.bottom <= viewportHeight) { const id = checkbox.id?.replace("select-", ""); if (id) { @@ -128,13 +129,14 @@ export class ManageUsagersTableComponent implements OnDestroy { } }); - visibleIds.forEach((id) => { - if (this.selectedRefs.has(id)) { - this.selectedRefs.delete(id); // Supprime si présent - } else { - this.selectedRefs.add(id); // Ajoute si absent - } - }); - console.log(visibleIds); + if (!this.selectAllCheckboxes) { + this.selectedRefs.clear(); + } else { + visibleIds.forEach((id) => { + if (!this.selectedRefs.has(id)) { + this.selectedRefs.add(id); + } + }); + } } } diff --git a/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.html b/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.html index 9620121ff7..56a0020b2f 100644 --- a/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.html +++ b/packages/frontend/src/app/modules/manage-usagers/components/manage-usagers-table/manage-usagers-table.html @@ -2,7 +2,7 @@
{{ selectedRefs.size }} selectionnés
@@ -81,7 +81,8 @@ diff --git a/packages/frontend/src/app/modules/shared/constants/FA_ICONS.const.ts b/packages/frontend/src/app/modules/shared/constants/FA_ICONS.const.ts index 00fcb2f8d8..9f1d8a7b4f 100644 --- a/packages/frontend/src/app/modules/shared/constants/FA_ICONS.const.ts +++ b/packages/frontend/src/app/modules/shared/constants/FA_ICONS.const.ts @@ -25,6 +25,7 @@ import { faCheckCircle, faCircle, faCircleNotch, + faCircleXmark, faDownload, faEllipsisVertical, faExclamationCircle, @@ -105,6 +106,7 @@ export const FA_ICONS: IconDefinition[] = [ faRss, faSearch, faSignOutAlt, + faCircleXmark, faSms, faSort, faSortAmountDown, diff --git a/packages/frontend/src/app/modules/usager-shared/components/delete-usager/delete-usager.component.spec.ts b/packages/frontend/src/app/modules/usager-shared/components/delete-usager/delete-usager.component.spec.ts index 05aa479e94..c8958d5ee0 100644 --- a/packages/frontend/src/app/modules/usager-shared/components/delete-usager/delete-usager.component.spec.ts +++ b/packages/frontend/src/app/modules/usager-shared/components/delete-usager/delete-usager.component.spec.ts @@ -28,7 +28,7 @@ describe("DeleteUsagerComponent", () => { fixture = TestBed.createComponent(DeleteUsagerComponent); component = fixture.componentInstance; - component.selectedRefs = []; + component.selectedRefs = new Set(); fixture.detectChanges(); });