From a8b773addc615f85c5e6fbb1835581c25c75504e Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 17 Jul 2016 12:53:20 -0400 Subject: add file move interface --- data/assets/js/admin/tabs/files.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'data/assets') diff --git a/data/assets/js/admin/tabs/files.js b/data/assets/js/admin/tabs/files.js index 0e26b2f..56fb6c9 100644 --- a/data/assets/js/admin/tabs/files.js +++ b/data/assets/js/admin/tabs/files.js @@ -57,6 +57,10 @@ jQuery(function($) { "", ], + move_prompt: [ + "Enter destination path for \"%{name|h}\":", + ], + delete_confirm: [ "Are you sure you want to delete \"%{name|h}\"?", ], @@ -176,7 +180,28 @@ jQuery(function($) { if (data.url) location.href = url; } else if (action_id == 'move') { - alert('TODO: move file'); + var dst_path = prompt(TEMPLATES.run('move_prompt', data), data.path); + if (dst_path) { + send('file/move', { + src_path: data.path, + dst_path: dst_path, + }).always(function() { + // TODO: need loading handler + }).fail(function(r) { + var error = r.responseText; + + try { + var data = $.parseJSON(r.responseText); + if (data.error) + error = data.error; + } catch (e) {} + + alert("Error: " + error); + }).done(function() { + // reload file list + reload(); + }); + } } else if (action_id == 'delete') { if (confirm(TEMPLATES.run('delete_confirm', data))) { send('file/delete', { -- cgit v1.2.3