fix on note delete, select first

This commit is contained in:
Mo Bitar
2017-03-01 17:44:20 -06:00
parent 86c0ce3b9f
commit f7f0522f70
5 changed files with 12 additions and 10 deletions

View File

@@ -224,16 +224,9 @@ angular.module('app.frontend')
if(confirm("Are you sure you want to delete this note?")) { if(confirm("Are you sure you want to delete this note?")) {
this.remove()(this.note); this.remove()(this.note);
this.showMenu = false; this.showMenu = false;
this.notifyDelete();
} }
} }
this.notifyDelete = function() {
$timeout(function() {
$rootScope.$broadcast("noteDeleted");
}.bind(this), 500);
}
this.clickedEditNote = function() { this.clickedEditNote = function() {
this.editorMode = 'edit'; this.editorMode = 'edit';
this.focusEditor(100); this.focusEditor(100);

View File

@@ -153,6 +153,12 @@ angular.module('app.frontend')
this.$apply(fn); this.$apply(fn);
}; };
$scope.notifyDelete = function() {
$timeout(function() {
$rootScope.$broadcast("noteDeleted");
}.bind(this), 0);
}
$scope.deleteNote = function(note) { $scope.deleteNote = function(note) {
modelManager.setItemToBeDeleted(note); modelManager.setItemToBeDeleted(note);
@@ -163,6 +169,7 @@ angular.module('app.frontend')
if(note.dummy) { if(note.dummy) {
modelManager.removeItemLocally(note); modelManager.removeItemLocally(note);
$scope.notifyDelete();
return; return;
} }
@@ -170,8 +177,11 @@ angular.module('app.frontend')
if(authManager.offline()) { if(authManager.offline()) {
// when deleting items while ofline, we need to explictly tell angular to refresh UI // when deleting items while ofline, we need to explictly tell angular to refresh UI
setTimeout(function () { setTimeout(function () {
$scope.notifyDelete();
$scope.safeApply(); $scope.safeApply();
}, 50); }, 50);
} else {
$scope.notifyDelete();
} }
}); });
} }

View File

@@ -4,7 +4,6 @@ angular.module('app.frontend')
scope: { scope: {
addNew: "&", addNew: "&",
selectionMade: "&", selectionMade: "&",
remove: "&",
tag: "=", tag: "=",
removeTag: "&" removeTag: "&"
}, },

View File

@@ -112,7 +112,7 @@ angular.module('app.frontend')
}.bind(this)) }.bind(this))
.catch(function(response){ .catch(function(response){
console.log("Registration error", response); console.log("Registration error", response);
callback(null); callback(response.data);
}) })
}.bind(this)); }.bind(this));
} }

View File

@@ -4,7 +4,7 @@
"tags" => "tags"} "tags" => "tags"}
%notes-section{"remove-tag" => "notesRemoveTag", "add-new" => "notesAddNew", "selection-made" => "notesSelectionMade", %notes-section{"remove-tag" => "notesRemoveTag", "add-new" => "notesAddNew", "selection-made" => "notesSelectionMade",
"tag" => "selectedTag", "remove" => "deleteNote"} "tag" => "selectedTag"}
%editor-section{"note" => "selectedNote", "remove" => "deleteNote", "save" => "saveNote", "update-tags" => "updateTagsForNote"} %editor-section{"note" => "selectedNote", "remove" => "deleteNote", "save" => "saveNote", "update-tags" => "updateTagsForNote"}