Prepare for save name sort order

This commit is contained in:
OzzieIsaacs 2020-08-23 09:13:44 +02:00
parent ed8275a20b
commit 4c38b0ab10
3 changed files with 19 additions and 11 deletions

View File

@ -19,13 +19,16 @@ var direction = 0; // Descending order
var sort = 0; // Show sorted entries var sort = 0; // Show sorted entries
$("#sort_name").click(function() { $("#sort_name").click(function() {
/*$.ajax({ var class_name = $("h1").attr('Class') + "_sort_name";
var obj = {};
obj[class_name] = sort;
$.ajax({
method:"post", method:"post",
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
dataType: "json", dataType: "json",
url: window.location.pathname + "/../../ajax/view", url: window.location.pathname + "/../../ajax/view",
data: "{" + st + "}", data: JSON.stringify({obj}),
});*/ });
var count = 0; var count = 0;
var index = 0; var index = 0;

View File

@ -378,16 +378,19 @@ $(function() {
}); });
$(".update-view").click(function(e) { $(".update-view").click(function(e) {
var target = $(this).data("target");
var view = $(this).data("view"); var view = $(this).data("view");
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
var data = {}; $.ajax({
data[target] = view; method:"post",
console.debug("Updating view data: ", data); contentType: "application/json; charset=utf-8",
$.post( "/ajax/view", data).done(function( ) { dataType: "json",
url: window.location.pathname + "/../../ajax/view",
data: JSON.stringify({"series_view":view}),
success: function success() {
location.reload(); location.reload();
}
}); });
}); });
}); });

View File

@ -466,7 +466,7 @@ def toggle_archived(book_id):
@web.route("/ajax/view", methods=["POST"]) @web.route("/ajax/view", methods=["POST"])
@login_required @login_required
def update_view(): def update_view():
to_save = request.form.to_dict() to_save = request.get_json()
allowed_view = ['grid', 'list'] allowed_view = ['grid', 'list']
if "series_view" in to_save and to_save["series_view"] in allowed_view: if "series_view" in to_save and to_save["series_view"] in allowed_view:
try: try:
@ -481,10 +481,12 @@ def update_view():
except Exception: except Exception:
log.error("Could not save series_view_settings: %r %r", request, to_save) log.error("Could not save series_view_settings: %r %r", request, to_save)
return "Invalid request", 400 return "Invalid request", 400
elif "authorslist" in to_save:
pass
else: else:
log.error("Invalid request received: %r %r", request, to_save) log.error("Invalid request received: %r %r", request, to_save)
return "Invalid request", 400 return "Invalid request", 400
return "", 200 return "1", 200
''' '''