AdrianBZG/InterMine-Data-Browser-Tool

Allow users to add and remove filters (only one)

yochannah opened this issue ยท 7 comments

"clear filters" is great, but sometimes a user might want to remove just one of the filters and leave the others intact. Could we have an x beside any active filter?

There is a removeConstraint method in im-tables, but I think it expects to be passed a ActiveConstraint backbone object, which isn't ideal.

Would modifying im-tables to accept the code (e.g. "B") of a constraint to remove be a good way forward for you? I can look at this probably no earlier than mid-july, unfortunately, due to a conference/

@yochannah The thing is I'm not sure how to give a code to a constraint using addConstraint, maybe it's useful to remove a constraint by index, like removeConstraint(1) -> removes second constraint. This way I can keep a index per constraint and attach it to the event of selecting one, so when the user removes it I can just delete the associated constraint... what do u think?

it looks to me like the constraints get automatically appended to the end of the constraints array, but I think it's probably safer to explicitly use the codes. You can set the code when you add the constraint, e.g.

          table.query.addConstraint({
            "path": "goAnnotation.ontologyTerm.name",
            "op": "==",
            "value": "protein binding",
            "code" : "B"
          });

@yochannah ok! Perfect ๐Ÿ‘

ok, I was wrong - this is already possible! I'm learning so much about imjs and imtables this GSoC ๐Ÿ˜†

Demo to remove a constraint: https://yochannah.github.io/im-tables-examples/constraint-remove.html

@yochannah Wonderful, that's exactly what I need ๐Ÿ‘ thanks