Skip to content

TVB-2757: Apply filters on linked datatypes at runtime by rerendering the form

Marmaduke Woodman requested to merge TVB-2757-v2 into master

Created by: VinczeRobert

At the beginning we thought this method might be simpler than what I did on the other PR of this task, but now I am not so sure about that. I think that at least the code is easier to understand.

I chose to separate the 3 types of filters (default, user defined and runtime filters) in 3 dictionaries because they need to be handled differently:

  • default filters just need to stay hidden in their respective select field elements
  • user defined filters need to not stay hidden and they need to be readded after the form is rerendered
  • runtime filters also need to stay hidden but the values of those filters need to be replaced in the Python code in cases such as when you filter the connectivities based on the connectivity annotations (I call this 'reverse_filtering' because you don't have an 'fk_connectivity_annotations field on ConnectivityIndex, so I used ConnectivityIndex.number_of_regions comparing it with the number of regions of the connectivity with the gid equal to ConnectivityAnnotationsIndex.fk_connectivity_gid).

Anothe problem was that after you rerender the form, the most recently added datatypes will appear to be the selected values by default, so I needed to keep the values before applying the filters to reput them after the form is rerendered.

I have two bugs (aspects I still have to take care of) currently:

  1. When reading the filters I am using the dynamic filters of the field that currently had its value changed but I should use the dynamic filters of each field when readding the filters for each particular field. (EDIT: I solved this one)
  2. I didn't take care of the reverse filtering in the get_filtered_datatypes method_yet. (EDIT: I solved this one)

Merge request reports