@@ -4,6 +4,7 @@ import { CustomFilterHost } from "@mendix/widget-plugin-filtering/stores/generic
4
4
import { DatasourceController } from "@mendix/widget-plugin-grid/query/DatasourceController" ;
5
5
import { QueryController } from "@mendix/widget-plugin-grid/query/query-controller" ;
6
6
import { RefreshController } from "@mendix/widget-plugin-grid/query/RefreshController" ;
7
+ import { clearAllPages , selectAllPages } from "@mendix/widget-plugin-grid/selection/select-all-pages" ;
7
8
import { SelectionCountStore } from "@mendix/widget-plugin-grid/selection/stores/SelectionCountStore" ;
8
9
import { BaseControllerHost } from "@mendix/widget-plugin-mobx-kit/BaseControllerHost" ;
9
10
import { disposeBatch } from "@mendix/widget-plugin-mobx-kit/disposeBatch" ;
@@ -17,11 +18,10 @@ import { DerivedLoaderController } from "../../controllers/DerivedLoaderControll
17
18
import { PaginationController } from "../../controllers/PaginationController" ;
18
19
import { ProgressStore } from "../../features/data-export/ProgressStore" ;
19
20
import { SelectAllProgressStore } from "../../features/multi-page-selection/SelectAllProgressStore" ;
20
- import { MultiPageSelectionController } from "../../features/multi-page-selection/MultiPageSelectionController" ;
21
21
import { StaticInfo } from "../../typings/static-info" ;
22
+ import { SelectActionHelper } from "../SelectActionHelper" ;
22
23
import { ColumnGroupStore } from "./ColumnGroupStore" ;
23
24
import { GridPersonalizationStore } from "./GridPersonalizationStore" ;
24
- import { SelectActionHelper } from "../SelectActionHelper" ;
25
25
26
26
type RequiredProps = Pick <
27
27
DatagridContainerProps ,
@@ -55,7 +55,8 @@ export class RootGridStore extends BaseControllerHost {
55
55
staticInfo : StaticInfo ;
56
56
exportProgressCtrl : ProgressStore ;
57
57
selectAllProgressStore : SelectAllProgressStore ;
58
- multiPageSelectionCtrl : MultiPageSelectionController ;
58
+ private selectAllAbortController ?: AbortController ;
59
+ private selectAllLocked = false ;
59
60
loaderCtrl : DerivedLoaderController ;
60
61
paginationCtrl : PaginationController ;
61
62
readonly filterAPI : FilterAPI ;
@@ -103,11 +104,6 @@ export class RootGridStore extends BaseControllerHost {
103
104
104
105
this . selectAllProgressStore = new SelectAllProgressStore ( ) ;
105
106
106
- this . multiPageSelectionCtrl = new MultiPageSelectionController ( this , {
107
- query,
108
- progressStore : this . selectAllProgressStore
109
- } ) ;
110
-
111
107
new DatasourceParamsController ( this , {
112
108
query,
113
109
filterHost : combinedFilter ,
@@ -146,33 +142,45 @@ export class RootGridStore extends BaseControllerHost {
146
142
}
147
143
148
144
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 ) {
153
146
return ;
154
147
}
155
148
156
149
// 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 ;
161
151
162
152
if ( ! canSelect ) {
163
153
selectActionHelper . onSelectAll ( "selectAll" ) ;
164
154
return ;
165
155
}
166
156
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
+ } ) ;
169
166
170
167
if ( ! success ) {
171
168
selectActionHelper . onSelectAll ( "selectAll" ) ;
172
169
}
170
+ this . selectAllLocked = false ;
171
+ this . selectAllAbortController = undefined ;
172
+ }
173
+
174
+ async clearAllPages ( ) : Promise < void > {
175
+ clearAllPages ( this . gate ) ;
173
176
}
174
177
175
178
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
+ }
177
185
}
178
186
}
0 commit comments