From 1fb220c25ea367977e28b96d4423383d559ae207 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 5 Jul 2017 16:27:28 -0400 Subject: [PATCH] attachment errors --- src/app/directives/apiFormDirective.js | 16 ++++++++++------ src/app/vault/vaultAttachmentsController.js | 3 ++- src/app/vault/vaultController.js | 7 ++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/app/directives/apiFormDirective.js b/src/app/directives/apiFormDirective.js index ea2790c0c6..a2049c2a1f 100644 --- a/src/app/directives/apiFormDirective.js +++ b/src/app/directives/apiFormDirective.js @@ -1,7 +1,7 @@ angular .module('bit.directives') - .directive('apiForm', function ($rootScope, validationService) { + .directive('apiForm', function ($rootScope, validationService, $timeout) { return { require: 'form', restrict: 'A', @@ -25,12 +25,16 @@ angular form.$loading = true; promise.then(function success(response) { - form.$loading = false; + $timeout(function () { + form.$loading = false; + }); }, function failure(reason) { - form.$loading = false; - validationService.addErrors(form, reason); - scope.$broadcast('show-errors-check-validity'); - $('html, body').animate({ scrollTop: 0 }, 200); + $timeout(function () { + form.$loading = false; + validationService.addErrors(form, reason); + scope.$broadcast('show-errors-check-validity'); + $('html, body').animate({ scrollTop: 0 }, 200); + }); }); } }); \ No newline at end of file diff --git a/src/app/vault/vaultAttachmentsController.js b/src/app/vault/vaultAttachmentsController.js index 32cb164402..77879b155e 100644 --- a/src/app/vault/vaultAttachmentsController.js +++ b/src/app/vault/vaultAttachmentsController.js @@ -2,7 +2,7 @@ .module('bit.vault') .controller('vaultAttachmentsController', function ($scope, apiService, $uibModalInstance, cryptoService, cipherService, - loginId, $analytics, validationService) { + loginId, $analytics, validationService, toastr) { $analytics.eventTrack('vaultAttachmentsController', { category: 'Modal' }); $scope.login = {}; $scope.readOnly = false; @@ -45,6 +45,7 @@ return apiService.ciphers.postAttachment({ id: loginId }, fd).$promise; }).then(function (response) { $analytics.eventTrack('Added Attachment'); + toastr.success('The attachment has been added.'); $uibModalInstance.close({ action: 'attach', data: $scope.login diff --git a/src/app/vault/vaultController.js b/src/app/vault/vaultController.js index 9944ca8004..3e03652105 100644 --- a/src/app/vault/vaultController.js +++ b/src/app/vault/vaultController.js @@ -200,6 +200,11 @@ }; $scope.attachments = function (login) { + if (!cryptoService.getEncKey()) { + toastr.error('You cannot use this feature until you update your encryption key.', 'Feature Unavailable'); + return; + } + var addModel = $uibModal.open({ animation: true, templateUrl: 'app/vault/views/vaultAttachments.html', @@ -210,7 +215,7 @@ }); addModel.result.then(function (data) { - + }); };