Title in table translatable

Edit some elements in table possible
Checkbox state is kept over page change in book table
Fix missing div in layout
pull/1539/head
Ozzieisaacs 4 years ago
parent 6bfbf3ee41
commit 94b5ec91cc

@ -887,3 +887,39 @@ def convert_bookformat(book_id):
else:
flash(_(u"There was an error converting this book: %(res)s", res=rtn), category="error")
return redirect(url_for('editbook.edit_book', book_id=book_id))
@editbook.route("/ajax/editbooks/<param>", methods=['POST'])
@login_required_if_no_ano
def edit_list_book(param):
vals = request.form.to_dict()
#calibre_db.update_title_sort(config)
#calibre_db.session.connection().connection.connection.create_function('uuid4', 0, lambda: str(uuid4()))
book = calibre_db.get_book(vals['pk'])
if param =='series_index':
edit_book_series_index(vals['value'], book)
elif param =='tags':
edit_book_tags(vals['value'], book)
elif param =='series':
edit_book_series(vals['value'], book)
elif param =='publishers':
edit_book_publisher(vals['value'], book)
# ToDo: edit books
elif param =='languages':
edit_book_languages(vals['value'], book)
elif param =='title':
edit_book_languages(vals['value'], book)
elif param =='sort':
edit_book_languages(vals['value'], book)
elif param =='author_sort':
edit_book_languages(vals['value'], book)
elif param =='authors':
edit_book_languages(vals['value'], book)
book.last_modified = datetime.utcnow()
calibre_db.session.commit()
return ""
@editbook.route("/ajax/deletebooks")
@login_required_if_no_ano
def delete_list_book():
pass

@ -1,4 +1,8 @@
{% extends "layout.html" %}
{% macro text_table_row(parameter, edit_text, show_text) -%}
<th data-field="{{ parameter }}" id="{{ parameter }}" data-sortable="true" {% if g.user.role_edit() %}data-editable-type="text" data-editable-url="{{ url_for('editbook.edit_list_book', param=parameter)}}" data-editable="true" data-editable-title="{{ edit_text}}"{% endif %}>{{ show_text }}</th>
{%- endmacro %}
{% block header %}
<link href="{{ url_for('static', filename='css/libs/bootstrap-table.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/libs/bootstrap-editable.css') }}" rel="stylesheet">
@ -21,25 +25,25 @@
data-search-on-enter-key="true"
data-checkbox-header="false"
data-maintain-meta-data="true"
data-response-handler="responseHandler"
data-editable-emptytext="<span class='glyphicon glyphicon-plus'></span>">
<thead>
<tr>
<!--th data-field="title" id="title" data-editable-type="text" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"></th-->
{% if g.user.role_edit() %}
<th data-checkbox="true" data-sortable="true"></th>
<th data-field="state" data-checkbox="true" data-sortable="true"></th>
{% endif %}
<th data-field="id" id="id" data-visible="false" data-switchable="false"></th>
<th data-field="title" id="title" data-sortable="true" {% if g.user.role_edit() %}data-editable-type="text" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>Title</th>
<th data-field="sort" id="sort" data-sortable="true" {% if g.user.role_edit() %}data-editable-type="text" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>Sort</th>
<th data-field="author_sort" id="author_sort" data-sortable="true" {% if g.user.role_edit() %}data-editable-type="text" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>Authors Sort</th>
<th data-field="authors" id="authors" data-sortable="true" {% if g.user.role_edit() %}data-editable-type="text" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>Authors</th>
<th data-field="tags" id="tags" data-sortable="true" {% if g.user.role_edit() %}data-editable-type="text" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>Tags</th>
<th data-field="series" id="series" data-sortable="true" {% if g.user.role_edit() %}data-editable-type="text" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>Series</th>
<th data-field="series_index" id="series_index" data-sortable="true" {% if g.user.role_edit() %} data-editable-type="number" data-editable-placeholder="1" data-editable-step="0.01" data-editable-min="0" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>Series Index</th>
<th data-field="languages" id="languages" data-sortable="true" {% if g.user.role_edit() %}data-editable-type="text" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>Language</th>
{{ text_table_row('title', _('Enter Title'),_('Title')) }}
{{ text_table_row('sort', _('Enter Titlesort'),_('Sort')) }}
{{ text_table_row('author_sort', _('Enter Authorsort'),_('Authors Sort')) }}
{{ text_table_row('authors', _('Enter Authors'),_('Authors')) }}
{{ text_table_row('tags', _('Enter Tags'),_('Tags')) }}
{{ text_table_row('series', _('Enter Series'),_('Series')) }}
<th data-field="series_index" id="series_index" data-sortable="true" {% if g.user.role_edit() %} data-editable-type="number" data-editable-placeholder="1" data-editable-step="0.01" data-editable-min="0" data-editable-url="{{ url_for('editbook.edit_list_book', param='series_index')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>{{_('Series Index')}}</th>
{{ text_table_row('languages', _('Enter Languages'),_('Languages')) }}
<th data-field="pubdate" id="pubdate" data-sortable="true">Publishing Date</th>
<th data-field="publishers" id="publishers" data-sortable="true" {% if g.user.role_edit() %}data-editable-type="text" data-editable-url="{{ url_for('web.edit_list_book')}}" data-editable="true" data-editable-title="{{_('Enter title')}}"{% endif %}>Publishers</th>
{{ text_table_row('publishers', _('Enter Publishers'),_('Publishers')) }}
{% if g.user.role_edit() %}
<th data-align="right" data-formatter="EbookActions" data-switchable="false"></th>
{% endif %}
@ -55,4 +59,33 @@
<script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table-editable.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-editable.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/table.js') }}"></script>
<script>
var $table = $('#books-table')
var selections = []
function responseHandler(res) {
$.each(res.rows, function (i, row) {
row.state = $.inArray(row.id, selections) !== -1
})
return res
}
$(function() {
$table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table',
function (e, rowsAfter, rowsBefore) {
var rows = rowsAfter
if (e.type === 'uncheck-all') {
rows = rowsBefore
}
var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) {
return row.id
})
var func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference'
selections = window._[func](selections, ids)
})
})
</script>
{% endblock %}

@ -173,6 +173,7 @@
{% endif %}
</div>
</div>
</div>
<div class="modal fade" id="bookDetailsModal" tabindex="-1" role="dialog" aria-labelledby="bookDetailsModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">

@ -77,11 +77,6 @@ try:
except ImportError:
pass # We're not using Python 3
#try:
# import rarfile
# feature_support['rar'] = True
#except ImportError:
# feature_support['rar'] = False
try:
from natsort import natsorted as sort
@ -862,15 +857,6 @@ def list_books():
response.headers["Content-Type"] = "application/json; charset=utf-8"
return response
@web.route("/ajax/editbooks")
@login_required_if_no_ano
def edit_list_book():
pass
@web.route("/ajax/editbooks")
@login_required_if_no_ano
def delete_list_book():
pass
@web.route("/author")
@login_required_if_no_ano

Loading…
Cancel
Save