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?")) {
this.remove()(this.note);
this.showMenu = false;
this.notifyDelete();
}
}
this.notifyDelete = function() {
$timeout(function() {
$rootScope.$broadcast("noteDeleted");
}.bind(this), 500);
}
this.clickedEditNote = function() {
this.editorMode = 'edit';
this.focusEditor(100);

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@
"tags" => "tags"}
%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"}