From fdf482d14b7d8f564abb336aa46006ddc3feb3d0 Mon Sep 17 00:00:00 2001 From: Alvin Chow Date: Sun, 27 Sep 2015 16:14:34 -0700 Subject: [PATCH] Fix bug with rename feature to also delete old page --- realms/static/js/editor.js | 8 ++++++-- realms/templates/wiki/edit.html | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/realms/static/js/editor.js b/realms/static/js/editor.js index fc39062..08d7e6b 100644 --- a/realms/static/js/editor.js +++ b/realms/static/js/editor.js @@ -73,7 +73,11 @@ var aced = new Aced({ content: content }; - var path = Config['RELATIVE_PATH'] + '/' + data['name']; + // If renaming an existing page, use the old page name for the URL to PUT to + var subPath = (PAGE_NAME) ? PAGE_NAME : data['name'] + var path = Config['RELATIVE_PATH'] + '/' + subPath; + var newPath = Config['RELATIVE_PATH'] + '/' + data['name']; + var type = (Commit.info['sha']) ? "PUT" : "POST"; $.ajax({ @@ -87,7 +91,7 @@ var aced = new Aced({ $page_name.addClass('parsley-error'); bootbox.alert("

" + res['message'] + "

"); } else { - location.href = path; + location.href = newPath; } }); } diff --git a/realms/templates/wiki/edit.html b/realms/templates/wiki/edit.html index 3812f39..71c7dd1 100644 --- a/realms/templates/wiki/edit.html +++ b/realms/templates/wiki/edit.html @@ -3,6 +3,8 @@ @@ -169,4 +171,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %}