From 034e779b4144ea51a13edc6aa697e2c1df01a185 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 21 May 2017 13:16:31 +0530 Subject: [PATCH] Add a setting to the server Book details panel to show all metadata fields instead of only the enabled ones from Preferences->Look & Feel->Book details To access the setting click the three vertical dots in the top right corner of the book details panel --- src/pyj/book_list/book_details.pyj | 14 +++++++++++++- src/pyj/session.pyj | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pyj/book_list/book_details.pyj b/src/pyj/book_list/book_details.pyj index 3c2c383340..7609647b9a 100644 --- a/src/pyj/book_list/book_details.pyj +++ b/src/pyj/book_list/book_details.pyj @@ -13,6 +13,7 @@ from book_list.library_data import ( download_url, library_data, load_status, set_book_metadata ) from book_list.router import back, home, open_book +from book_list.globals import get_session_data from book_list.theme import get_color, get_font_size from book_list.top_bar import add_button, create_top_bar, set_title from book_list.ui import query_as_href, set_panel_handler, show_panel @@ -133,7 +134,7 @@ def render_metadata(mi, table, book_id): # {{{ return True fields = library_data.book_display_fields - if not fields or not fields.length: + if not fields or not fields.length or get_session_data().get('show_all_metadata'): fields = sorted(filter(allowed_fields, mi), key=field_sorter(field_metadata)) else: fields = filter(allowed_fields, fields) @@ -552,11 +553,16 @@ def show_subsequent_panel(name, replace=False): def create_more_actions_panel(container_id): container = document.getElementById(container_id) create_top_bar(container, title=_('More actions…'), action=back, icon='close') + if get_session_data().get('show_all_metadata'): + title, subtitle = _('Show important metadata'), _('Show only the important metadata fields in the book details') + else: + title, subtitle = _('Show all metadata'), _('Show all metadata fields in the book details') items = [ create_item(_('Search the internet'), subtitle=_('Search for this author or book on various websites'), action=def(): show_subsequent_panel('search_internet', replace=True) ), + create_item(title, subtitle=subtitle, action=toggle_fields), ] container.appendChild(E.div()) create_item_list(container.lastChild, items) @@ -567,6 +573,12 @@ def return_to_book_details(): show_panel('book_details', query=q, replace=True) +def toggle_fields(): + sd = get_session_data() + sd.set('show_all_metadata', False if sd.get('show_all_metadata') else True) + return_to_book_details() + + def url_for(template, data): def eqc(x): return encode_query_component(x).replace(/%20/g, '+') diff --git a/src/pyj/session.pyj b/src/pyj/session.pyj index fd84a5fd02..c3fae0bf6b 100644 --- a/src/pyj/session.pyj +++ b/src/pyj/session.pyj @@ -12,6 +12,7 @@ defaults = { 'view_mode': 'cover_grid', 'sort': 'timestamp.desc', # comma separated list of items of the form: field.order 'last_sort_order': {}, + 'show_all_metadata': False, # show all metadata fields in the book details panel # Tag Browser settings 'partition_method': 'first letter', # other choices: 'disable', 'partition'