diff --git a/cps/db.py b/cps/db.py index bf27b4d9..2e3fa29e 100644 --- a/cps/db.py +++ b/cps/db.py @@ -631,21 +631,26 @@ class CalibreDB(threading.Thread): .filter(and_(Books.authors.any(and_(*q)), func.lower(Books.title).ilike("%" + title + "%"))).first() # read search results from calibre-database and return it (function is used for feed and simple search - def get_search_results(self, term, order=None, limit=-1): + def get_search_results(self, term, offset=None, order=None, limit=None): order = order or [Books.sort] + if offset != None and limit != None: + offset = int(offset) + limit = offset + int(limit) term.strip().lower() self.session.connection().connection.connection.create_function("lower", 1, lcase) q = list() authorterms = re.split("[, ]+", term) for authorterm in authorterms: q.append(Books.authors.any(func.lower(Authors.name).ilike("%" + authorterm + "%"))) - return self.session.query(Books).filter(self.common_filters(True)).filter( + result = self.session.query(Books).filter(self.common_filters(True)).filter( or_(Books.tags.any(func.lower(Tags.name).ilike("%" + term + "%")), Books.series.any(func.lower(Series.name).ilike("%" + term + "%")), Books.authors.any(and_(*q)), Books.publishers.any(func.lower(Publishers.name).ilike("%" + term + "%")), func.lower(Books.title).ilike("%" + term + "%") - )).order_by(*order).limit(limit).all() + )).order_by(*order).all() + result_count = len(result) + return result[offset:limit], result_count # Creates for all stored languages a translated speaking name in the array for the UI def speaking_language(self, languages=None): diff --git a/cps/opds.py b/cps/opds.py index 5f6cf88d..ac0e103b 100644 --- a/cps/opds.py +++ b/cps/opds.py @@ -408,7 +408,7 @@ def get_metadata_calibre_companion(uuid, library): def feed_search(term): if term: - entries = calibre_db.get_search_results(term) + entries, __ = calibre_db.get_search_results(term) entriescount = len(entries) if len(entries) > 0 else 1 pagination = Pagination(1, entriescount, entriescount) return render_xml_template('feed.xml', searchterm=term, entries=entries, pagination=pagination) diff --git a/cps/static/js/table.js b/cps/static/js/table.js index 479c7815..879c80eb 100644 --- a/cps/static/js/table.js +++ b/cps/static/js/table.js @@ -100,6 +100,33 @@ $(function() { $(e.currentTarget).find("#btndeletedomain").data("domainId", domainId); }); + $("#delete_confirm").click(function() { + //get data-id attribute of the clicked element + var deleteId = $(this).data("deleteid"); + $.ajax({ + method:"get", + url: window.location.pathname + "/../../delete"/+deleteId, + }); + }); + + //triggered when modal is about to be shown + $("#deleteModal").on("show.bs.modal", function(e) { + //get data-id attribute of the clicked element and store in button + var bookId = $(e.relatedTarget).data("delete-id"); + $(e.currentTarget).find("#delete_confirm").data("deleteid", bookId); + }); + // receive result from request, dismiss modal dialog, show flash message + // insert after navbar + /*$("#deleteModal").on("hidden.bs.modal", function () { +
+
{{ message[1] }}
+
*/ + + // to save current setting + // coresponding event: onColumnSwitch + //$table.bootstrapTable('getVisibleColumns') + //$table.bootstrapTable('getHiddenColumns'). + $("#restrictModal").on("hidden.bs.modal", function () { // Destroy table and remove hooks for buttons $("#restrict-elements-table").unbind(); @@ -223,9 +250,8 @@ function RestrictionActions (value, row) { /* Function for deleting books */ function EbookActions (value, row) { return [ - "
", + "
", "", "
" ].join(""); } - diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index 14bc590a..1f7b57b4 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -192,34 +192,7 @@ {% endblock %} {% block modal %} -{% if g.user.role_delete_books() %} - -{% endif %} +{{ delete_book(book.id) }} {% endmacro %} +{% macro delete_book(bookid) %} +{% if g.user.role_delete_books() %} + +{% endif %} +{% endmacro %} diff --git a/cps/templates/search.html b/cps/templates/search.html index da59efa6..b0dbc4af 100644 --- a/cps/templates/search.html +++ b/cps/templates/search.html @@ -5,7 +5,7 @@

{{_('No Results Found')}} {{adv_searchterm}}

{{_('Search Term:')}} {{adv_searchterm}}

{% else %} -

{{entries|length}} {{_('Results for:')}} {{adv_searchterm}}

+

{{result_count}} {{_('Results for:')}} {{adv_searchterm}}

{% if g.user.is_authenticated %} {% if g.user.shelf.all() or g.shelves_access %}