modlinltd / django-advanced-filters

Add advanced filtering abilities to Django admin
https://pypi.org/project/django-advanced-filters/
MIT License
771 stars 173 forks source link

initialize select2 widget #31

Open pjpassa opened 8 years ago

pjpassa commented 8 years ago

This merge request allows the select2 widget to pre-populate with the current value. It should also fix Issue 22.

There is a side effect to how I fixed this, which I think is OK. If the value is not in the list returned by the ajax call it is added to the beginning of the list. This does also make it easy to switch back to the old value if you want to.

Also, if the value is in the list returned from the ajax call, it is in the list twice. This behavior is less desired, but it can be useful if you have a long list to see what the previous value was.

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 96.198% when pulling f37013c9ad45dcb1813b82dbb59bed99fb79e976 on worthwhile:feat/initialize-select2 into 119c76d7198b84148f5662face3e62af9241895b on modlinltd:develop.

asfaltboy commented 8 years ago

Hi @pjpassa, thanks again for putting work on the project.

Please see my comments on commit b48dfe8fb9d267be918dd0d272785ed581260509. Generally speaking this seems like the right place to resolve this issue.

Unfortunately, I won't have time to test any time soon, and we still don't have a frontend test suite (issue #19).

mrname commented 6 years ago

I just merged master into this branch locally and tested it out. Things seem to work as promised:

advanced_filters_pr_31