mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Tag Browser: Fix clicking on first-letter groups for series not working
This commit is contained in:
parent
2ba85a0869
commit
8b7a8997d9
@ -670,6 +670,24 @@ class SeriesField(ManyToOneField):
|
||||
val = self.table.id_map[item_id]
|
||||
return title_sort(val, order=tss, lang=lang)
|
||||
|
||||
def iter_searchable_values_for_sort(self, candidates, lang_map, default_value=None):
|
||||
cbm = self.table.col_book_map
|
||||
sso = tweaks['title_series_sorting']
|
||||
ts = title_sort
|
||||
empty = set()
|
||||
lang_map = {k:v[0] if v else None for k, v in lang_map.iteritems()}
|
||||
for item_id, val in self.table.id_map.iteritems():
|
||||
book_ids = cbm.get(item_id, empty).intersection(candidates)
|
||||
if book_ids:
|
||||
lang_counts = Counter()
|
||||
for book_id in book_ids:
|
||||
lang = lang_map.get(book_id)
|
||||
if lang:
|
||||
lang_counts[lang[0]] += 1
|
||||
lang = lang_counts.most_common(1)[0][0] if lang_counts else None
|
||||
yield ts(val, order=sso, lang=lang), book_ids
|
||||
|
||||
|
||||
class TagsField(ManyToManyField):
|
||||
|
||||
def get_news_category(self, tag_class, book_ids=None):
|
||||
|
@ -682,6 +682,13 @@ class Parser(SearchQueryParser): # {{{
|
||||
if _match(q, val, matchkind, use_primary_find_in_search=upf):
|
||||
matches |= book_ids
|
||||
|
||||
if location == 'series_sort':
|
||||
book_lang_map = self.dbcache.fields['languages'].book_value_map
|
||||
for val, book_ids in self.dbcache.fields['series'].iter_searchable_values_for_sort(current_candidates, book_lang_map):
|
||||
if val is not None:
|
||||
if _match(q, (val,), matchkind, use_primary_find_in_search=upf):
|
||||
matches |= book_ids
|
||||
|
||||
return matches
|
||||
|
||||
def get_user_category_matches(self, location, query, candidates):
|
||||
|
@ -290,7 +290,7 @@ class ReadingTest(BaseTest):
|
||||
'title:="Title One"', 'title:~title', '#enum:=one', '#enum:tw',
|
||||
'#enum:false', '#enum:true', 'series:one', 'tags:one', 'tags:true',
|
||||
'tags:false', 'uuid:2', 'one', '20.02', '"publisher one"',
|
||||
'"my comments one"',
|
||||
'"my comments one"', 'series_sort:one',
|
||||
|
||||
# User categories
|
||||
'@Good Authors:One', '@Good Series.good tags:two',
|
||||
|
Loading…
x
Reference in New Issue
Block a user