From 2245c7f00fa6a25ed1edf99886b0b31d07c72c6a Mon Sep 17 00:00:00 2001 From: Matias De lellis Date: Tue, 12 Feb 2019 15:08:03 -0300 Subject: [PATCH] WII.. Finally add a confirmation before deleting a note. --- js/script.js | 53 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/js/script.js b/js/script.js index 471c571..e624050 100644 --- a/js/script.js +++ b/js/script.js @@ -359,18 +359,27 @@ View.prototype = { event.stopPropagation(); self._notes.load(id); - self._notes.removeActive().done(function () { - if (self._notes.length() > 0) { - $(".notes-grid").isotope('remove', note.parent()) - .isotope('layout'); - self.showAll(); - self.renderNavigation(); - } else { - self.render(); - } - }).fail(function () { - alert('Could not delete note, not found'); - }); + OC.dialogs.confirm( + t('quicknotes', 'Are you sure you want to delete the note?'), + t('quicknotes', 'Delete note'), + function(result) { + if (result) { + self._notes.removeActive().done(function () { + if (self._notes.length() > 0) { + $(".notes-grid").isotope('remove', note.parent()) + .isotope('layout'); + self.showAll(); + self.renderNavigation(); + } else { + self.render(); + } + }).fail(function () { + alert('Could not delete note, not found'); + }); + } + }, + true + ); }); /* @@ -595,12 +604,20 @@ View.prototype = { $('#app-navigation .note .delete').click(function () { var entry = $(this).closest('.note'); entry.find('.app-navigation-entry-menu').removeClass('open'); - - self._notes.removeActive().done(function () { - self.render(); - }).fail(function () { - alert('Could not delete note, not found'); - }); + OC.dialogs.confirm( + t('quicknotes', 'Are you sure you want to delete the note?'), + t('quicknotes', 'Delete note'), + function(result) { + if (result) { + self._notes.removeActive().done(function () { + self.render(); + }).fail(function () { + alert('Could not delete note, not found'); + }); + } + }, + true + ); }); // show a note