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')
.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',
state = stateService.getState(stateKey) || {};
stateService.removeState('viewGrouping');
@ -25,8 +25,13 @@ angular
$scope.loaded = true;
if (!$rootScope.vaultCiphers) {
$rootScope.vaultCiphers = [];
$scope.favoriteCiphers = [];
delayLoad = false;
}
else {
$scope.favoriteCiphers = $filter('filter')($rootScope.vaultCiphers, { favorite: true });
}
if (!$rootScope.vaultFolders) {
$rootScope.vaultFolders = [];
delayLoad = false;
@ -68,6 +73,7 @@ angular
$rootScope.vaultFolders = decFolders;
$rootScope.vaultCollections = decCollections;
$rootScope.vaultCiphers = decCiphers;
$scope.favoriteCiphers = $filter('filter')($rootScope.vaultCiphers, { favorite: true });
if ($scope.showGroupingCounts) {
var folderCounts = { 'none': 0 };

View File

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