mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Work on show notes panel
This commit is contained in:
parent
475ffbd1d2
commit
8b154c1b75
@ -14,7 +14,7 @@ from book_list.library_data import (
|
|||||||
current_virtual_library, download_url, library_data, load_status,
|
current_virtual_library, download_url, library_data, load_status,
|
||||||
set_book_metadata
|
set_book_metadata
|
||||||
)
|
)
|
||||||
from book_list.router import back, home, open_book, report_a_load_failure, show_note_url
|
from book_list.router import back, home, open_book, report_a_load_failure, show_note
|
||||||
from book_list.theme import (
|
from book_list.theme import (
|
||||||
color_scheme, get_color, get_color_as_rgba, get_font_size
|
color_scheme, get_color, get_color_as_rgba, get_font_size
|
||||||
)
|
)
|
||||||
@ -192,12 +192,15 @@ def render_metadata(mi, table, book_id, iframe_css): # {{{
|
|||||||
comments = v'[]'
|
comments = v'[]'
|
||||||
link_maps = mi.link_maps or v'{}'
|
link_maps = mi.link_maps or v'{}'
|
||||||
|
|
||||||
|
def show_note_action(field, name, item_id, item_val):
|
||||||
|
show_note(book_id, field, item_id, item_val)
|
||||||
|
|
||||||
def add_note_link(field, name, val, parent):
|
def add_note_link(field, name, val, parent):
|
||||||
if mi.items_with_notes[field] and mi.items_with_notes[field][val]:
|
if mi.items_with_notes[field] and mi.items_with_notes[field][val]:
|
||||||
parent.appendChild(document.createTextNode(' '))
|
parent.appendChild(document.createTextNode(' '))
|
||||||
parent.appendChild(E.a(
|
parent.appendChild(E.a(
|
||||||
svgicon('pencil'), title=_('Show notes for: {}').format(val), href=show_note_url(
|
svgicon('pencil'), title=_('Show notes for: {}').format(val), href='javascript:void(0)', onclick=show_note_action.bind(
|
||||||
book_id, field, val, close_action='close_window'), target='_new', class_='blue-link'))
|
None, book_id, field, mi.items_with_notes[field][val], val), class_='blue-link'))
|
||||||
|
|
||||||
def add_row(field, name, val, is_searchable=False, is_html=False, join=None, search_text=None, use_quotes=True):
|
def add_row(field, name, val, is_searchable=False, is_html=False, join=None, search_text=None, use_quotes=True):
|
||||||
if val is undefined or val is None:
|
if val is undefined or val is None:
|
||||||
|
@ -29,6 +29,7 @@ import book_list.book_details # noqa: unused-import
|
|||||||
import book_list.edit_metadata # noqa: unused-import
|
import book_list.edit_metadata # noqa: unused-import
|
||||||
import book_list.convert_book # noqa: unused-import
|
import book_list.convert_book # noqa: unused-import
|
||||||
import book_list.fts # noqa: unused-import
|
import book_list.fts # noqa: unused-import
|
||||||
|
import book_list.show_note # noqa: unused-import
|
||||||
|
|
||||||
|
|
||||||
def remove_initial_progress_bar():
|
def remove_initial_progress_bar():
|
||||||
|
@ -87,15 +87,23 @@ def open_book_url(book_id, fmt, extra_query):
|
|||||||
return ans + encode_query(q, '#')
|
return ans + encode_query(q, '#')
|
||||||
|
|
||||||
|
|
||||||
def show_note_url(book_id, field, item_value, close_action='back'):
|
def show_note_url(book_id, field, item_id, item_value, library_id=None, close_action='back'):
|
||||||
lid = current_library_id()
|
lid = library_id or current_library_id()
|
||||||
ans = absolute_path('')
|
ans = absolute_path('')
|
||||||
q = {'book_id':book_id, 'field': field, 'item':item_value, 'panel': 'show_note', 'close_action': close_action}
|
q = {'book_id':book_id, 'field': field, 'item':item_value, 'item_id': item_id, 'panel': 'show_note', 'close_action': close_action}
|
||||||
if lid:
|
if lid:
|
||||||
q.library_id = lid
|
q.library_id = lid
|
||||||
return ans + encode_query(q, '#')
|
return ans + encode_query(q, '#')
|
||||||
|
|
||||||
|
|
||||||
|
def show_note(book_id, field, item_id, item_value, replace=False, library_id=None, close_action='back'):
|
||||||
|
lid = library_id or current_library_id()
|
||||||
|
q = {'book_id':book_id, 'field': field, 'item':item_value, 'item_id': item_id, 'panel': 'show_note', 'close_action': close_action}
|
||||||
|
if lid:
|
||||||
|
q.library_id = lid
|
||||||
|
push_state(q, replace=replace)
|
||||||
|
|
||||||
|
|
||||||
def push_state(query, replace=False, mode='book_list', call_handler=True):
|
def push_state(query, replace=False, mode='book_list', call_handler=True):
|
||||||
query = {k:query[k] for k in query if query[k]}
|
query = {k:query[k] for k in query if query[k]}
|
||||||
if mode is not 'book_list':
|
if mode is not 'book_list':
|
||||||
|
21
src/pyj/book_list/show_note.pyj
Normal file
21
src/pyj/book_list/show_note.pyj
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# vim:fileencoding=utf-8
|
||||||
|
# License: GPL v3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
from __python__ import bound_methods, hash_literals
|
||||||
|
|
||||||
|
from book_list.router import back, home
|
||||||
|
from book_list.top_bar import create_top_bar
|
||||||
|
from book_list.ui import set_panel_handler
|
||||||
|
from utils import parse_url_params
|
||||||
|
|
||||||
|
|
||||||
|
def init(container_id):
|
||||||
|
container = document.getElementById(container_id)
|
||||||
|
close_action, close_icon = back, 'close'
|
||||||
|
q = parse_url_params()
|
||||||
|
ca = q.close_action
|
||||||
|
if ca is 'home':
|
||||||
|
close_action, close_icon = def(): home();, 'home'
|
||||||
|
create_top_bar(container, title=q.item, action=close_action, icon=close_icon)
|
||||||
|
|
||||||
|
|
||||||
|
set_panel_handler('show_note', init)
|
Loading…
x
Reference in New Issue
Block a user