Fix bug with rename feature to also delete old page

This commit is contained in:
Alvin Chow 2015-09-27 16:14:34 -07:00
parent 459a9c2c59
commit fdf482d14b
2 changed files with 9 additions and 3 deletions

View file

@ -73,7 +73,11 @@ var aced = new Aced({
content: content 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"; var type = (Commit.info['sha']) ? "PUT" : "POST";
$.ajax({ $.ajax({
@ -87,7 +91,7 @@ var aced = new Aced({
$page_name.addClass('parsley-error'); $page_name.addClass('parsley-error');
bootbox.alert("<h3>" + res['message'] + "</h3>"); bootbox.alert("<h3>" + res['message'] + "</h3>");
} else { } else {
location.href = path; location.href = newPath;
} }
}); });
} }

View file

@ -3,6 +3,8 @@
<script> <script>
var Commit = {}; var Commit = {};
Commit.info = {{ info|tojson }}; Commit.info = {{ info|tojson }};
var PAGE_NAME = '{{ name }}';
</script> </script>
<script src="{{ url_for('static', filename='js/editor.js') }}"></script> <script src="{{ url_for('static', filename='js/editor.js') }}"></script>
@ -169,4 +171,4 @@
</div> </div>
{% endblock %} {% endblock %}