Skip to content

[WC-2870] filtering dropdown #1530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: WC2869-improved-filtering-date-time
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
23b13a8
feat: add new set of properties
iobuhov Apr 11, 2025
594daa2
chore: split code into packages
iobuhov Apr 18, 2025
5700ddc
chore: fix imports and remove old modules
iobuhov Apr 18, 2025
1ba7180
chore: move tests
iobuhov Apr 18, 2025
22737c6
build: fix all type issues
iobuhov Apr 18, 2025
dfd8d6a
refactor(!): remove legacy provider
iobuhov Apr 18, 2025
d57bbd7
chore: move hook
iobuhov Apr 22, 2025
b15cfc1
refactor: remove header filter
iobuhov Apr 22, 2025
fbfa539
refactor: remove header filter
iobuhov Apr 23, 2025
721d55b
chore: introduce wide filter api
iobuhov Apr 23, 2025
b7ed3da
chore: update imports
iobuhov Apr 23, 2025
c58202c
chore: remove dead code
iobuhov Apr 23, 2025
b47d003
chore: start migrating dd filter
iobuhov Apr 23, 2025
334eb2b
refactor: switch to gate
iobuhov Apr 24, 2025
e6c8c04
chore: update type
iobuhov Apr 24, 2025
7732782
chore: migrate to gate
iobuhov Apr 24, 2025
52228b7
refactor: move static filter container
iobuhov Apr 24, 2025
6a2c384
chore: update ref filter props
iobuhov Apr 24, 2025
7563cdf
chore: create new component tree
iobuhov Apr 24, 2025
82dcac9
chore: finish enum filter
iobuhov Apr 25, 2025
4d5cceb
feat: add linked ref store
iobuhov Apr 25, 2025
bc71bf7
feat: switch to assc metadata
iobuhov Apr 25, 2025
1016fad
chore: restore code
iobuhov Apr 25, 2025
c2a80d2
feat: first implementation of linked dd filter
iobuhov Apr 28, 2025
60ee798
chore: fix issue with ref
iobuhov Apr 28, 2025
a5272e6
refactor: change to useSetup
iobuhov Apr 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"verify": "rui-verify-package-format"
},
"dependencies": {
"@mendix/widget-plugin-dropdown-filter": "workspace:^",
"@mendix/widget-plugin-external-events": "workspace:*",
"@mendix/widget-plugin-filtering": "workspace:*",
"classnames": "^2.3.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hidePropertyIn, Problem, Properties } from "@mendix/pluggable-widgets-tools";
import { hidePropertiesIn, hidePropertyIn, Problem, Properties } from "@mendix/pluggable-widgets-tools";
import { chevronDownIcon, chevronDownIconDark } from "@mendix/widget-plugin-filtering/preview/editor-preview-icons";
import {
ContainerProps,
Expand All @@ -13,8 +13,10 @@ export function getProperties(values: DatagridDropdownFilterPreviewProps, defaul
const showSelectedItemsStyle = values.filterable && values.multiSelect;
const showSelectionMethod = showSelectedItemsStyle && values.selectedItemsStyle === "boxes";

if (values.auto) {
hidePropertyIn(defaultProperties, values, "filterOptions");
if (values.baseType === "attr") {
defaultProperties = attrGroupProperties(values, defaultProperties);
} else {
hidePropertiesIn(defaultProperties, values, ["attr", "attrChoice", "filterOptions", "auto"]);
}

if (values.filterable) {
Expand All @@ -33,6 +35,21 @@ export function getProperties(values: DatagridDropdownFilterPreviewProps, defaul
return defaultProperties;
}

function attrGroupProperties(values: DatagridDropdownFilterPreviewProps, defaultProperties: Properties): Properties {
hidePropertiesIn(defaultProperties, values, ["refEntity", "refOptions", "refCaption", "fetchOptionsLazy"]);

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

if (values.auto) {
hidePropertyIn(defaultProperties, values, "filterOptions");
}

return defaultProperties;
}

export const getPreview = (values: DatagridDropdownFilterPreviewProps, isDarkMode: boolean): StructurePreviewProps => {
const palette = structurePreviewPalette[isDarkMode ? "dark" : "light"];
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { enableStaticRendering } from "mobx-react-lite";
enableStaticRendering(true);

import { createElement, ReactElement } from "react";
import { DatagridDropdownFilterPreviewProps } from "../typings/DatagridDropdownFilterProps";
import { parseStyle } from "@mendix/widget-plugin-platform/preview/parse-style";
import { Select } from "@mendix/widget-plugin-filtering/controls/select/Select";
import { Select } from "@mendix/widget-plugin-dropdown-filter/controls/select/Select";

enableStaticRendering(true);

function Preview(props: DatagridDropdownFilterPreviewProps): ReactElement {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
import { createElement, ReactElement } from "react";
import { withPreloader } from "@mendix/widget-plugin-platform/hoc/withPreloader";
import { DatagridDropdownFilterContainerProps } from "../typings/DatagridDropdownFilterProps";
import { StaticFilterContainer } from "./components/StaticFilterContainer";
import { withSelectFilterAPI, Select_FilterAPIv2 } from "./hocs/withSelectFilterAPI";
import { RefFilterContainer } from "./components/RefFilterContainer";
import { AttrFilter } from "./components/AttrFilter";
import { RefFilter } from "./components/RefFilter";

function Container(props: DatagridDropdownFilterContainerProps & Select_FilterAPIv2): React.ReactElement {
const commonProps = {
ariaLabel: props.ariaLabel?.value,
className: props.class,
tabIndex: props.tabIndex,
styles: props.style,
onChange: props.onChange,
valueAttribute: props.valueAttribute,
parentChannelName: props.parentChannelName,
name: props.name,
multiselect: props.multiSelect,
emptyCaption: props.emptyOptionCaption?.value,
defaultValue: props.defaultValue?.value,
filterable: props.filterable,
selectionMethod: props.selectionMethod,
selectedItemsStyle: props.selectedItemsStyle,
clearable: props.clearable
};

if (props.filterStore.storeType === "refselect") {
return <RefFilterContainer {...commonProps} filterStore={props.filterStore} />;
function Container(props: DatagridDropdownFilterContainerProps): ReactElement {
if (props.baseType === "attr") {
return <AttrFilter {...props} />;
}

return (
<StaticFilterContainer {...commonProps} filterStore={props.filterStore} filterOptions={props.filterOptions} />
);
return <RefFilter {...props} />;
}

const container = withPreloader(Container, props => props.defaultValue?.status === "loading");

const Widget = withSelectFilterAPI(container);
const DatagridDropdownFilter = withPreloader(Container, props => props.defaultValue?.status === "loading");

export default function DatagridDropdownFilter(props: DatagridDropdownFilterContainerProps): ReactElement {
return <Widget {...props} />;
}
export default DatagridDropdownFilter;
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,41 @@
<helpUrl>https://docs.mendix.com/appstore/modules/data-grid-2#7-2-drop-down-filter</helpUrl>
<properties>
<propertyGroup caption="General">
<propertyGroup caption="General">
<propertyGroup caption="Data source">
<property key="baseType" type="enumeration" defaultValue="attr">
<caption>Filter by</caption>
<description />
<enumerationValues>
<enumerationValue key="attr">Attribute</enumerationValue>
<enumerationValue key="ref">Association</enumerationValue>
</enumerationValues>
</property>
<property key="linkedDs" type="datasource" isLinked="true" isList="true">
<caption>Datasource to Filter</caption>
<description />
</property>

<!-- start: Attr type -->
<property key="attrChoice" type="enumeration" defaultValue="auto">
<caption>Attribute config</caption>
<description>"Auto" works only when the widget is placed in a Data grid column.</description>
<enumerationValues>
<enumerationValue key="auto">Auto</enumerationValue>
<enumerationValue key="linked">Custom</enumerationValue>
</enumerationValues>
</property>
<property key="attr" type="attribute" dataSource="linkedDs" isMetaData="true">
<caption>Attribute</caption>
<description />
<attributeTypes>
<attributeType name="Enum" />
<attributeType name="Boolean" />
</attributeTypes>
</property>
<property key="auto" type="boolean" defaultValue="true">
<caption>Automatic options</caption>
<description>Show options based on the references or the enumeration values and captions.</description>
</property>
<property key="defaultValue" type="expression" required="false">
<caption>Default value</caption>
<description>Empty option caption will be shown by default or if configured default value matches none of the options</description>
<returnType type="String" />
</property>
<property key="filterOptions" type="object" isList="true" required="false">
<caption>Options</caption>
<description />
Expand All @@ -34,6 +59,40 @@
</property>
</properties>
</property>
<!-- end: Attr type -->

<!-- start: Ref type -->
<property key="refEntity" type="association" selectableObjects="refOptions" required="true" dataSource="linkedDs" isMetaData="true">
<caption>Entity</caption>
<description>Set the entity to enable filtering over association.</description>
<associationTypes>
<associationType name="Reference" />
<associationType name="ReferenceSet" />
</associationTypes>
</property>
<property key="refOptions" type="datasource" isList="true" required="false">
<caption>Selectable objects</caption>
<description>The options to show in the Drop-down filter widget.</description>
</property>
<property key="refCaption" type="attribute" dataSource="refOptions" required="false">
<caption>Caption</caption>
<description />
<attributeTypes>
<attributeType name="String" />
</attributeTypes>
</property>
<property key="fetchOptionsLazy" type="boolean" defaultValue="false">
<caption>Use lazy load</caption>
<description>Lazy loading enables faster parent loading, but with personalization enabled, value restoration will be limited.</description>
</property>
<!-- end: Ref type -->
</propertyGroup>
<propertyGroup caption="General">
<property key="defaultValue" type="expression" required="false">
<caption>Default value</caption>
<description>Empty option caption will be shown by default or if configured default value matches none of the options</description>
<returnType type="String" />
</property>
<property key="filterable" type="boolean" defaultValue="false">
<caption>Filterable</caption>
<description />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ReactElement, createElement } from "react";
import { StaticFilterContainer } from "@mendix/widget-plugin-dropdown-filter/containers/StaticFilterContainer";
import { withParentProvidedEnumStore } from "../hocs/withParentProvidedEnumStore";
import { DatagridDropdownFilterContainerProps } from "../../typings/DatagridDropdownFilterProps";
import { withLinkedEnumStore } from "../hocs/withLinkedEnumStore";
import { EnumFilterAPI } from "./typings";

export function AttrFilter(props: DatagridDropdownFilterContainerProps): ReactElement {
if (props.auto) {
return <AutoAttrFilter {...props} />;
}

return <LinkedAttrFilter {...props} />;
}

const AutoAttrFilter = withParentProvidedEnumStore(Connector);

const LinkedAttrFilter = withLinkedEnumStore(Connector);

function Connector(props: DatagridDropdownFilterContainerProps & EnumFilterAPI): ReactElement {
return (
<StaticFilterContainer
{...props}
multiselect={props.multiSelect}
ariaLabel={props.ariaLabel?.value}
className={props.class}
styles={props.style}
emptyCaption={props.emptyOptionCaption?.value}
defaultValue={props.defaultValue?.value}
parentChannelName={props.parentChannelName}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createElement, ReactElement } from "react";
import { withLinkedRefStore } from "../hocs/withLinkedRefStore";
import { RefFilterContainer } from "@mendix/widget-plugin-dropdown-filter/containers/RefFilterContainer";
import { RefFilterAPI } from "./typings";
import { DatagridDropdownFilterContainerProps } from "../../typings/DatagridDropdownFilterProps";

function Connector(props: DatagridDropdownFilterContainerProps & RefFilterAPI): ReactElement {
return (
<RefFilterContainer
{...props}
multiselect={props.multiSelect}
ariaLabel={props.ariaLabel?.value}
className={props.class}
styles={props.style}
emptyCaption={props.emptyOptionCaption?.value}
defaultValue={props.defaultValue?.value}
parentChannelName={props.parentChannelName}
/>
);
}

export const RefFilter = withLinkedRefStore(Connector);
Loading