Creating a filter view in Jspresso containing a date picker without comparison operators

120 views Asked by At

In my Jspresso application, I have an entity with startDate and endDate. I've created a filter module on this entity with a search on a validityDate that the user has to type in. The generated query should return the list of entities for which this validityDate is between startDate and endDate. So I customized the query and this works well.

Unfortunately, the filter view displays the validityDate field preceeded by a search operator (<,>, between…) which is irrelevant in my case; so I simply ignore the operator in the query.

I would like to hide the operator in the view to only have the date with a date picker.

1

There are 1 answers

2
Vincent Vandenschrick On BEST ANSWER

I don't think it can easily be achieved using the current Jspresso version (4.0.7 as of now). The problem is that the code responsible for exploding the comparable scalar properties into a (comparator, min, max) filtering structure is too deeply nested for it to be overridden using dependency injection :

The following method :

protected boolean isPropertyFilterComparable(
      IPropertyDescriptor propertyDescriptor) {
    return propertyDescriptor instanceof INumberPropertyDescriptor
        || propertyDescriptor instanceof IDatePropertyDescriptor
        || propertyDescriptor instanceof ITimePropertyDescriptor
        || propertyDescriptor instanceof IDurationPropertyDescriptor;
}

is located into the RefQueryComponentDescriptor class whose instances are constructed at runtime by the BasicQueryComponentDescriptorFactory but in a private method (i.e. createOrGetQueryComponentDescriptor). So even if you could inject your own customized instance of BasicQueryComponentDescriptorFactory, you would have to copy/paste too much code to reach the isPropertyFilterComparable method.

Since your use case is perfectly valid, I suggest that you create an enhancement request on the Jspresso GitHub.

A little less straightforward but more versatile approach might be to open the various comparable properties (number, date, time and duration) for an extra customization in order to tell Jspresso whether to generate or not the comparator structure when those properties are added in a filter view.

something like :

date 'validityDate', filterComparable:true

But this would require a change in the SJS DSL.