Skip to content

Commit 60ee798

Browse files
committed
chore: fix issue with ref
1 parent c2a80d2 commit 60ee798

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/DatagridDropdownFilter.editorConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function getProperties(values: DatagridDropdownFilterPreviewProps, defaul
3636
}
3737

3838
function attrGroupProperties(values: DatagridDropdownFilterPreviewProps, defaultProperties: Properties): Properties {
39-
hidePropertiesIn(defaultProperties, values, ["ref", "refOptions", "fetchOptionsLazy"]);
39+
hidePropertiesIn(defaultProperties, values, ["refEntity", "refOptions", "refCaption", "fetchOptionsLazy"]);
4040

4141
if (values.attrChoice === "auto") {
4242
hidePropertyIn(defaultProperties, {} as { linkedDs: unknown }, "linkedDs");

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/DatagridDropdownFilter.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<!-- end: Attr type -->
6363

6464
<!-- start: Ref type -->
65-
<property key="ref" type="association" selectableObjects="refOptions" required="true" dataSource="linkedDs" isMetaData="true">
65+
<property key="refEntity" type="association" selectableObjects="refOptions" required="true" dataSource="linkedDs" isMetaData="true">
6666
<caption>Entity</caption>
6767
<description>Set the entity to enable filtering over association.</description>
6868
<associationTypes>

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/hocs/withLinkedRefStore.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import { DatagridDropdownFilterContainerProps } from "../../typings/DatagridDrop
1111
import { useSetup } from "@mendix/widget-plugin-mobx-kit/react/useSetup";
1212
import { RefFilterAPI } from "../components/typings";
1313

14-
type WidgetProps = Pick<DatagridDropdownFilterContainerProps, "name" | "ref" | "refOptions" | "refCaption">;
14+
type WidgetProps = Pick<DatagridDropdownFilterContainerProps, "name" | "refEntity" | "refOptions" | "refCaption">;
1515

1616
export interface RequiredProps {
1717
name: string;
18-
ref: AssociationMetaData;
18+
refEntity: AssociationMetaData;
1919
refOptions: ListValue;
2020
refCaption: ListAttributeValue<string>;
2121
searchAttrId: ListAttributeValue["id"];
@@ -41,29 +41,30 @@ export function withLinkedRefStore<P extends WidgetProps>(Cmp: Component<P & Ref
4141
}
4242

4343
function mapProps(props: WidgetProps): RequiredProps {
44-
if (!props.ref) {
45-
throw new Error("RefFilterStoreProvider: ref is required");
44+
if (!props.refEntity) {
45+
throw new Error("RefFilterStoreProvider: refEntity is required");
4646
}
47+
4748
if (!props.refOptions) {
4849
throw new Error("RefFilterStoreProvider: refOptions is required");
4950
}
51+
5052
if (!props.refCaption) {
5153
throw new Error("RefFilterStoreProvider: refCaption is required");
5254
}
5355
return {
5456
name: props.name,
55-
ref: props.ref,
57+
refEntity: props.refEntity,
5658
refOptions: props.refOptions,
5759
refCaption: props.refCaption,
5860
searchAttrId: props.refCaption.id
5961
};
6062
}
6163

6264
function useGate(props: WidgetProps): DerivedPropsGate<RequiredProps> {
63-
const gateProps = useMemo(() => mapProps(props), [props]);
64-
const gp = useConst(() => new GateProvider(gateProps));
65+
const gp = useConst(() => new GateProvider(mapProps(props)));
6566
useEffect(() => {
66-
gp.setProps(gateProps);
67+
gp.setProps(mapProps(props));
6768
});
6869
return gp.gate;
6970
}

packages/pluggableWidgets/datagrid-dropdown-filter-web/typings/DatagridDropdownFilterProps.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface DatagridDropdownFilterContainerProps {
3434
attr: AttributeMetaData<string | boolean>;
3535
auto: boolean;
3636
filterOptions: FilterOptionsType[];
37-
ref: AssociationMetaData;
37+
refEntity: AssociationMetaData;
3838
refOptions?: ListValue;
3939
refCaption?: ListAttributeValue<string>;
4040
fetchOptionsLazy: boolean;
@@ -66,7 +66,7 @@ export interface DatagridDropdownFilterPreviewProps {
6666
attr: string;
6767
auto: boolean;
6868
filterOptions: FilterOptionsPreviewType[];
69-
ref: string;
69+
refEntity: string;
7070
refOptions: {} | { caption: string } | { type: string } | null;
7171
refCaption: string;
7272
fetchOptionsLazy: boolean;

packages/shared/widget-plugin-dropdown-filter/src/containers/RefFilterContainer.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { createElement, CSSProperties, useEffect } from "react";
1313
import { useFrontendType } from "../helpers/useFrontendType";
1414
import { useOnScrollBottom } from "@mendix/widget-plugin-hooks/useOnScrollBottom";
1515
import { SelectedItemsStyleEnum, SelectionMethodEnum } from "../typings/widget";
16+
import { useSetup } from "@mendix/widget-plugin-mobx-kit/react/useSetup";
1617
import { useConst } from "@mendix/widget-plugin-mobx-kit/react/useConst";
1718
import { GateProvider } from "@mendix/widget-plugin-mobx-kit/GateProvider";
1819
import { DerivedPropsGate } from "@mendix/widget-plugin-mobx-kit/props-gate";
@@ -52,7 +53,7 @@ function Container(props: RefFilterContainerProps): React.ReactElement {
5253

5354
const SelectWidget = observer(function SelectWidget(props: RefFilterContainerProps): React.ReactElement {
5455
const gate = useGate(props);
55-
const ctrl1 = useConst(() => new RefSelectController({ gate }));
56+
const ctrl1 = useSetup(() => new RefSelectController({ gate }));
5657
const handleMenuScroll = useOnScrollBottom(ctrl1.handleMenuScrollEnd, { triggerZoneHeight: 100 });
5758

5859
usePickerJSActions(ctrl1, props);
@@ -76,7 +77,7 @@ const SelectWidget = observer(function SelectWidget(props: RefFilterContainerPro
7677

7778
const ComboboxWidget = observer(function ComboboxWidget(props: RefFilterContainerProps): React.ReactElement {
7879
const gate = useGate(props);
79-
const ctrl2 = useConst(() => new RefComboboxController({ gate }));
80+
const ctrl2 = useSetup(() => new RefComboboxController({ gate }));
8081
const handleMenuScroll = useOnScrollBottom(ctrl2.handleMenuScrollEnd, { triggerZoneHeight: 100 });
8182

8283
usePickerJSActions(ctrl2, props);
@@ -99,7 +100,7 @@ const ComboboxWidget = observer(function ComboboxWidget(props: RefFilterContaine
99100

100101
const TagPickerWidget = observer(function TagPickerWidget(props: RefFilterContainerProps): React.ReactElement {
101102
const gate = useGate(props);
102-
const ctrl3 = useConst(() => new RefTagPickerController({ gate }));
103+
const ctrl3 = useSetup(() => new RefTagPickerController({ gate }));
103104
const handleMenuScroll = useOnScrollBottom(ctrl3.handleMenuScrollEnd, { triggerZoneHeight: 100 });
104105

105106
usePickerJSActions(ctrl3, props);

packages/shared/widget-plugin-dropdown-filter/src/stores/RefFilterStore.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type ListAttributeId = AttributeMetaData["id"];
1313

1414
export interface RefFilterStoreProps {
1515
fetchOptionsLazy?: boolean;
16-
ref: AssociationMetaData;
16+
refEntity: AssociationMetaData;
1717
refCaption: CaptionAccessor;
1818
refOptions: ListValue;
1919
searchAttrId?: ListAttributeId;
@@ -55,9 +55,9 @@ export class RefFilterStore extends BaseSelectStore {
5555
this.datasource.setLimit(0);
5656
}
5757

58-
makeObservable<this, "datasource" | "ref" | "caption" | "fetchReady">(this, {
58+
makeObservable<this, "datasource" | "refEntity" | "caption" | "fetchReady">(this, {
5959
datasource: computed,
60-
ref: computed,
60+
refEntity: computed,
6161
caption: computed,
6262
options: computed,
6363
hasMore: computed,
@@ -80,8 +80,8 @@ export class RefFilterStore extends BaseSelectStore {
8080
return this.gate.props.refOptions;
8181
}
8282

83-
private get ref(): AssociationMetaData {
84-
return this.gate.props.ref;
83+
private get refEntity(): AssociationMetaData {
84+
return this.gate.props.refEntity;
8585
}
8686

8787
private get caption(): CaptionAccessor {
@@ -122,7 +122,7 @@ export class RefFilterStore extends BaseSelectStore {
122122
const obj = this.selectedItems.find(o => o.id === guid);
123123

124124
if (obj) {
125-
return [contains(association(this.ref.id), literal(obj))];
125+
return [contains(association(this.refEntity.id), literal(obj))];
126126
}
127127

128128
const viewExp = this.initCondArray.find(e => {

0 commit comments

Comments
 (0)