diff --git a/src/popup/app/config.js b/src/popup/app/config.js index ad28d712..48bad0ce 100644 --- a/src/popup/app/config.js +++ b/src/popup/app/config.js @@ -89,14 +89,14 @@ templateUrl: 'app/vault/views/vaultAddSite.html', controller: 'vaultAddSiteController', data: { authorize: true }, - params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, uri: null, site: null } + params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, uri: null, site: null, fromCurrent: false } }) .state('editSite', { url: '/edit-site?siteId', templateUrl: 'app/vault/views/vaultEditSite.html', controller: 'vaultEditSiteController', data: { authorize: true }, - params: { animation: null, fromView: true, returnScrollY: 0, returnSearchText: null } + params: { animation: null, fromView: true, returnScrollY: 0, returnSearchText: null, site: null } }) .state('passwordGenerator', { diff --git a/src/popup/app/tools/toolsPasswordGeneratorController.js b/src/popup/app/tools/toolsPasswordGeneratorController.js index ee050735..20e5df47 100644 --- a/src/popup/app/tools/toolsPasswordGeneratorController.js +++ b/src/popup/app/tools/toolsPasswordGeneratorController.js @@ -5,6 +5,8 @@ var addState = $stateParams.addState, editState = $stateParams.editState; + $scope.showSelect = $stateParams.addState || $stateParams.editState; + popupUtils.initListSectionItemListeners(); $scope.password = '-'; @@ -61,16 +63,38 @@ }; $scope.close = function () { + dismiss(); + }; + + $scope.select = function () { + if (addState) { + addState.site.password = $scope.password; + } + else if (editState) { + editState.site.password = $scope.password; + } + + dismiss(); + }; + + function dismiss() { if (addState) { $state.go('addSite', { animation: 'out-slide-down', - site: addState + fromCurrent: addState.fromCurrent, + site: addState.site, + returnScrollY: addState.returnScrollY, + returnSearchText: addState.returnSearchText }); } else if (editState) { $state.go('editSite', { animation: 'out-slide-down', - siteId: editState + site: editState.site, + fromView: editState.fromView, + siteId: editState.siteId, + returnScrollY: editState.returnScrollY, + returnSearchText: editState.returnSearchText }); } else { @@ -78,5 +102,5 @@ animation: 'out-slide-down' }); } - }; + } }); diff --git a/src/popup/app/tools/views/toolsPasswordGenerator.html b/src/popup/app/tools/views/toolsPasswordGenerator.html index edb8e142..925393e8 100644 --- a/src/popup/app/tools/views/toolsPasswordGenerator.html +++ b/src/popup/app/tools/views/toolsPasswordGenerator.html @@ -3,7 +3,7 @@ Close
- Select + Select
Generate Password
diff --git a/src/popup/app/vault/vaultAddSiteController.js b/src/popup/app/vault/vaultAddSiteController.js index 524a1ba5..c8c83ec5 100644 --- a/src/popup/app/vault/vaultAddSiteController.js +++ b/src/popup/app/vault/vaultAddSiteController.js @@ -4,7 +4,7 @@ .controller('vaultAddSiteController', function ($scope, $state, $stateParams, siteService, folderService, cryptoService, $q, toastr) { var returnScrollY = $stateParams.returnScrollY; var returnSearchText = $stateParams.returnSearchText; - var fromCurrent = $stateParams.uri !== null; + var fromCurrent = $stateParams.fromCurrent || $stateParams.uri !== null; $scope.site = { folderId: null, @@ -12,7 +12,11 @@ uri: $stateParams.uri }; - if ($scope.site.name && $scope.site.uri) { + if ($stateParams.site) { + angular.extend($scope.site, $stateParams.site); + } + + if (!$stateParams.site && $scope.site.name && $scope.site.uri) { $('#username').focus(); } else { @@ -52,4 +56,16 @@ }); } }; + + $scope.generatePassword = function () { + $state.go('passwordGenerator', { + animation: 'in-slide-up', + addState: { + fromCurrent: fromCurrent, + site: $scope.site, + returnScrollY: returnScrollY, + returnSearchText: returnSearchText + } + }); + }; }); diff --git a/src/popup/app/vault/vaultEditSiteController.js b/src/popup/app/vault/vaultEditSiteController.js index 2009b7c7..1ef0466e 100644 --- a/src/popup/app/vault/vaultEditSiteController.js +++ b/src/popup/app/vault/vaultEditSiteController.js @@ -4,16 +4,23 @@ angular .controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, folderService, cryptoService, $q, toastr) { var returnScrollY = $stateParams.returnScrollY; var returnSearchText = $stateParams.returnSearchText; + var siteId = $stateParams.siteId; + var fromView = $stateParams.fromView; $scope.site = { folderId: null }; - siteService.get($stateParams.siteId, function (site) { - $q.when(site.decrypt()).then(function (model) { - $scope.site = model; + if ($stateParams.site) { + angular.extend($scope.site, $stateParams.site); + } + else { + siteService.get(siteId, function (site) { + $q.when(site.decrypt()).then(function (model) { + $scope.site = model; + }); }); - }); + } $q.when(folderService.getAllDecrypted()).then(function (folders) { $scope.folders = folders.concat([{ @@ -36,9 +43,9 @@ angular }; $scope.close = function () { - if ($stateParams.fromView) { + if (fromView) { $state.go('viewSite', { - siteId: $stateParams.siteId, + siteId: siteId, animation: 'out-slide-down', returnScrollY: returnScrollY || 0, returnSearchText: returnSearchText @@ -52,4 +59,21 @@ angular }); } }; + + $scope.generatePassword = function () { + if ($scope.site.password) { + // TODO: confirmation + } + + $state.go('passwordGenerator', { + animation: 'in-slide-up', + editState: { + fromView: fromView, + siteId: siteId, + site: $scope.site, + returnScrollY: returnScrollY, + returnSearchText: returnSearchText + } + }); + }; }); diff --git a/src/popup/app/vault/views/vaultAddSite.html b/src/popup/app/vault/views/vaultAddSite.html index 443b2fce..39301246 100644 --- a/src/popup/app/vault/views/vaultAddSite.html +++ b/src/popup/app/vault/views/vaultAddSite.html @@ -32,9 +32,9 @@ - + Generate Password - + diff --git a/src/popup/app/vault/views/vaultEditSite.html b/src/popup/app/vault/views/vaultEditSite.html index f12ae876..e1fe6bac 100644 --- a/src/popup/app/vault/views/vaultEditSite.html +++ b/src/popup/app/vault/views/vaultEditSite.html @@ -32,9 +32,9 @@ - + Generate Password - + diff --git a/src/popup/less/components.less b/src/popup/less/components.less index fedb637d..5d0d6f76 100644 --- a/src/popup/less/components.less +++ b/src/popup/less/components.less @@ -284,6 +284,12 @@ } } + .fa-chevron-right { + float: right; + margin-top: 3px; + color: @gray-light; + } + &.condensed { padding: 3px 10px; @@ -359,4 +365,5 @@ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + font-family: @font-family-monospace; }