1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-08 09:43:42 +01:00

filter favorite ciphers from controller

This commit is contained in:
Kyle Spearrin 2017-12-19 21:39:44 -05:00
parent c1189e3318
commit f77e3b09ea
2 changed files with 9 additions and 4 deletions

View File

@ -2,7 +2,7 @@ angular
.module('bit.vault') .module('bit.vault')
.controller('vaultController', function ($scope, $rootScope, cipherService, folderService, $q, $state, $stateParams, toastr, .controller('vaultController', function ($scope, $rootScope, cipherService, folderService, $q, $state, $stateParams, toastr,
syncService, utilsService, $analytics, i18nService, stateService, $timeout, $window, collectionService) { syncService, utilsService, $analytics, i18nService, stateService, $timeout, $window, collectionService, $filter) {
var stateKey = 'vault', var stateKey = 'vault',
state = stateService.getState(stateKey) || {}; state = stateService.getState(stateKey) || {};
stateService.removeState('viewGrouping'); stateService.removeState('viewGrouping');
@ -25,8 +25,13 @@ angular
$scope.loaded = true; $scope.loaded = true;
if (!$rootScope.vaultCiphers) { if (!$rootScope.vaultCiphers) {
$rootScope.vaultCiphers = []; $rootScope.vaultCiphers = [];
$scope.favoriteCiphers = [];
delayLoad = false; delayLoad = false;
} }
else {
$scope.favoriteCiphers = $filter('filter')($rootScope.vaultCiphers, { favorite: true });
}
if (!$rootScope.vaultFolders) { if (!$rootScope.vaultFolders) {
$rootScope.vaultFolders = []; $rootScope.vaultFolders = [];
delayLoad = false; delayLoad = false;
@ -68,6 +73,7 @@ angular
$rootScope.vaultFolders = decFolders; $rootScope.vaultFolders = decFolders;
$rootScope.vaultCollections = decCollections; $rootScope.vaultCollections = decCollections;
$rootScope.vaultCiphers = decCiphers; $rootScope.vaultCiphers = decCiphers;
$scope.favoriteCiphers = $filter('filter')($rootScope.vaultCiphers, { favorite: true });
if ($scope.showGroupingCounts) { if ($scope.showGroupingCounts) {
var folderCounts = { 'none': 0 }; var folderCounts = { 'none': 0 };

View File

@ -12,7 +12,7 @@
<!-- Grouping List --> <!-- Grouping List -->
<div ng-if="vaultCiphers.length && vaultFolders.length && (!searchText || searchText.length < 2)"> <div ng-if="vaultCiphers.length && vaultFolders.length && (!searchText || searchText.length < 2)">
<div class="list"> <div class="list">
<div class="list-section" ng-show="favoriteCiphers.length"> <div class="list-section" ng-if="favoriteCiphers.length">
<div class="list-section-header"> <div class="list-section-header">
{{::i18n.favorites}} {{::i18n.favorites}}
<span>{{favoriteCiphers.length}}</span> <span>{{favoriteCiphers.length}}</span>
@ -20,8 +20,7 @@
<div class="list-section-items"> <div class="list-section-items">
<a href="#" stop-click ng-click="viewCipher(cipher)" class="list-section-item condensed" <a href="#" stop-click ng-click="viewCipher(cipher)" class="list-section-item condensed"
title="{{::i18n.view}}" title="{{::i18n.view}}"
ng-repeat="cipher in favoriteCiphers = (vaultCiphers | filter: {favorite: true} | ng-repeat="cipher in favoriteCiphers | orderBy: ['name', 'subTitle'] track by $index">
orderBy: ['name', 'subTitle']) track by $index">
<action-buttons cipher="cipher"></action-buttons> <action-buttons cipher="cipher"></action-buttons>
<icon cipher="cipher"></icon> <icon cipher="cipher"></icon>
<span class="text"> <span class="text">