From 898357d1607b2cc9c498e655e6cdaab1a6b630f2 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Mon, 9 Dec 2013 10:38:17 +0100 Subject: [PATCH] Fixed remove entry popup. --- frontend/static/js/entries.js | 24 ++++++++++++++++++------ frontend/templates/index.html | 2 +- frontend/templates/remove_entry.html | 10 +++++----- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/frontend/static/js/entries.js b/frontend/static/js/entries.js index e80cf27..11aaa6c 100644 --- a/frontend/static/js/entries.js +++ b/frontend/static/js/entries.js @@ -307,11 +307,23 @@ var EntryController = function($scope, $http, $rootScope, $filter) { }); }; + $scope.removeEntry = function(entry) { + $scope.removingEntry = entry; + $("#remove_entry").modal({ + keyboard: false, + }); + }; + + $scope.hideRemoveEntryPopup = function() { + $scope.removingEntry = null; + $("#remove_entry").modal("hide"); + }; + // Removes an entry. - $scope.removeEntry = function(entry, modalScope) { + $scope.confirmRemoveEntry = function() { // Cancel current editing. - if (!$scope.isNew(entry)) { - $http.delete("/api/entries/" + entry.id).success(function (result) { + if ($scope.removingEntry) { + $http.delete("/api/entries/" + $scope.removingEntry.id).success(function (result) { $.pnotify({ type: "success", title: "Delete", @@ -319,9 +331,9 @@ var EntryController = function($scope, $http, $rootScope, $filter) { }); // Send the "entry removed" event. - $scope.$emit("entryRemovedEvent", entry); + $scope.$emit("entryRemovedEvent", $scope.removingEntry); - $scope.closeModal(modalScope); + $scope.hideRemoveEntryPopup(); }).error(function (data) { $.pnotify({ type: "error", @@ -329,7 +341,7 @@ var EntryController = function($scope, $http, $rootScope, $filter) { text: data }); - $scope.closeModal(modalScope); + $scope.hideRemoveEntryPopup(); }); } }; diff --git a/frontend/templates/index.html b/frontend/templates/index.html index a049fb7..36747ab 100644 --- a/frontend/templates/index.html +++ b/frontend/templates/index.html @@ -114,7 +114,7 @@ - diff --git a/frontend/templates/remove_entry.html b/frontend/templates/remove_entry.html index 5c96350..bf87d7c 100644 --- a/frontend/templates/remove_entry.html +++ b/frontend/templates/remove_entry.html @@ -19,19 +19,19 @@