aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-07-17 12:53:20 -0400
committerPaul Duncan <pabs@pablotron.org>2016-07-17 12:53:20 -0400
commita8b773addc615f85c5e6fbb1835581c25c75504e (patch)
tree219bceeec7accd84157defcff91990c8a6722829
parent2dd59c8a570a4bb28129b9ef3fd36b8e18ff5a9c (diff)
downloadguff-a8b773addc615f85c5e6fbb1835581c25c75504e.tar.bz2
guff-a8b773addc615f85c5e6fbb1835581c25c75504e.zip
add file move interface
-rw-r--r--data/assets/js/admin/tabs/files.js27
1 files changed, 26 insertions, 1 deletions
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($) {
"</div><!-- btn-group -->",
],
+ 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', {