frontend now correctly changes folder status during moving / creating / deleting notes

This commit is contained in:
azivner 2017-06-11 15:40:52 -04:00
parent 20a1e71100
commit db21db18e8

View File

@ -289,6 +289,11 @@
url: baseUrl + 'notes/' + node.key, url: baseUrl + 'notes/' + node.key,
type: 'DELETE', type: 'DELETE',
success: function(result) { success: function(result) {
if (node.getParent() != null && node.getParent().getChildren().length <= 1) {
node.getParent().folder = false;
node.getParent().renderTitle();
}
node.remove(); node.remove();
} }
}); });
@ -325,6 +330,11 @@
type: 'PUT', type: 'PUT',
contentType: "application/json", contentType: "application/json",
success: function(result) { success: function(result) {
if (node.getParent() != null && node.getParent().getChildren().length <= 1) {
node.getParent().folder = false;
node.getParent().renderTitle();
}
node.moveTo(node.getParent(), 'after'); node.moveTo(node.getParent(), 'after');
} }
}); });
@ -342,6 +352,9 @@
node.moveTo(prevSibling); node.moveTo(prevSibling);
prevSibling.setExpanded(true); prevSibling.setExpanded(true);
prevSibling.folder = true;
prevSibling.renderTitle();
} }
}); });
} }
@ -391,6 +404,9 @@
} }
else { else {
node.addChildren(newNode).setActive(true); node.addChildren(newNode).setActive(true);
node.folder = true;
node.renderTitle();
} }
message("Created!"); message("Created!");