diff --git a/src/Web/wwwroot/app/vault/vaultController.js b/src/Web/wwwroot/app/vault/vaultController.js
index 8b5368cd65..f97ab17740 100644
--- a/src/Web/wwwroot/app/vault/vaultController.js
+++ b/src/Web/wwwroot/app/vault/vaultController.js
@@ -77,13 +77,25 @@
}
});
- editModel.result.then(function (editedSite) {
- var site = $filter('filter')($scope.sites, { id: editedSite.id }, true);
- if (site && site.length > 0) {
- site[0].folderId = editedSite.folderId;
- site[0].name = editedSite.name;
- site[0].username = editedSite.username;
- site[0].favorite = editedSite.favorite;
+ editModel.result.then(function (returnVal) {
+ if (returnVal.action === 'edit') {
+ var siteToUpdate = $filter('filter')($scope.sites, { id: returnVal.data.id }, true);
+
+ if (siteToUpdate && siteToUpdate.length > 0) {
+ siteToUpdate[0].folderId = returnVal.data.folderId;
+ siteToUpdate[0].name = returnVal.data.name;
+ siteToUpdate[0].username = returnVal.data.username;
+ siteToUpdate[0].favorite = returnVal.data.favorite;
+ }
+ }
+ else if (returnVal.action === 'delete') {
+ var siteToDelete = $filter('filter')($scope.sites, { id: returnVal.data }, true);
+ if (siteToDelete && siteToDelete.length > 0) {
+ var index = $scope.sites.indexOf(siteToDelete[0]);
+ if (index > -1) {
+ $scope.sites.splice(index, 1);
+ }
+ }
}
});
};
diff --git a/src/Web/wwwroot/app/vault/vaultEditSiteController.js b/src/Web/wwwroot/app/vault/vaultEditSiteController.js
index 3aa01e2e12..630a17f8fd 100644
--- a/src/Web/wwwroot/app/vault/vaultEditSiteController.js
+++ b/src/Web/wwwroot/app/vault/vaultEditSiteController.js
@@ -15,7 +15,10 @@
$scope.savePromise = apiService.sites.put({ id: siteId }, site, function (siteResponse) {
$analytics.eventTrack('Edited Site');
var decSite = cipherService.decryptSite(siteResponse);
- $uibModalInstance.close(decSite);
+ $uibModalInstance.close({
+ action: 'edit',
+ data: decSite
+ });
}).$promise;
};
@@ -49,6 +52,19 @@
}
}
+ $scope.delete = function () {
+ if (!confirm('Are you sure you want to delete this site (' + $scope.site.name + ')?')) {
+ return;
+ }
+
+ apiService.sites.del({ id: $scope.site.id }, function () {
+ $uibModalInstance.close({
+ action: 'delete',
+ data: $scope.site.id
+ });
+ });
+ };
+
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
diff --git a/src/Web/wwwroot/app/vault/views/vaultEditSite.html b/src/Web/wwwroot/app/vault/views/vaultEditSite.html
index f2f6c3892f..2d1d47bff6 100644
--- a/src/Web/wwwroot/app/vault/views/vaultEditSite.html
+++ b/src/Web/wwwroot/app/vault/views/vaultEditSite.html
@@ -97,5 +97,8 @@
Save
+