From 89b1639ddae9c9f6a211a0cd8e05dc8bd6ef2a4a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 12 Jul 2017 00:11:17 -0400 Subject: [PATCH] setup attachments page --- src/_locales/en/messages.json | 24 ++++++++ src/popup/app/config.js | 7 +++ .../app/vault/vaultAttachmentsController.js | 57 +++++++++++++++++++ .../app/vault/vaultEditLoginController.js | 10 ++++ .../app/vault/views/vaultAttachments.html | 40 +++++++++++++ src/popup/app/vault/views/vaultEditLogin.html | 4 ++ src/popup/index.html | 1 + src/popup/less/components.less | 8 +++ 8 files changed, 151 insertions(+) create mode 100644 src/popup/app/vault/vaultAttachmentsController.js create mode 100644 src/popup/app/vault/views/vaultAttachments.html diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index eb7ef5166e..81885cbd28 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -718,5 +718,29 @@ "attachments": { "message": "Attachments", "description": "Attachments" + }, + "deleteAttachment": { + "message": "Delete attachment", + "description": "Delete attachment" + }, + "deleteAttachmentConfirmation": { + "message": "Are you sure you want to delete this attachment?", + "description": "Are you sure you want to delete this attachment?" + }, + "deletedAttachment": { + "message": "Deleted attachment", + "description": "Deleted attachment" + }, + "newAttachment": { + "message": "Add New Attachment", + "description": "Add New Attachment" + }, + "noAttachments": { + "message": "No attachments.", + "description": "No attachments." + }, + "file": { + "message": "File", + "description": "File" } } diff --git a/src/popup/app/config.js b/src/popup/app/config.js index e78e287195..0c0ae0d4b9 100644 --- a/src/popup/app/config.js +++ b/src/popup/app/config.js @@ -140,6 +140,13 @@ data: { authorize: true }, params: { animation: null, fromView: true, login: null, from: 'vault' } }) + .state('attachments', { + url: '/attachments?id', + templateUrl: 'app/vault/views/vaultAttachments.html', + controller: 'vaultAttachmentsController', + data: { authorize: true }, + params: { animation: null, fromView: true, login: null, from: 'vault' } + }) .state('passwordGenerator', { url: '/password-generator', diff --git a/src/popup/app/vault/vaultAttachmentsController.js b/src/popup/app/vault/vaultAttachmentsController.js new file mode 100644 index 0000000000..f8dfa651b5 --- /dev/null +++ b/src/popup/app/vault/vaultAttachmentsController.js @@ -0,0 +1,57 @@ +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' + }); + } + }; + }); diff --git a/src/popup/app/vault/vaultEditLoginController.js b/src/popup/app/vault/vaultEditLoginController.js index ce6872e1f7..5184b3d76a 100644 --- a/src/popup/app/vault/vaultEditLoginController.js +++ b/src/popup/app/vault/vaultEditLoginController.js @@ -68,6 +68,16 @@ angular }); }; + $scope.attachments = function () { + $state.go('attachments', { + id: loginId, + login: $scope.login, + animation: 'in-slide-up', + from: from, + fromView: fromView + }); + }; + $scope.close = function () { if (fromView) { $state.go('viewLogin', { diff --git a/src/popup/app/vault/views/vaultAttachments.html b/src/popup/app/vault/views/vaultAttachments.html new file mode 100644 index 0000000000..8358080eba --- /dev/null +++ b/src/popup/app/vault/views/vaultAttachments.html @@ -0,0 +1,40 @@ +
+ + +
{{i18n.attachments}}
+
+
+
+
+
+
+ {{i18n.noAttachments}} +
+
+ {{attachment.fileName}} + + + + + {{attachment.sizeName}} +
+
+
+
+
+ {{i18n.newAttachment}} +
+
+
+ + +
+
+
+
+
diff --git a/src/popup/app/vault/views/vaultEditLogin.html b/src/popup/app/vault/views/vaultEditLogin.html index eae8886006..29339e837c 100644 --- a/src/popup/app/vault/views/vaultEditLogin.html +++ b/src/popup/app/vault/views/vaultEditLogin.html @@ -57,6 +57,10 @@ + + {{i18n.attachments}} + +
diff --git a/src/popup/index.html b/src/popup/index.html index c26afee0ef..6669c5c85d 100644 --- a/src/popup/index.html +++ b/src/popup/index.html @@ -72,6 +72,7 @@ + diff --git a/src/popup/less/components.less b/src/popup/less/components.less index 7ef13d91eb..f797bc6cec 100644 --- a/src/popup/less/components.less +++ b/src/popup/less/components.less @@ -467,6 +467,14 @@ } } +.no-padding { + padding: 0 !important; +} + +.no-margin { + margin: 0 !important; +} + .btn { border-radius: 0; -webkit-border-radius: 0;