(web) New menu option to move mailboxes

Fixes #644
Fixes #3511
Fixes #4479
This commit is contained in:
Francis Lachapelle
2018-07-27 15:21:35 -04:00
parent 7e75c8be45
commit 894769ef6f
5 changed files with 177 additions and 2 deletions
@@ -485,7 +485,7 @@
/**
* @function $rename
* @memberof AddressBook.prototype
* @desc Rename the addressbook and keep the list sorted
* @desc Rename the mailbox and keep the list sorted
* @param {string} name - the new name
* @returns a promise of the HTTP operation
*/
@@ -827,6 +827,21 @@
this.$shadowData = this.$omit();
};
/**
* @function $move
* @memberof Mailbox.prototype
* @desc Move the mailbox to a different parent. Will reload the mailboxes list.
* @returns a promise of the HTTP operation
*/
Mailbox.prototype.$move = function(parentPath) {
var _this = this;
return Mailbox.$$resource.post(this.id, 'move', {parent: parentPath}).finally(function() {
_this.$account.$getMailboxes({reload: true});
return true;
});
};
/**
* @function $save
* @memberof Mailbox.prototype
@@ -296,6 +296,37 @@
});
};
this.isParentOf = function(path) {
var findChildren;
// Local recursive function
findChildren = function(parent) {
if (parent.children && parent.children.length > 0) {
for (var i = 0, found = false; !found && i < parent.children.length; i++) {
var o = parent.children[i];
if (o.children && o.children.length > 0) {
if (findChildren(o)) {
return true;
}
}
else if (o.path == path) {
return true;
}
}
}
else {
return (parent.path == path);
}
};
return findChildren(this.folder);
};
this.moveFolder = function(path) {
this.folder.$move(path);
mdPanelRef.close();
};
} // MenuController