From 1069b51266d5b88bb088369ed4229fd31e4fda87 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 10 Sep 2016 23:06:34 -0400 Subject: [PATCH] load folder dropdowns for site add/edit forms --- src/popup/app/vault/vaultAddSiteController.js | 26 ++++++++++++++++++- .../app/vault/vaultEditSiteController.js | 26 ++++++++++++++++++- src/popup/app/vault/views/vaultAddSite.html | 6 ++--- src/popup/app/vault/views/vaultEditSite.html | 6 ++--- 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/popup/app/vault/vaultAddSiteController.js b/src/popup/app/vault/vaultAddSiteController.js index b1a98219c3..6d52833c38 100644 --- a/src/popup/app/vault/vaultAddSiteController.js +++ b/src/popup/app/vault/vaultAddSiteController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultAddSiteController', function ($scope, $state, siteService, cipherService, $q) { + .controller('vaultAddSiteController', function ($scope, $state, siteService, folderService, cipherService, $q) { $scope.site = { folderId: null }; @@ -9,6 +9,30 @@ $('#name').focus(); popupUtils.initListSectionItemListeners(); + var promises = []; + var decFolders = [{ + id: null, + name: '(none)' + }]; + + folderService.getAll(function (folders) { + for (var i = 1; i < folders.length; i++) { + decFolders.push({ + id: folders[i].id + }); + + var folderNamePromise = cipherService.decrypt(folders[i].name, i); + promises.push(folderNamePromise); + folderNamePromise.then(function (obj) { + decFolders[obj.index].name = obj.val; + }); + } + + $q.all(promises).then(function () { + $scope.folders = decFolders; + }); + }); + $scope.savePromise = null; $scope.save = function (model) { $scope.savePromise = cipherService.encryptSite(model).then(function (siteModel) { diff --git a/src/popup/app/vault/vaultEditSiteController.js b/src/popup/app/vault/vaultEditSiteController.js index 7cc7d2ff64..30d9d157ac 100644 --- a/src/popup/app/vault/vaultEditSiteController.js +++ b/src/popup/app/vault/vaultEditSiteController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, cipherService, $q) { + .controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, folderService, cipherService, $q) { $scope.site = { folderId: null }; @@ -12,6 +12,30 @@ }); }); + var promises = []; + var decFolders = [{ + id: null, + name: '(none)' + }]; + + folderService.getAll(function (folders) { + for (var i = 1; i < folders.length; i++) { + decFolders.push({ + id: folders[i].id + }); + + var folderNamePromise = cipherService.decrypt(folders[i].name, i); + promises.push(folderNamePromise); + folderNamePromise.then(function (obj) { + decFolders[obj.index].name = obj.val; + }); + } + + $q.all(promises).then(function () { + $scope.folders = decFolders; + }); + }); + popupUtils.initListSectionItemListeners(); $scope.savePromise = null; diff --git a/src/popup/app/vault/views/vaultAddSite.html b/src/popup/app/vault/views/vaultAddSite.html index 438a1fb9c8..4382a2c637 100644 --- a/src/popup/app/vault/views/vaultAddSite.html +++ b/src/popup/app/vault/views/vaultAddSite.html @@ -42,10 +42,8 @@
- +
diff --git a/src/popup/app/vault/views/vaultEditSite.html b/src/popup/app/vault/views/vaultEditSite.html index 7048becb91..ff3350c331 100644 --- a/src/popup/app/vault/views/vaultEditSite.html +++ b/src/popup/app/vault/views/vaultEditSite.html @@ -42,10 +42,8 @@
- +