From d16b9920ece159cd37b1ec15518c258d9b194590 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 7 Dec 2016 00:07:01 -0500 Subject: [PATCH] from state passed around --- src/popup/app/config.js | 8 ++++---- src/popup/app/current/currentController.js | 2 +- .../app/tools/toolsPasswordGeneratorController.js | 2 +- src/popup/app/vault/vaultAddSiteController.js | 15 +++++++++++---- src/popup/app/vault/vaultEditSiteController.js | 4 ++-- src/popup/app/vault/vaultViewFolderController.js | 6 ++++-- src/popup/app/vault/vaultViewSiteController.js | 13 ++++++++++--- src/popup/app/vault/views/vaultViewFolder.html | 3 +-- 8 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/popup/app/config.js b/src/popup/app/config.js index 61446489b1..d6d438ef45 100644 --- a/src/popup/app/config.js +++ b/src/popup/app/config.js @@ -93,14 +93,14 @@ templateUrl: 'app/vault/views/vaultViewFolder.html', controller: 'vaultViewFolderController', data: { authorize: true }, - params: { animation: null, returnScrollY: 0, returnSearchText: null, fromCurrent: false } + params: { animation: null, returnScrollY: 0, returnSearchText: null, from: 'vault' } }) .state('viewSite', { url: '/view-site?siteId', templateUrl: 'app/vault/views/vaultViewSite.html', controller: 'vaultViewSiteController', data: { authorize: true }, - params: { animation: null, returnScrollY: 0, returnSearchText: null, fromCurrent: false } + params: { animation: null, returnScrollY: 0, returnSearchText: null, from: 'vault' } }) .state('addSite', { url: '/add-site', @@ -109,7 +109,7 @@ data: { authorize: true }, params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, - uri: null, site: null, fromCurrent: false + uri: null, site: null, from: 'vault' } }) .state('editSite', { @@ -119,7 +119,7 @@ data: { authorize: true }, params: { animation: null, fromView: true, returnScrollY: 0, - returnSearchText: null, site: null, fromCurrent: false + returnSearchText: null, site: null, from: 'vault' } }) diff --git a/src/popup/app/current/currentController.js b/src/popup/app/current/currentController.js index c7e974a00d..33fa90ecd3 100644 --- a/src/popup/app/current/currentController.js +++ b/src/popup/app/current/currentController.js @@ -104,7 +104,7 @@ angular $state.go('viewSite', { siteId: site.id, animation: 'in-slide-up', - fromCurrent: true + from: 'current' }); }; diff --git a/src/popup/app/tools/toolsPasswordGeneratorController.js b/src/popup/app/tools/toolsPasswordGeneratorController.js index 1f3abb374d..1f0d988738 100644 --- a/src/popup/app/tools/toolsPasswordGeneratorController.js +++ b/src/popup/app/tools/toolsPasswordGeneratorController.js @@ -93,7 +93,7 @@ if (addState) { $state.go('addSite', { animation: 'out-slide-down', - fromCurrent: addState.fromCurrent, + from: addState.from, site: addState.site, returnScrollY: addState.returnScrollY, returnSearchText: addState.returnSearchText diff --git a/src/popup/app/vault/vaultAddSiteController.js b/src/popup/app/vault/vaultAddSiteController.js index f49ecb3f4b..0c2f1f9711 100644 --- a/src/popup/app/vault/vaultAddSiteController.js +++ b/src/popup/app/vault/vaultAddSiteController.js @@ -6,7 +6,7 @@ $scope.i18n = i18nService; var returnScrollY = $stateParams.returnScrollY; var returnSearchText = $stateParams.returnSearchText; - var fromCurrent = $stateParams.fromCurrent || $stateParams.uri !== null; + var fromCurrent = $stateParams.from; $scope.site = { folderId: null, @@ -48,12 +48,19 @@ }; $scope.close = function () { - if (fromCurrent) { + if (from === 'current') { $state.go('tabs.current', { animation: 'out-slide-down' }); } - else { + else if (from === 'folder') { + $state.go('viewFolder', { + animation: 'out-slide-down', + scrollY: returnScrollY || 0, + searchText: returnSearchText + }); + } + else if(from === 'vault') { $state.go('tabs.vault', { animation: 'out-slide-down', scrollY: returnScrollY || 0, @@ -67,7 +74,7 @@ $state.go('passwordGenerator', { animation: 'in-slide-up', addState: { - fromCurrent: fromCurrent, + from: from, site: $scope.site, returnScrollY: returnScrollY, returnSearchText: returnSearchText diff --git a/src/popup/app/vault/vaultEditSiteController.js b/src/popup/app/vault/vaultEditSiteController.js index a62b82ed45..8fd34cf23c 100644 --- a/src/popup/app/vault/vaultEditSiteController.js +++ b/src/popup/app/vault/vaultEditSiteController.js @@ -8,7 +8,7 @@ angular var returnSearchText = $stateParams.returnSearchText; var siteId = $stateParams.siteId; var fromView = $stateParams.fromView; - var fromCurrent = $stateParams.fromCurrent; + var from = $stateParams.from; $scope.site = { folderId: null @@ -75,7 +75,7 @@ angular animation: 'out-slide-down', returnScrollY: returnScrollY || 0, returnSearchText: returnSearchText, - fromCurrent: fromCurrent + from: from }); } else { diff --git a/src/popup/app/vault/vaultViewFolderController.js b/src/popup/app/vault/vaultViewFolderController.js index 0af3df22c7..fae250303c 100644 --- a/src/popup/app/vault/vaultViewFolderController.js +++ b/src/popup/app/vault/vaultViewFolderController.js @@ -86,7 +86,8 @@ $state.go('addSite', { animation: 'in-slide-up', returnScrollY: getScrollY(), - returnSearchText: $scope.searchText + returnSearchText: $scope.searchText, + from: 'folder' }); }; @@ -95,7 +96,8 @@ siteId: site.id, animation: 'in-slide-up', returnScrollY: getScrollY(), - returnSearchText: $scope.searchText + returnSearchText: $scope.searchText, + from: 'folder' }); }; diff --git a/src/popup/app/vault/vaultViewSiteController.js b/src/popup/app/vault/vaultViewSiteController.js index 9f41a81051..6e0c7eb12c 100644 --- a/src/popup/app/vault/vaultViewSiteController.js +++ b/src/popup/app/vault/vaultViewSiteController.js @@ -6,7 +6,7 @@ angular $scope.i18n = i18nService; var returnScrollY = $stateParams.returnScrollY; var returnSearchText = $stateParams.returnSearchText; - var fromCurrent = $stateParams.fromCurrent; + var from = $stateParams.from; $scope.site = null; siteService.get($stateParams.siteId, function (site) { @@ -49,16 +49,23 @@ angular fromView: true, returnScrollY: returnScrollY || 0, returnSearchText: returnSearchText, - fromCurrent: fromCurrent + from: from }); }; $scope.close = function () { - if (fromCurrent) { + if (from === 'current') { $state.go('tabs.current', { animation: 'out-slide-down' }); } + else if (from === 'folder') { + $state.go('viewFolder', { + animation: 'out-slide-down', + scrollY: returnScrollY || 0, + searchText: returnSearchText + }); + } else { $state.go('tabs.vault', { animation: 'out-slide-down', diff --git a/src/popup/app/vault/views/vaultViewFolder.html b/src/popup/app/vault/views/vaultViewFolder.html index aa7d21d64b..8e3a290267 100644 --- a/src/popup/app/vault/views/vaultViewFolder.html +++ b/src/popup/app/vault/views/vaultViewFolder.html @@ -19,8 +19,7 @@ + ng-repeat="site in vaultSites | filter: searchSites() | orderBy: ['name', 'username']">