mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
Added delete option to edit site modal #25
This commit is contained in:
parent
9405be03b0
commit
0050b570b4
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -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');
|
||||
};
|
||||
|
@ -97,5 +97,8 @@
|
||||
<i class="fa fa-refresh fa-spin loading-icon" ng-show="editSiteForm.$loading"></i>Save
|
||||
</button>
|
||||
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
|
||||
<button type="button" class="btn btn-link pull-right" ng-click="delete()" uib-tooltip="Delete">
|
||||
<i class="fa fa-trash fa-lg"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user