nilesjohnson / conference-list

Conference list web app based on CakePHP framework
2 stars 2 forks source link

Improved country select #33

Open nilesjohnson opened 9 years ago

nilesjohnson commented 9 years ago

Leftover enhancement idea from #19 : Two ideas from that article that are not implemented:

  1. sorting search results by popularity (e.g. United States before United Arab Emarites when search term is 'Uni')
  2. matching on alternate spellings (e.g. USA or Deutschland)

I had trouble getting cake's form helper to output additional custom attributes in the select field (as in, I looked, and there was no functionality for this in the documentation). And attempting to add the relevant fields by hand, without the form helper, caused trouble with the CSRF token. Probably the fields weren't encoded in the token properly (or at all).

nilesjohnson commented 9 years ago

An idea: load the relevant data (modify the loadCountries function in the controller) and put it in a javascript object. Add/modify the custom 'matcher' and 'sortResults' functions to pull from that data (set an id for each select element, and use this in javascript to find the relevant data).

sethjohnson1 commented 9 years ago

I see two options:

  1. Use the nicer selectToAutocomplete plugin you found PRO: it's done and only adds 12KB file to load. Better degradation with no JS CON: Well, it's another damn library to keep track of
  2. Create an Ajax view of the country data and do a JSON call with select2 (that can be sorted) PRO: AJAX call might make the page load a little faster CON: Another action on the controller, more to keep track of I guess.
nilesjohnson commented 9 years ago

We have a custom sorter for select2 already, and it is working for tags, but is partly broken for countries.

Matches are correctly sorted within categories, but not across categories. For example, type 'zi' and see that Zimbabwe is listed above Swaziland. But Brazil is in a different category, below Swaziland.

nilesjohnson commented 9 years ago

note: removing the grouping by region would solve the sorting problem.