View status in books table is stored

pull/1539/head
Ozzieisaacs 5 years ago
parent c18d5786dd
commit d44f283a05

@ -945,15 +945,18 @@ def get_sorted_entry(field, bookid):
return json.dumps({'sort': book.sort})
elif field == 'authors':
return json.dumps({'author_sort': book.author_sort})
return ''
return ""
@editbook.route("/ajax/deletebooks")
@login_required
def delete_list_book():
pass
return ""
@editbook.route("/ajax/mergebooks", methods=['POST'])
@login_required
def merge_list_book():
vals = request.get_json()
# load first book
# load every next book, append data to first book, delete 2nd book
return ""

@ -42,6 +42,17 @@ $(function() {
$("#merge_books").addClass("disabled");
$("#merge_books").attr("aria-disabled", true);
}
if (selections.length < 1) {
$("#delete_selection").addClass("disabled");
$("#delete_selection").attr("aria-disabled", true);
}
else{
$("#delete_selection").removeClass("disabled");
$("#delete_selection").attr("aria-disabled", false);
}
});
$("#delete_selection").click(function() {
$("#books-table").bootstrapTable('uncheckAll');
});
$("#merge_books").click(function() {
@ -108,7 +119,7 @@ $(function() {
id: row.id,
field: key,
value: data[key]
})
});
console.log(data);
}
});
@ -117,25 +128,39 @@ $(function() {
onColumnSwitch: function (field, checked) {
var visible = $("#books-table").bootstrapTable('getVisibleColumns');
var hidden = $("#books-table").bootstrapTable('getHiddenColumns');
// to save current setting
// coresponding event: onColumnSwitch
//$table.bootstrapTable('getVisibleColumns')
//$table.bootstrapTable('getHiddenColumns').
var visibility =[]
var st = ""
visible.forEach(function(item) {
st += "\""+ item.field + "\":\"" +"true"+ "\","
/*var element = {};
element[item.field] = "true";
visibility.push(element);*/
});
hidden.forEach(function(item) {
st += "\""+ item.field + "\":\"" +"false"+ "\","
/*var element = {};
element[item.field] = "false";
visibility.push(element);*/
});
/*
visibility.forEach(function(item) {
st += JSON.stringify(item) + ',';
});*/
st = st.slice(0, -1);
$.ajax({
method:"post",
contentType: "application/json; charset=utf-8",
dataType: "json",
url: window.location.pathname + "/../../ajax/table_settings",
data: JSON.stringify({"Merge_books":selections}),
success: function success() {
// ToDo:
}
data: "{" + st + "}",
});
}
},
});
// to save current setting
// coresponding event: onColumnSwitch
//$table.bootstrapTable('getVisibleColumns')
//$table.bootstrapTable('getHiddenColumns').
$("#domain_allow_submit").click(function(event) {
event.preventDefault();

@ -1,6 +1,7 @@
{% extends "layout.html" %}
{% macro text_table_row(parameter, edit_text, show_text, validate) -%}
<th data-field="{{ parameter }}" id="{{ parameter }}" data-sortable="true"
data-visible = "{{visiblility.get(parameter)}}"
{% if g.user.role_edit() %}
data-editable-type="text"
data-editable-url="{{ url_for('editbook.edit_list_book', param=parameter)}}"
@ -18,9 +19,15 @@
{% block body %}
<h2 class="{{page}}">{{_(title)}}</h2>
<div class="btn btn-default disabled" id="merge_books" aria-disabled="true">{{_('Merge selected books')}}</div>
<div class="btn btn-default" id="delete_selection" aria-disabled="false">{{_('Remove Selections')}}</div>
<div class="btn btn-default" id="autoupdate_titlesort" aria-disabled="false">{{_('Update Title Sort automatically')}}</div>
<div class="btn btn-default" id="autoupdate_autorsort" aria-disabled="false">{{_('Update Author Sort automatically')}}</div>
<div class="btn btn-default disabled" id="delete_selection" aria-disabled="true">{{_('Remove Selections')}}</div>
<div class="form-group">
<input type="checkbox" id="autoupdate_titlesort" name="autoupdate_titlesort">
<label for="autoupdate_titlesort">{{_('Update Title Sort automatically')}}</label>
</div>
<div class="form-group">
<input type="checkbox" id="autoupdate_autorsort" name="autoupdate_autorsort">
<label for="autoupdate_autorsort">{{_('Update Author Sort automatically')}}</label>
</div>
<table id="books-table" class="table table-no-bordered table-striped"
data-url="{{url_for('web.list_books')}}">
<thead>
@ -35,12 +42,12 @@
{{ text_table_row('authors', _('Enter Authors'),_('Authors'), true) }}
{{ text_table_row('tags', _('Enter Categories'),_('Categories'), false) }}
{{ text_table_row('series', _('Enter Series'),_('Series'), false) }}
<th data-field="series_index" id="series_index" data-edit-validate="{{ _('This Field is Required') }}" 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-edit="true" data-editable-title="{{_('Enter title')}}"{% endif %}>{{_('Series Index')}}</th>
<th data-field="series_index" id="series_index" data-visible="{{visiblility.get('series_index')}}" data-edit-validate="{{ _('This Field is Required') }}" 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-edit="true" data-editable-title="{{_('Enter title')}}"{% endif %}>{{_('Series Index')}}</th>
{{ text_table_row('languages', _('Enter Languages'),_('Languages'), false) }}
<th data-field="pubdate" data-type="date" data-viewformat="dd.mm.yyyy" id="pubdate" data-sortable="true">{{_('Publishing Date')}}</th>
<th data-field="pubdate" data-type="date" data-visible="{{visiblility.get('pubdate')}}" data-viewformat="dd.mm.yyyy" id="pubdate" data-sortable="true">{{_('Publishing Date')}}</th>
{{ text_table_row('publishers', _('Enter Publishers'),_('Publishers'), false) }}
{% if g.user.role_edit() %}
<th data-align="right" data-formatter="EbookActions" data-switchable="false"></th>
<th data-align="right" data-formatter="EbookActions" data-switchable="false">{{_('Delete')}}</th>
{% endif %}
</tr>
</thead>

@ -218,6 +218,7 @@ class User(UserBase, Base):
allowed_column_value = Column(String, default="")
remote_auth_token = relationship('RemoteAuthToken', backref='user', lazy='dynamic')
series_view = Column(String(10), default="list")
view_settings = Column(String, default="list")
if oauth_support:
@ -259,6 +260,7 @@ class Anonymous(AnonymousUserMixin, UserBase):
self.denied_column_value = data.denied_column_value
self.allowed_column_value = data.allowed_column_value
self.series_view = data.series_view
self.view_settings = data.view_settings
def role_admin(self):
return False
@ -570,6 +572,11 @@ def migrate_Database(session):
except exc.OperationalError:
conn = engine.connect()
conn.execute("ALTER TABLE user ADD column `series_view` VARCHAR(10) DEFAULT 'list'")
try:
session.query(exists().where(User.view_settings)).scalar()
except exc.OperationalError:
conn = engine.connect()
conn.execute("ALTER TABLE user ADD column `view_settings` VARCHAR DEFAULT '{}'")
if session.query(User).filter(User.role.op('&')(constants.ROLE_ANONYMOUS) == constants.ROLE_ANONYMOUS).first() \
is None:
@ -591,6 +598,7 @@ def migrate_Database(session):
"sidebar_view INTEGER,"
"default_language VARCHAR(3),"
"series_view VARCHAR(10),"
"view_settings VARCHAR,"
"UNIQUE (nickname),"
"UNIQUE (email))")
conn.execute("INSERT INTO user_id(id, nickname, email, role, password, kindle_mail,locale,"

@ -829,8 +829,12 @@ def render_language_books(page, name, order):
@web.route("/table")
@login_required
def books_table():
# __, __, pagination = calibre_db.fill_indexpage(1, 0, db.Books, True, [db.Books.timestamp.asc()])
return render_title_template('book_table.html', title=_(u"Books list"), page="book_table") #, pagination=pagination)
try:
visibility = json.loads(current_user.view_settings)
except Exception:
visibility = {}
return render_title_template('book_table.html', title=_(u"Books list"), page="book_table",
visiblility=visibility)
@web.route("/ajax/listbooks")
@login_required
@ -865,11 +869,14 @@ def list_books():
response.headers["Content-Type"] = "application/json; charset=utf-8"
return response
@web.route("/ajax/table_settings")
@web.route("/ajax/table_settings", methods=['POST'])
@login_required
def update_table_settings():
# vals = request.get_json()
# ToDo: Save table settings
pass
current_user.view_settings = request.data
ub.session.commit()
return ""
@web.route("/author")
@login_required_if_no_ano

Loading…
Cancel
Save