This repository has been archived by the owner on Mar 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Generic filter improvements #196
Milestone
Comments
This was referenced Jan 25, 2021
GlebDurygin
pushed a commit
to jmix-projects/jmix-translations
that referenced
this issue
Jan 31, 2021
GlebDurygin
pushed a commit
to jmix-projects/jmix-templates
that referenced
this issue
Jan 31, 2021
GlebDurygin
pushed a commit
to jmix-framework/jmix
that referenced
this issue
Jan 31, 2021
GlebDurygin
pushed a commit
to jmix-projects/jmix-data
that referenced
this issue
Jan 31, 2021
GlebDurygin
pushed a commit
that referenced
this issue
Jan 31, 2021
TC:
run app>open browser>filter_settingsButton |
glebfox
pushed a commit
to jmix-projects/jmix-translations
that referenced
this issue
Feb 16, 2021
glebfox
pushed a commit
to jmix-framework/jmix
that referenced
this issue
Feb 16, 2021
glebfox
pushed a commit
that referenced
this issue
Feb 16, 2021
GlebDurygin
pushed a commit
to jmix-framework/jmix-ui-samples
that referenced
this issue
Feb 19, 2021
Will be fixed in #343
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The main issue #162
List of remaining tasks:
Filter actions
FilterMakeDefaultAction
class;FilterSaveWithValuesAction
class;Features
parameterWhere
,parameterJoin
,parameterFetchPlan
attributes;XML
<jpqlFilter/>
XML element;captionPosition
attribute to Filter componentFilter appearance
Events
ConfigurationChangeEvent
Solution
Filter components
The generic filter component can only work with components that implement the
FilterComponent
interface. If the component is a container for placing multiple filter components, then it needs to implementLogicalFilterComponent
interface.The filter component is treated as a query condition:
GroupFilter
The
GroupFilter
component is a composite component that has aGroupBoxLayout
component as its root container. This component is needed to combine several conditions into a logical group (AND by default, OR). The component can be used only inside theFilter
component.PropertyFilter
See #29, #171
PropertyFilter
is a UI component used for filtering entities returned by the {@link DataLoader}. The component is related to entity property and can automatically render proper layout for setting a condition value. In general case a PropertyFilter layout contains a label with entity property caption, operation label or selector (=, contains, >, etc.) and a field for editing a property value. The component can be used inside theFilter
component and independently.propertyFilter
attributes inside thefilter
:id
property
(required) May be a property or properties path:name
,order
,order.date
operation
(required)operationEditable
Default falseoperationCaptionVisible
Default true.caption
(optional) If absent, the caption is evaluated by entity propertywidth
parameterName
- name of LoadContext parameter that is used by this condition. If not defined then the parameter name is randomly generated.defaultValue
- the default value of filter componentJpqlFilter
JpqlFilter
is a UI component used for filtering entities returned by the DataLoader. The component contains JPQL expressions that will be added to the 'from' and 'where' data loader query sections. The component can automatically render proper layout for setting a condition value. In general case a JpqlFilter layout contains a label with caption and a field for editing a condition value. The component can be used only inside theFilter
component.jpqlFilter
attributes inside thefilter
:id
parameterClass
(required) the value typeparameterName
- name of LoadContext parameter that is used by this condition. If not defined then the parameter name is randomly generated.caption
(optional) If absent, the caption is evaluated by entity propertywidth
defaultValue
- the default value of filter componentFilter component registration
See
FilterComponentRegistration
class. TheFilterComponentRegistration
class has the following attributes:componentClass
(required) - filter component class, must extend fromFilterComponent
class;modelClass
(required) - non-persistent entity class that stores the state of the filter component, must extend fromFilterCondition
class. The model class is used to save filter component state in DB and is used to display and change the state of the filter component at runtime;converterClass
(required) - a converter class for converting between a component and a model must implement the FilterConverter interface.editorScreenId
(optional) - ID of the model edit screen. If no identifier is specified then the default identifier (modelName.edit -> PropertyFilterCondition.edit
) will be used.PropertyFilter
registration example:All registered filter components are displayed in a
PopupButton
on theAddConditionScreen
so that the user has the opportunity to create a filter component in runtime. Pressing the button will open the editor screen for the selected filter component.This method of registering filter components is convenient because we can register the filter components in different modules. And also the user can replace the filter component registered in the jmix framework with his own implementation by specifying the
@Order
annotation (for example, to expand the set of model attributes saved by the filter).Configurations
A configuration is a set of filter components that has an id (required) and name (optional). The id must be unique within this filter. If the name is not specified, then id is used as a key in the messagePack.
The
LogicalFilterComponent
is the root element of the configuration.The configuration does not store a reference to all components, but stores a reference only to the root element (
LogicalFilterComponent
) from which the rest filter components can be obtained.Configurations can be created at design time or at run time (via filter configuration editor).
Using Filter#getCurrentConfiguration() user can get the current configuration, and using Filter#getConfiguration(String id) user can get the configuration by id.
Design-time configuration
See
DesignTimeConfigurationImpl
class. Such configurations cannot be changed and saved in run-time, but the user can useFilterCopyAction
that copies all conditions from the design-time configuration to run-time configuration.Configuration addConfiguration(String id, @Nullable String name)
method creates and adds to filter a design-time configuration.Use
default
XML attribute to set the design-time configuration as default for filter.All design-time configurations are displayed in the
selectConfigurationButton
:Run-time configuration
See
RuntimeTimeConfigurationImpl
. Such configurations are created by the user in run-time and can be saved and modified.Predefined conditions
A predefined condition is a filter component that is not initially added to any of the configurations, but the user can select this component in the
AddConditionScreen
in the Predefined conditions section and add it to the run-time configuration.AddConditionScreen
The set of conditions that will be displayed in
AddConditionScreen
is defined using ConditionBuilder beans: PropertyConditionBuilder, PredefinedConditionBuilder, ConfigurationConditionBuilder.The set of possible dropdown actions for the Create button is determined by the number of registered FilterComponents.
Configuration editor
GroupCondition editor
PropertyCondition editor
JpqlCondition editor
Filter actions
Now, the
Filter
component implementsActionsHolder
interface. All actions will be added to thesettingsButton
PopupButton.The framework loads a set of default actions for the filter, depending on the connected modules:
ui module
FilterEditAction
(filter_edit)FilterCopyAction
(filter_copy)FilterClearValuesAction
(filter_clearValues)ui-data module
FilterSaveAction
(filter_save)FilterSaveWithValuesAction
(filter_saveWithValues)FilterSaveAsAction
(filter_saveAs)FilterEditAction
(filter_edit)FilterRemoveAction
(filter_remove)FilterCopyAction
(filter_copy)FilterMakeDefaultAction
(filter_makeDefault)FilterClearValuesAction
(filter_clearValues)User can override default actions in XML or in JAVA:
filter_save - saves changes to current filter configuration.
filter_saveWithValues - saves changes to the current filter configuration using the values in inner filter components as filter default values.
filter_saveAs - saves current filter configuration under new code and caption;
filter_edit - edits current run-time filter configuration (opens
FilterConfigurationEdit
screen). Disabled for design-time configurations.filter_remove - removes current run-time filter configuration. Disabled for design-time configurations.
filter_copy - copies all conditions from design-time configuration to run-time configuration;
filter_makeDefault - makes the filter configuration default for this screen. The filter will be automatically displayed on the filter panel when the screen is opened. Takes precedence over
default
attribute of design-time configurations andDefault for all users
attribute of configuration. Disabled if noscreenSettings
facet is added to the screen.filter_clearValues - clears the filter condition values.
filter_addCondition - adds condition to current filter configuration.
Permissions
Ui properties
autoApply
attribute specifies when the filter is applied. If the attribute value is false, the filter will be applied only after the Search button is clicked. If the attribute value is true, filter is applied immediately after changing the filter components.Samples
Add a design-time configuration with a PropertyFilter to a Filter
Add a design-time configuration with a JpqlFilter to a Filter
Add a design-time configuration with a GroupFilter to a Filter
Add a filter component to existing configuration
Programmatically defined Filter
The text was updated successfully, but these errors were encountered: