diff --git a/src/popup/app/vault/vaultAddSiteController.js b/src/popup/app/vault/vaultAddSiteController.js index 0fbb622000..78bb46fc5b 100644 --- a/src/popup/app/vault/vaultAddSiteController.js +++ b/src/popup/app/vault/vaultAddSiteController.js @@ -1,12 +1,12 @@ angular .module('bit.vault') - .controller('vaultAddSiteController', function ($scope, siteService, cipherService) { + .controller('vaultAddSiteController', function ($scope, $state, siteService, cipherService) { $scope.site = { folderId: null }; - $scope.createSite = function (model) { + $scope.save = function (model) { cipherService.encryptSite(model, function (siteModel) { var site = new Site(siteModel, true); siteService.saveWithServer(site, function () { @@ -16,6 +16,6 @@ }; $scope.close = function () { - $scope.parentScope.closeAddSite(); + $state.go('tabs.vault', { animation: 'out-slide-down' }); }; }); diff --git a/src/popup/app/vault/vaultController.js b/src/popup/app/vault/vaultController.js index 0d322f056c..6b8e90619f 100644 --- a/src/popup/app/vault/vaultController.js +++ b/src/popup/app/vault/vaultController.js @@ -1,14 +1,26 @@ angular .module('bit.vault') - .controller('vaultController', function ($scope, siteService, folderService, $q, cipherService) { - $scope.sites = []; - $scope.folders = []; - $scope.focusedSiteId = null; + .controller('vaultController', function ($scope, $rootScope, siteService, folderService, $q, cipherService) { + var delayLoad = true; + if (!$rootScope.vaultSites) { + $rootScope.vaultSites =[]; + delayLoad = false; + } + if (!$rootScope.vaultFolders) { + $rootScope.vaultFolders = []; + delayLoad = false; + } - loadVault(); + if (delayLoad) { + setTimeout(loadVault, 1000); + } + else { + loadVault(); + } function loadVault() { + var promises = []; var decSites = []; var decFolders = [{ id: null, @@ -17,8 +29,6 @@ folderService.getAll(function (folders) { siteService.getAll(function (sites) { - var promises = []; - for (var i = 1; i < folders.length; i++) { decFolders.push({ id: folders[i].id @@ -52,8 +62,8 @@ } $q.all(promises).then(function () { - $scope.sites = decSites; - $scope.folders = decFolders; + $rootScope.vaultSites = decSites; + $rootScope.vaultFolders = decFolders; }); }); }); @@ -66,46 +76,4 @@ return item.name.toLowerCase(); }; - - /* - $scope.editSite = function (site) { - $scope.focusedSiteId = site.id; - $ionicModal.fromTemplateUrl('app/vault/views/vaultEditSite.html', { - scope: $scope, - animation: 'slide-in-up' - }).then(function (modal) { - $scope.editSiteModal = modal; - modal.show(); - }); - }; - - $scope.addSite = function () { - $ionicModal.fromTemplateUrl('app/vault/views/vaultAddSite.html', { - scope: $scope, - animation: 'slide-in-up' - }).then(function (modal) { - $scope.addSiteModal = modal; - modal.show(); - }); - }; - */ - - $scope.closeAddSite = function () { - $scope.addSiteModal.hide(); - }; - - $scope.closeViewSite = function () { - $scope.viewSiteModal.hide(); - $scope.focusedSiteId = null; - }; - - $scope.closeEditSite = function () { - $scope.editSiteModal.hide(); - $scope.focusedSiteId = null; - }; - - $scope.$on('closeViewSite.hidden', function () { - console.log('modal hidden'); - loadVault(); - }); }); diff --git a/src/popup/app/vault/views/vault.html b/src/popup/app/vault/views/vault.html index 2a7b657acf..478c897e97 100644 --- a/src/popup/app/vault/views/vault.html +++ b/src/popup/app/vault/views/vault.html @@ -4,15 +4,15 @@