@@ -203,8 +203,18 @@ export interface IGlobalListAction<T> extends IOptionalAction<T> {
203
203
action : ( ) => void ;
204
204
}
205
205
206
+ /**
207
+ * Class to support a single multi filter entry/drop down
208
+ */
206
209
export class MultiFilterManager < T > {
210
+ /**
211
+ * Supporting dependencies ready and there are items available to select
212
+ */
207
213
public filterIsReady$ : Observable < boolean > ;
214
+ /**
215
+ * Supporting dependencies ready and the items to select have been fetched (but may be zero)
216
+ */
217
+ public filterIsInitialised$ : Observable < boolean > ;
208
218
public filterItems$ : Observable < IListMultiFilterConfigItem [ ] > ;
209
219
public hasItems$ : Observable < boolean > ;
210
220
public hasOneOrLessItems$ : Observable < boolean > ;
@@ -225,6 +235,7 @@ export class MultiFilterManager<T> {
225
235
this . hasOneOrLessItems$ = this . filterItems$ . pipe ( map ( items => items . length <= 1 ) ) ;
226
236
this . hasItems$ = this . filterItems$ . pipe ( map ( items => ! ! items . length ) ) ;
227
237
this . filterIsReady$ = this . getReadyObservable ( multiFilterConfig , dataSource , this . hasItems$ ) ;
238
+ this . filterIsInitialised$ = this . getInitialisedObservable ( multiFilterConfig , dataSource , this . filterItems$ ) ;
228
239
229
240
// Also select the first option if configured
230
241
if ( multiFilterConfig . autoSelectFirst ) {
@@ -251,6 +262,21 @@ export class MultiFilterManager<T> {
251
262
) ;
252
263
}
253
264
265
+ private getInitialisedObservable (
266
+ multiFilterConfig : IListMultiFilterConfig ,
267
+ dataSource : IListDataSource < T > ,
268
+ filterItems$ : Observable < IListMultiFilterConfigItem [ ] >
269
+ ) {
270
+ return combineLatest (
271
+ dataSource . isLoadingPage$ ,
272
+ multiFilterConfig . loading$ ,
273
+ filterItems$ ,
274
+ ) . pipe (
275
+ map ( ( [ fetchingListPage , fetchingFilter , filterItems ] ) => ( ! fetchingListPage && ! fetchingFilter ) && ! ! filterItems ) ,
276
+ startWith ( false )
277
+ ) ;
278
+ }
279
+
254
280
private getItemObservable ( multiFilterConfig : IListMultiFilterConfig ) {
255
281
return multiFilterConfig . list$ . pipe (
256
282
map ( list => list ? list : [ ] )
0 commit comments