11import { FilterData } from "@mendix/filter-commons/typings/settings" ;
22import { EnumFilterStore } from "@mendix/widget-plugin-dropdown-filter/stores/EnumFilterStore" ;
33import { FilterAPI , getGlobalFilterContextObject } from "@mendix/widget-plugin-filtering/context" ;
4- import { value } from "@mendix/widget-plugin-filtering/result-meta" ;
4+ import { APIError } from "@mendix/widget-plugin-filtering/errors" ;
5+ import { error , value } from "@mendix/widget-plugin-filtering/result-meta" ;
56import { InputFilterStore , attrgroupFilterStore } from "@mendix/widget-plugin-filtering/stores/input/store-utils" ;
67import { ObservableFilterHost } from "@mendix/widget-plugin-filtering/typings/ObservableFilterHost" ;
78import { disposeBatch } from "@mendix/widget-plugin-mobx-kit/disposeBatch" ;
@@ -22,14 +23,24 @@ const { Provider } = getGlobalFilterContextObject();
2223
2324export class ColumnFilterStore implements IColumnFilterStore {
2425 private _widget : ReactNode ;
26+ private _error : APIError | null ;
2527 private _filterStore : FilterStore | null = null ;
2628 private _context : FilterAPI ;
2729 private _observerBag : ObserverBag ;
2830
2931 constructor ( props : ColumnsType , info : StaticInfo , dsViewState : FilterCondition | null , observerBag : ObserverBag ) {
3032 this . _observerBag = observerBag ;
3133 this . _widget = props . filter ;
32- this . _filterStore = this . createFilterStore ( props , dsViewState ) ;
34+ const storeResult = this . createFilterStore ( props , dsViewState ) ;
35+ if ( storeResult === null ) {
36+ this . _error = this . _filterStore = null ;
37+ } else if ( storeResult . hasError ) {
38+ this . _error = storeResult . error ;
39+ this . _filterStore = null ;
40+ } else {
41+ this . _error = null ;
42+ this . _filterStore = storeResult . value ;
43+ }
3344 this . _context = this . createContext ( this . _filterStore , info ) ;
3445
3546 makeObservable < this> ( this , {
@@ -45,9 +56,12 @@ export class ColumnFilterStore implements IColumnFilterStore {
4556 return disposeAll ;
4657 }
4758
48- private createFilterStore ( props : ColumnsType , dsViewState : FilterCondition | null ) : FilterStore | null {
59+ private createFilterStore (
60+ props : ColumnsType ,
61+ dsViewState : FilterCondition | null
62+ ) : ReturnType < typeof attrgroupFilterStore > | null {
4963 if ( isListAttributeValue ( props . attribute ) ) {
50- return attrgroupFilterStore ( props . attribute . type , [ props . attribute ] , dsViewState ) ;
64+ return attrgroupFilterStore ( props . attribute . type , props . attribute , dsViewState ) ;
5165 }
5266
5367 return null ;
@@ -57,10 +71,12 @@ export class ColumnFilterStore implements IColumnFilterStore {
5771 return {
5872 version : 3 ,
5973 parentChannelName : info . filtersChannelName ,
60- provider : value ( {
61- type : "direct" ,
62- store
63- } ) ,
74+ provider : this . _error
75+ ? error ( this . _error )
76+ : value ( {
77+ type : "direct" ,
78+ store
79+ } ) ,
6480 filterObserver : this . _observerBag . customFilterHost ,
6581 sharedInitFilter : this . _observerBag . sharedInitFilter
6682 } ;
0 commit comments