@@ -4,6 +4,7 @@ import { CustomFilterHost } from "@mendix/widget-plugin-filtering/stores/generic
44import { DatasourceController } from "@mendix/widget-plugin-grid/query/DatasourceController" ;
55import { QueryController } from "@mendix/widget-plugin-grid/query/query-controller" ;
66import { RefreshController } from "@mendix/widget-plugin-grid/query/RefreshController" ;
7+ import { clearAllPages , selectAllPages } from "@mendix/widget-plugin-grid/selection/select-all-pages" ;
78import { SelectionCountStore } from "@mendix/widget-plugin-grid/selection/stores/SelectionCountStore" ;
89import { BaseControllerHost } from "@mendix/widget-plugin-mobx-kit/BaseControllerHost" ;
910import { disposeBatch } from "@mendix/widget-plugin-mobx-kit/disposeBatch" ;
@@ -17,11 +18,10 @@ import { DerivedLoaderController } from "../../controllers/DerivedLoaderControll
1718import { PaginationController } from "../../controllers/PaginationController" ;
1819import { ProgressStore } from "../../features/data-export/ProgressStore" ;
1920import { SelectAllProgressStore } from "../../features/multi-page-selection/SelectAllProgressStore" ;
20- import { MultiPageSelectionController } from "../../features/multi-page-selection/MultiPageSelectionController" ;
2121import { StaticInfo } from "../../typings/static-info" ;
22+ import { SelectActionHelper } from "../SelectActionHelper" ;
2223import { ColumnGroupStore } from "./ColumnGroupStore" ;
2324import { GridPersonalizationStore } from "./GridPersonalizationStore" ;
24- import { SelectActionHelper } from "../SelectActionHelper" ;
2525
2626type RequiredProps = Pick <
2727 DatagridContainerProps ,
@@ -55,7 +55,8 @@ export class RootGridStore extends BaseControllerHost {
5555 staticInfo : StaticInfo ;
5656 exportProgressCtrl : ProgressStore ;
5757 selectAllProgressStore : SelectAllProgressStore ;
58- multiPageSelectionCtrl : MultiPageSelectionController ;
58+ private selectAllAbortController ?: AbortController ;
59+ private selectAllLocked = false ;
5960 loaderCtrl : DerivedLoaderController ;
6061 paginationCtrl : PaginationController ;
6162 readonly filterAPI : FilterAPI ;
@@ -103,11 +104,6 @@ export class RootGridStore extends BaseControllerHost {
103104
104105 this . selectAllProgressStore = new SelectAllProgressStore ( ) ;
105106
106- this . multiPageSelectionCtrl = new MultiPageSelectionController ( this , {
107- query,
108- progressStore : this . selectAllProgressStore
109- } ) ;
110-
111107 new DatasourceParamsController ( this , {
112108 query,
113109 filterHost : combinedFilter ,
@@ -146,33 +142,45 @@ export class RootGridStore extends BaseControllerHost {
146142 }
147143
148144 async startMultiPageSelectAll ( selectActionHelper : SelectActionHelper ) : Promise < void > {
149- const ds = this . gate . props . datasource ;
150- const selectionHelper = this . basicData . currentSelectionHelper ;
151-
152- if ( ! selectionHelper ) {
145+ if ( this . selectAllLocked ) {
153146 return ;
154147 }
155148
156149 // Check if multi-page selection is possible
157- const canSelect = this . multiPageSelectionCtrl . canSelectAllPages (
158- selectActionHelper . canSelectAllPages ,
159- selectActionHelper . selectionType
160- ) ;
150+ const canSelect = selectActionHelper . canSelectAllPages ;
161151
162152 if ( ! canSelect ) {
163153 selectActionHelper . onSelectAll ( "selectAll" ) ;
164154 return ;
165155 }
166156
167- // Delegate to the controller
168- const success = await this . multiPageSelectionCtrl . selectAllPages ( ds , selectionHelper ) ;
157+ this . selectAllLocked = true ;
158+ this . selectAllAbortController = new AbortController ( ) ;
159+ const success = await selectAllPages ( {
160+ query : this . query as QueryController ,
161+ gate : this . gate as any ,
162+ progress : this . selectAllProgressStore ,
163+ bufferSize : selectActionHelper . selectAllPagesBufferSize ,
164+ signal : this . selectAllAbortController . signal
165+ } ) ;
169166
170167 if ( ! success ) {
171168 selectActionHelper . onSelectAll ( "selectAll" ) ;
172169 }
170+ this . selectAllLocked = false ;
171+ this . selectAllAbortController = undefined ;
172+ }
173+
174+ async clearAllPages ( ) : Promise < void > {
175+ clearAllPages ( this . gate ) ;
173176 }
174177
175178 abortMultiPageSelect ( ) : void {
176- this . multiPageSelectionCtrl . abort ( ) ;
179+ if ( this . selectAllAbortController ) {
180+ this . selectAllAbortController . abort ( ) ;
181+ this . selectAllProgressStore . oncancel ( ) ;
182+ this . selectAllLocked = false ;
183+ this . selectAllAbortController = undefined ;
184+ }
177185 }
178186}
0 commit comments