Repository: akvo/akvo-rsr

Issue:
Advanced Filter - long dropdowns (Partner in particular)
When trying to select an organisation on the advanced filter in v3 we still have the very long list containing 2500+ organisations.

![screen shot 2015-01-23 at 11 36 31](https://cloud.githubusercontent.com/assets/1426234/5873201/41c8f9d8-a2f4-11e4-98e6-9492a51171c3.png)

We should implement the same list options as we have done in MyRSR for the Employment selections:

![screen shot 2015-01-23 at 11 36 39](https://cloud.githubusercontent.com/assets/1426234/5873203/470da7c2-a2f4-11e4-95c7-ffb209841e65.png)



Discussion:
Some other thoughts from the product meeting on Thursday:
- When making a selection from the filter, the sidebar closes automatically, yet there is a button that says to close the filter options - this button is therefore almost never needed.

It seems to make sense either to change the button into a "Apply Filters" type button to allow a user to enter more than a single filter (such as Sector & Country) before then retrieving the results.

Alternatively we could change the sidebar so it remains on the page after the selection and application of a filter, so the user could again select another filter.

I prefer option 1, but I think both are reasonable.

@loicsans / @gabemart - thoughts?

@adriancollier I agree that option 1 sounds better. I think it makes sense to be able to select more than one filter option before seeing the results of the filter

When we first discussed implementing typeahead, the consensus was that it was important to stay away from jQuery and use a react-based solution. Is this still an important requirement? At the time, I hadn't realized that the current typeahead system used for the main search input on the project directory page is jQuery-based, and jQuery is also currently used for submitting the django-filter based filter options in the side panel.

Thanks @gabemart 

AFAIK the React vs JQuery  requirement comes from an architectural simplification point of view and was provided by @iperdomo here: https://github.com/akvo/akvo-rsr/issues/1100

The close button on the sidebar was just added to close the panel if you triggered it and you don;t need it.
First option is definitely better, also we need to first reimplement the filtering system totally. For now, each time you select one parameter the whole page reloads, so the sidebar disappears.


Resolving patch:
diff --git a/akvo/rsr/views/project.py b/akvo/rsr/views/project.py
--- a/akvo/rsr/views/project.py
+++ b/akvo/rsr/views/project.py
@@ -56,6 +56,7 @@ def _project_directory_coll(request):
 
 def directory(request):
     """The project list view."""
+
     qs = remove_empty_querydict_items(request.GET)
 
     # Set show_filters to "in" if any filter is selected
@@ -78,6 +79,9 @@ def directory(request):
     page = request.GET.get('page')
     page, paginator, page_range = pagination(page, sorted_projects, 10)
 
+    # Get the current org filter for typeahead
+    org_filter = request.GET.get('organisation', '')   
+
     context = {
         'project_count': sorted_projects.count(),
         'filter': f,
@@ -87,6 +91,7 @@ def directory(request):
         'show_filters': show_filters,
         'q': filter_query_string(qs),
         'sorting': sorting,
+        'current_org': org_filter,
     }
     return render(request, 'project_directory.html', context)
 


Test patch: