Display current VL at top of book list

This commit is contained in:
Kovid Goyal 2017-04-25 21:23:09 +05:30
parent 60278959b1
commit be02dee998
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 24 additions and 11 deletions

View File

@ -49,6 +49,9 @@ def add_library_info(query):
if not query.library_id: if not query.library_id:
query.library_id = current_library_id() query.library_id = current_library_id()
if not query.vl: if not query.vl:
if query.vl is None:
v'delete query.vl'
else:
vlid = current_virtual_library() vlid = current_virtual_library()
if vlid: if vlid:
query.vl = vlid query.vl = vlid

View File

@ -37,7 +37,6 @@ DEFAULT_MODE = 'cover_grid'
add_extra_css(def(): add_extra_css(def():
sel = '.' + CLASS_NAME + ' ' sel = '.' + CLASS_NAME + ' '
ans = build_rule(sel + '[data-component="top_message"]', margin='1ex 1em') ans = build_rule(sel + '[data-component="top_message"]', margin='1ex 1em')
ans += build_rule(sel + '[data-component="top_message"] a', color='blue')
ans += cover_grid_css.call() ans += cover_grid_css.call()
return ans return ans
) )
@ -171,16 +170,25 @@ def create_more_button(more):
def show_top_message(): def show_top_message():
container = component('top_message') container = component('top_message')
if library_data.search_result?.query: q = loaded_books_query()
if not q.search and not q.vl:
container.style.display = 'none'
return
if q.vl:
container.appendChild(E.span(
E.span(_('Showing Virtual library: {} ').format(q.vl)),
create_button(_('Close'), 'close', def(): show_vl();, _('Show all books in library'))
))
if q.search:
container.appendChild(E.br())
if q.search:
text = _('Showing books matching: {} ') text = _('Showing books matching: {} ')
if not library_data.search_result.total_num: if not library_data.search_result.total_num:
text = _('No books matching: {} ') text = _('No books matching: {} ')
container.appendChild(E.span( container.appendChild(E.span(
E.span(text.format(library_data.search_result.query)), E.span(text.format(library_data.search_result.query)),
E.a(_('Clear'), href='javascript:void(0)', onclick=def():search();, class_='simple-link', title=_('Clear this search')) create_button(_('Clear'), 'close', def(): search();, _('Clear this search'))
)) ))
else:
container.style.display = 'none'
def create_books_list(container): def create_books_list(container):
book_list_data.container_id = ensure_id(container) book_list_data.container_id = ensure_id(container)
@ -299,13 +307,15 @@ def create_vl_panel(container_id):
vls = all_virtual_libraries() vls = all_virtual_libraries()
vl_names = Object.keys(vls).sort(def (a, b): return a.toLowerCase().localeCompare(b.toLowerCase());) vl_names = Object.keys(vls).sort(def (a, b): return a.toLowerCase().localeCompare(b.toLowerCase());)
for name in vl_names: for name in vl_names:
items.push(create_item(name, subtitle=vls[name], action=show_vl.bind(None, name))) items.push(create_item(name, subtitle=vls[name], action=show_vl.bind(None, name, True)))
container.appendChild(E.div()) container.appendChild(E.div())
create_item_list(container.lastChild, items, _('Choose a Virtual library to browse from the list below')) create_item_list(container.lastChild, items, _('Choose a Virtual library to browse from the list below'))
def show_vl(vl_name): def show_vl(vl_name, replace):
show_panel('book_list', query={'vl':vl_name}, replace=True) q = loaded_books_query()
q.vl = vl_name or None
show_panel('book_list', query=q, replace=replace or False)
# }}} # }}}