From 4c38b0ab10f19be1b2c678c4f8b2ca39b26a8472 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Sun, 23 Aug 2020 09:13:44 +0200 Subject: [PATCH] Prepare for save name sort order --- cps/static/js/filter_list.js | 9 ++++++--- cps/static/js/main.js | 15 +++++++++------ cps/web.py | 6 ++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cps/static/js/filter_list.js b/cps/static/js/filter_list.js index 611bf3b4..b138d3b6 100644 --- a/cps/static/js/filter_list.js +++ b/cps/static/js/filter_list.js @@ -19,13 +19,16 @@ var direction = 0; // Descending order var sort = 0; // Show sorted entries $("#sort_name").click(function() { - /*$.ajax({ + var class_name = $("h1").attr('Class') + "_sort_name"; + var obj = {}; + obj[class_name] = sort; + $.ajax({ method:"post", contentType: "application/json; charset=utf-8", dataType: "json", url: window.location.pathname + "/../../ajax/view", - data: "{" + st + "}", - });*/ + data: JSON.stringify({obj}), + }); var count = 0; var index = 0; diff --git a/cps/static/js/main.js b/cps/static/js/main.js index c7eaec1b..6e9116e7 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -378,16 +378,19 @@ $(function() { }); $(".update-view").click(function(e) { - var target = $(this).data("target"); var view = $(this).data("view"); e.preventDefault(); e.stopPropagation(); - var data = {}; - data[target] = view; - console.debug("Updating view data: ", data); - $.post( "/ajax/view", data).done(function( ) { - location.reload(); + $.ajax({ + method:"post", + contentType: "application/json; charset=utf-8", + dataType: "json", + url: window.location.pathname + "/../../ajax/view", + data: JSON.stringify({"series_view":view}), + success: function success() { + location.reload(); + } }); }); }); diff --git a/cps/web.py b/cps/web.py index 16c9c997..b3ecc674 100644 --- a/cps/web.py +++ b/cps/web.py @@ -466,7 +466,7 @@ def toggle_archived(book_id): @web.route("/ajax/view", methods=["POST"]) @login_required def update_view(): - to_save = request.form.to_dict() + to_save = request.get_json() allowed_view = ['grid', 'list'] if "series_view" in to_save and to_save["series_view"] in allowed_view: try: @@ -481,10 +481,12 @@ def update_view(): except Exception: log.error("Could not save series_view_settings: %r %r", request, to_save) return "Invalid request", 400 + elif "authorslist" in to_save: + pass else: log.error("Invalid request received: %r %r", request, to_save) return "Invalid request", 400 - return "", 200 + return "1", 200 '''