1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00:00
Files
browser/src/popup/app/vault/vaultAttachmentsController.js
2017-07-12 00:11:17 -04:00

58 lines
2.0 KiB
JavaScript

angular
.module('bit.vault')
.controller('vaultAttachmentsController', function ($scope, $state, $stateParams, loginService, folderService,
cryptoService, $q, toastr, SweetAlert, utilsService, $analytics, i18nService) {
$scope.i18n = i18nService;
$scope.login = $stateParams.login;
utilsService.initListSectionItemListeners($(document), angular);
$scope.submitPromise = null;
$scope.submit = function () {
$scope.close(true);
};
$scope.delete = function (attachment) {
SweetAlert.swal({
title: i18nService.deleteAttachment,
text: i18nService.deleteAttachmentConfirmation,
showCancelButton: true,
confirmButtonText: i18nService.yes,
cancelButtonText: i18nService.no
}, function (confirmed) {
if (confirmed) {
$q.when(loginService.deleteAttachmentWithServer($stateParams.id, attachment.id)).then(function () {
$analytics.eventTrack('Deleted Attachment');
toastr.success(i18nService.deletedAttachment);
});
}
});
};
$scope.close = function (allOut) {
if (!allOut) {
$state.go('editLogin', {
loginId: $stateParams.id,
animation: 'out-slide-down',
from: $stateParams.from,
fromView: $stateParams.fromView
});
return;
}
if ($stateParams.fromView) {
$state.go('viewLogin', {
loginId: $stateParams.id,
animation: 'out-slide-down',
from: $stateParams.from
});
}
else {
$state.go('tabs.vault', {
animation: 'out-slide-down'
});
}
};
});