Skip to content

Component Filtration Extension

Vadym edited this page Aug 12, 2021 · 12 revisions

Dictionary based components should support filtration and filtration process should be described declarative. All filtration logic should be placed inside "filters" property on root level in component description. This should be or single filtration rule, or set of filtration rules connected with AND bool operand, or tree of rules with binary operator in the root to describe how filters should joins.

Filtration properties:

  • operator - bool operator to connect several filters
  • by - the field to be used to check with
  • comparator - comparison function to be used to compare values. Out-of-the-box system should support this comparators: eq, contains, less, greater, empty and all negetaions to this operators: !eq, !contains, !less, !greater, !empty
  • val - value to be used as second comparator operand. This can be static value or refernce to data in data model to check with

Filtration examples:

single filter declaration allow to filter dictionary based component by name and select only those fields which contains 'york' word

{
  binding: 'cities',
  filters: [{
    by: 'name',
    comparator: 'contains',
    val: 'york'
  }]
}

Dynamic filter example:

When dynamic value need to be used for filter - path to data in data model tree can be used. In this case value string should be started with '@' symbol.

{
  binding: 'cities',
  filters: [{
    by: 'name',
    comparator: 'eq',
    val: '@path.to.data'
  }]
}