diff --git a/tabellio/searchform/form.py b/tabellio/searchform/form.py index db24903..3890ea9 100644 --- a/tabellio/searchform/form.py +++ b/tabellio/searchform/form.py @@ -78,9 +78,14 @@ class ListAuthorsView(BrowserView): for object in self.deputies_folder.objectValues(): if object.portal_type != 'themis.datatypes.deputy': continue - if q in normalizer.normalize(object.Title()).lower(): - s.append(object) - s.sort() + re.split(r'[-\s]', 'hello-pol to') + for name_part in re.split(r'[-\s]', normalizer.normalize(object.Title()).lower()): + if name_part.startswith(q): + s.append(object) + def cmp_deputy(x, y): + return cmp(normalizer.normalize(x.Title()).lower(), + normalizer.normalize(y.Title()).lower()) + s.sort(cmp_deputy) return '\n'.join(['%s|%s' % (x.Title(), x.id) for x in s]) class ListPolgroupsView(BrowserView): diff --git a/tabellio/searchform/js_macros.pt b/tabellio/searchform/js_macros.pt index aeb70f7..568610d 100644 --- a/tabellio/searchform/js_macros.pt +++ b/tabellio/searchform/js_macros.pt @@ -63,7 +63,7 @@ if(typeof(String.prototype.trim) === "undefined") { (function($) { $().ready(function() { $('.author-autocomplete').each(sync_authors).autocomplete(PORTAL_URL+'/listAuthors', { - }).result(autocomplete_ready); + 'matchContains': true, 'scroll': true, 'max': 30}).result(autocomplete_ready); $('.polgroup-autocomplete').each(sync_polgroups).autocomplete(PORTAL_URL+'/listPolgroups', { }).result(autocomplete_ready); $('.topic-autocomplete').each(sync_topics).autocomplete(PORTAL_URL+'/listTopics', {