Hook up the PathControl and Actor up to the move service request.
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 4 Oct 2010 15:33:49 +0000 (11:33 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 4 Oct 2010 15:33:49 +0000 (11:33 -0400)
web_frontend/actor.js
web_frontend/file.js
web_frontend/path_control.js

index 8517031a6f66ab22c65b9c6b4a7998eb05dcf1b9..fb280c5998022b9ef21e3e46e4fdf81826c264bf 100644 (file)
@@ -174,6 +174,18 @@ armadillo.Actor.prototype.performMove_ = function() {
   var editor = new armadillo.PathControl(this.file_.getFullPath(), true);
   dialog.addChild(editor, true);
 
+  var closeCallback = function(e) {
+    if (e.key != goog.ui.Dialog.DefaultButtonKeys.CANCEL) {
+      var newPath = editor.getPath();
+      this.file_.move(newPath);
+    }
+    dialog.dispose();
+    this.dispose();
+  };
+  // Will be removed when the event source closes.
+  goog.events.listen(dialog, goog.ui.Dialog.SELECT_EVENT,
+      closeCallback, false, this);
+
   dialog.setVisible(true);
   var position = goog.style.getPosition(dialog.getElement());
   goog.style.setPosition(dialog.getElement(), position.x, '10%');
@@ -197,6 +209,8 @@ armadillo.Actor.prototype.performDelete_ = function() {
   var closeCallback = function(e) {
     if (e.key != goog.ui.Dialog.DefaultButtonKeys.CANCEL) {
       this.file_.remove();
+      confirm.dispose();
+      this.dispose();
     }
   };
   // Will be removed when the event source closes.
index 4b8ccb5165191b2f949007620eee702e4811e561..54ec108cbcaaedd832ff20b06a5f9bfd74fa09c3 100644 (file)
@@ -119,6 +119,24 @@ armadillo.File.prototype.remove = function() {
   app.sendRequest('remove', {'path':this.path_ + this.name_}, callback);
 };
 
+/**
+ * Moves a file from one absolute path to another. On success, it will navigate
+ * to the new path.
+ * @param  {string}  dest  The destination path.
+ */
+armadillo.File.prototype.move = function(dest) {
+  var file = this;
+  var callback = function(data) {
+    if (data['error']) {
+      app.showError(data['message']);
+    } else {
+      app.clearError();
+      app.list(app.stripLastPathComponent(dest));
+    }
+  };
+  app.sendRequest('move', {'source':this.getFullPath(), 'target':dest}, callback);
+};
+
 /**
  * Click handler for the list element.
  * @param  {Event}  e
index aa4a6254ba89b3f8b68fa8f48d495a7e2daea72e..b743a796944dd7ee4532ec4ef2788f952793074e 100644 (file)
@@ -73,6 +73,14 @@ armadillo.PathControl.prototype.setPath = function(path) {
   console.log(this.path_ + ' = ' + this.name_);
 };
 
+/**
+ * Gets the new path.
+ * @returns  {string}
+ */
+armadillo.PathControl.prototype.getPath = function() {
+  return app.joinPath(this.path_, this.name_);
+};
+
 /**
  * Creates a new path control object.
  */