From 515ae6f7543d6dfcb578bd8c3ce2ee87d8709142 Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Fri, 19 Aug 2022 07:43:52 +0000 Subject: [PATCH] checkbox bug fix --- .../components/list.component.html | 36 +++++++------- .../components/list.component.ts | 47 +++++++++++++++---- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/src/app/modules/admin/member/partner-recommendation/components/list.component.html b/src/app/modules/admin/member/partner-recommendation/components/list.component.html index 3514db2..74c23c2 100644 --- a/src/app/modules/admin/member/partner-recommendation/components/list.component.html +++ b/src/app/modules/admin/member/partner-recommendation/components/list.component.html @@ -25,21 +25,23 @@ @@ -178,21 +180,23 @@ diff --git a/src/app/modules/admin/member/partner-recommendation/components/list.component.ts b/src/app/modules/admin/member/partner-recommendation/components/list.component.ts index 023eb50..6672632 100644 --- a/src/app/modules/admin/member/partner-recommendation/components/list.component.ts +++ b/src/app/modules/admin/member/partner-recommendation/components/list.component.ts @@ -115,7 +115,8 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { selectedPartnerRecommendation?: PartnerRecommendation; pagination?: PartnerRecommendationPagination; - selection = new SelectionModel(true, []); + registSelection = new SelectionModel(true, []); + removeSelection = new SelectionModel(true, []); private _unsubscribeAll: Subject = new Subject(); @@ -234,30 +235,56 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { // ----------------------------------------------------------------------------------------------------- /** Selects all rows if they are not all selected; otherwise clear selection. */ - __toggleAllRows() { - if (this.__isAllSelected()) { - this.selection.clear(); + __registToggleAllRows() { + if (this.__registIsAllSelected()) { + this.registSelection.clear(); return; } - this.selection.select(...this.registPartnerStoreDataSource.data); + this.registSelection.select(...this.registPartnerStoreDataSource.data); } - __isAllSelected() { - const numSelected = this.selection.selected.length; + __registIsAllSelected() { + const numSelected = this.registSelection.selected.length; const numRows = this.registPartnerStoreDataSource.data.length; return numSelected === numRows; } /** The label for the checkbox on the passed row */ - __checkboxLabel(row?: MemberModel): string { + __registCheckboxLabel(row?: MemberModel): string { if (!row) { - return `${this.__isAllSelected() ? 'deselect' : 'select'} all`; + return `${this.__registIsAllSelected() ? 'deselect' : 'select'} all`; } return `${ - this.selection.isSelected(row) ? 'deselect' : 'select' + this.registSelection.isSelected(row) ? 'deselect' : 'select' } row ${row.getUsername()}`; } + + __removeToggleAllRows() { + if (this.__removeIsAllSelected()) { + this.removeSelection.clear(); + return; + } + + this.removeSelection.select(...this.removePartnerStoreDataSource.data); + } + + __removeIsAllSelected() { + const numSelected = this.removeSelection.selected.length; + const numRows = this.removePartnerStoreDataSource.data.length; + return numSelected === numRows; + } + + /** The label for the checkbox on the passed row */ + __removeCheckboxLabel(row?: MemberModel): string { + if (!row) { + return `${this.__removeIsAllSelected() ? 'deselect' : 'select'} all`; + } + return `${ + this.removeSelection.isSelected(row) ? 'deselect' : 'select' + } row ${row.getUsername()}`; + } + /** * Create product */