from state passed around

This commit is contained in:
Kyle Spearrin 2016-12-07 00:07:01 -05:00
parent 4476eb7389
commit d16b9920ec
8 changed files with 34 additions and 19 deletions

View File

@ -93,14 +93,14 @@
templateUrl: 'app/vault/views/vaultViewFolder.html', templateUrl: 'app/vault/views/vaultViewFolder.html',
controller: 'vaultViewFolderController', controller: 'vaultViewFolderController',
data: { authorize: true }, data: { authorize: true },
params: { animation: null, returnScrollY: 0, returnSearchText: null, fromCurrent: false } params: { animation: null, returnScrollY: 0, returnSearchText: null, from: 'vault' }
}) })
.state('viewSite', { .state('viewSite', {
url: '/view-site?siteId', url: '/view-site?siteId',
templateUrl: 'app/vault/views/vaultViewSite.html', templateUrl: 'app/vault/views/vaultViewSite.html',
controller: 'vaultViewSiteController', controller: 'vaultViewSiteController',
data: { authorize: true }, data: { authorize: true },
params: { animation: null, returnScrollY: 0, returnSearchText: null, fromCurrent: false } params: { animation: null, returnScrollY: 0, returnSearchText: null, from: 'vault' }
}) })
.state('addSite', { .state('addSite', {
url: '/add-site', url: '/add-site',
@ -109,7 +109,7 @@
data: { authorize: true }, data: { authorize: true },
params: { params: {
animation: null, returnScrollY: 0, returnSearchText: null, name: null, animation: null, returnScrollY: 0, returnSearchText: null, name: null,
uri: null, site: null, fromCurrent: false uri: null, site: null, from: 'vault'
} }
}) })
.state('editSite', { .state('editSite', {
@ -119,7 +119,7 @@
data: { authorize: true }, data: { authorize: true },
params: { params: {
animation: null, fromView: true, returnScrollY: 0, animation: null, fromView: true, returnScrollY: 0,
returnSearchText: null, site: null, fromCurrent: false returnSearchText: null, site: null, from: 'vault'
} }
}) })

View File

@ -104,7 +104,7 @@ angular
$state.go('viewSite', { $state.go('viewSite', {
siteId: site.id, siteId: site.id,
animation: 'in-slide-up', animation: 'in-slide-up',
fromCurrent: true from: 'current'
}); });
}; };

View File

@ -93,7 +93,7 @@
if (addState) { if (addState) {
$state.go('addSite', { $state.go('addSite', {
animation: 'out-slide-down', animation: 'out-slide-down',
fromCurrent: addState.fromCurrent, from: addState.from,
site: addState.site, site: addState.site,
returnScrollY: addState.returnScrollY, returnScrollY: addState.returnScrollY,
returnSearchText: addState.returnSearchText returnSearchText: addState.returnSearchText

View File

@ -6,7 +6,7 @@
$scope.i18n = i18nService; $scope.i18n = i18nService;
var returnScrollY = $stateParams.returnScrollY; var returnScrollY = $stateParams.returnScrollY;
var returnSearchText = $stateParams.returnSearchText; var returnSearchText = $stateParams.returnSearchText;
var fromCurrent = $stateParams.fromCurrent || $stateParams.uri !== null; var fromCurrent = $stateParams.from;
$scope.site = { $scope.site = {
folderId: null, folderId: null,
@ -48,12 +48,19 @@
}; };
$scope.close = function () { $scope.close = function () {
if (fromCurrent) { if (from === 'current') {
$state.go('tabs.current', { $state.go('tabs.current', {
animation: 'out-slide-down' 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', { $state.go('tabs.vault', {
animation: 'out-slide-down', animation: 'out-slide-down',
scrollY: returnScrollY || 0, scrollY: returnScrollY || 0,
@ -67,7 +74,7 @@
$state.go('passwordGenerator', { $state.go('passwordGenerator', {
animation: 'in-slide-up', animation: 'in-slide-up',
addState: { addState: {
fromCurrent: fromCurrent, from: from,
site: $scope.site, site: $scope.site,
returnScrollY: returnScrollY, returnScrollY: returnScrollY,
returnSearchText: returnSearchText returnSearchText: returnSearchText

View File

@ -8,7 +8,7 @@ angular
var returnSearchText = $stateParams.returnSearchText; var returnSearchText = $stateParams.returnSearchText;
var siteId = $stateParams.siteId; var siteId = $stateParams.siteId;
var fromView = $stateParams.fromView; var fromView = $stateParams.fromView;
var fromCurrent = $stateParams.fromCurrent; var from = $stateParams.from;
$scope.site = { $scope.site = {
folderId: null folderId: null
@ -75,7 +75,7 @@ angular
animation: 'out-slide-down', animation: 'out-slide-down',
returnScrollY: returnScrollY || 0, returnScrollY: returnScrollY || 0,
returnSearchText: returnSearchText, returnSearchText: returnSearchText,
fromCurrent: fromCurrent from: from
}); });
} }
else { else {

View File

@ -86,7 +86,8 @@
$state.go('addSite', { $state.go('addSite', {
animation: 'in-slide-up', animation: 'in-slide-up',
returnScrollY: getScrollY(), returnScrollY: getScrollY(),
returnSearchText: $scope.searchText returnSearchText: $scope.searchText,
from: 'folder'
}); });
}; };
@ -95,7 +96,8 @@
siteId: site.id, siteId: site.id,
animation: 'in-slide-up', animation: 'in-slide-up',
returnScrollY: getScrollY(), returnScrollY: getScrollY(),
returnSearchText: $scope.searchText returnSearchText: $scope.searchText,
from: 'folder'
}); });
}; };

View File

@ -6,7 +6,7 @@ angular
$scope.i18n = i18nService; $scope.i18n = i18nService;
var returnScrollY = $stateParams.returnScrollY; var returnScrollY = $stateParams.returnScrollY;
var returnSearchText = $stateParams.returnSearchText; var returnSearchText = $stateParams.returnSearchText;
var fromCurrent = $stateParams.fromCurrent; var from = $stateParams.from;
$scope.site = null; $scope.site = null;
siteService.get($stateParams.siteId, function (site) { siteService.get($stateParams.siteId, function (site) {
@ -49,16 +49,23 @@ angular
fromView: true, fromView: true,
returnScrollY: returnScrollY || 0, returnScrollY: returnScrollY || 0,
returnSearchText: returnSearchText, returnSearchText: returnSearchText,
fromCurrent: fromCurrent from: from
}); });
}; };
$scope.close = function () { $scope.close = function () {
if (fromCurrent) { if (from === 'current') {
$state.go('tabs.current', { $state.go('tabs.current', {
animation: 'out-slide-down' animation: 'out-slide-down'
}); });
} }
else if (from === 'folder') {
$state.go('viewFolder', {
animation: 'out-slide-down',
scrollY: returnScrollY || 0,
searchText: returnSearchText
});
}
else { else {
$state.go('tabs.vault', { $state.go('tabs.vault', {
animation: 'out-slide-down', animation: 'out-slide-down',

View File

@ -19,8 +19,7 @@
</div> </div>
<a href="javascript:void(0)" ng-click="viewSite(site)" <a href="javascript:void(0)" ng-click="viewSite(site)"
class="list-section-item condensed" title="{{i18n.edit}} {{site.name}}" class="list-section-item condensed" title="{{i18n.edit}} {{site.name}}"
ng-repeat="site in vaultSites | filter: { folderId: folder.id } ng-repeat="site in vaultSites | filter: searchSites() | orderBy: ['name', 'username']">
| filter: searchSites() | orderBy: ['name', 'username']">
<span class="btn-list" ng-click="$event.stopPropagation()" title="{{i18n.copyPassword}}" ngclipboard <span class="btn-list" ng-click="$event.stopPropagation()" title="{{i18n.copyPassword}}" ngclipboard
ngclipboard-error="clipboardError(e)" ngclipboard-success="clipboardSuccess(e, i18n.password)" ngclipboard-error="clipboardError(e)" ngclipboard-success="clipboardSuccess(e, i18n.password)"
data-clipboard-text="{{site.password}}" ng-class="{'disabled': !site.password}"> data-clipboard-text="{{site.password}}" ng-class="{'disabled': !site.password}">