persist folder/subvault collapse
This commit is contained in:
parent
a81572914a
commit
751935e90b
|
@ -2,20 +2,23 @@
|
|||
.module('bit.vault')
|
||||
|
||||
.controller('vaultController', function ($scope, $uibModal, apiService, $filter, cryptoService, authService, toastr,
|
||||
cipherService, $q) {
|
||||
cipherService, $q, $localStorage) {
|
||||
$scope.logins = [];
|
||||
$scope.folders = [];
|
||||
$scope.loading = true;
|
||||
$scope.favoriteCollapsed = $localStorage.collapsedFolders && 'favorite' in $localStorage.collapsedFolders;
|
||||
|
||||
$scope.$on('$viewContentLoaded', function () {
|
||||
var folderPromise = apiService.folders.list({}, function (folders) {
|
||||
var decFolders = [{
|
||||
id: null,
|
||||
name: 'No Folder'
|
||||
name: 'No Folder',
|
||||
collapsed: $localStorage.collapsedFolders && 'none' in $localStorage.collapsedFolders
|
||||
}];
|
||||
|
||||
for (var i = 0; i < folders.Data.length; i++) {
|
||||
var decFolder = cipherService.decryptFolderPreview(folders.Data[i]);
|
||||
decFolder.collapsed = $localStorage.collapsedFolders && decFolder.id in $localStorage.collapsedFolders;
|
||||
decFolders.push(decFolder);
|
||||
}
|
||||
|
||||
|
@ -48,6 +51,20 @@
|
|||
return item.name.toLowerCase();
|
||||
};
|
||||
|
||||
$scope.collapseExpand = function (folder, favorite) {
|
||||
if (!$localStorage.collapsedFolders) {
|
||||
$localStorage.collapsedFolders = {};
|
||||
}
|
||||
|
||||
var id = favorite ? 'favorite' : (folder.id || 'none');
|
||||
if (id in $localStorage.collapsedFolders) {
|
||||
delete $localStorage.collapsedFolders[id];
|
||||
}
|
||||
else {
|
||||
$localStorage.collapsedFolders[id] = true;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.editLogin = function (login) {
|
||||
var editModel = $uibModal.open({
|
||||
animation: true,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
angular
|
||||
.module('bit.vault')
|
||||
|
||||
.controller('vaultSubvaultsController', function ($scope, apiService, cipherService, $analytics, $q) {
|
||||
.controller('vaultSubvaultsController', function ($scope, apiService, cipherService, $analytics, $q, $localStorage) {
|
||||
$scope.logins = [];
|
||||
$scope.subvaults = [];
|
||||
$scope.loading = true;
|
||||
|
@ -12,6 +12,8 @@
|
|||
|
||||
for (var i = 0; i < subvaults.Data.length; i++) {
|
||||
var decSubvault = cipherService.decryptSubvault(subvaults.Data[i], null, true);
|
||||
decSubvault.collapsed = $localStorage.collapsedSubvaults &&
|
||||
decSubvault.id in $localStorage.collapsedSubvaults;
|
||||
decSubvaults.push(decSubvault);
|
||||
}
|
||||
|
||||
|
@ -41,4 +43,17 @@
|
|||
return cipher.subvaultIds.indexOf(subvault.id) > -1;
|
||||
};
|
||||
};
|
||||
|
||||
$scope.collapseExpand = function (subvault) {
|
||||
if (!$localStorage.collapsedSubvaults) {
|
||||
$localStorage.collapsedSubvaults = {};
|
||||
}
|
||||
|
||||
if (subvault.id in $localStorage.collapsedFolders) {
|
||||
delete $localStorage.collapsedSubvaults[subvault.id];
|
||||
}
|
||||
else {
|
||||
$localStorage.collapsedSubvaults[subvault.id] = true;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div ng-show="loading && !folders.length">
|
||||
<p>Loading...</p>
|
||||
</div>
|
||||
<div class="box box-primary" style="margin-bottom: 40px;"
|
||||
<div class="box box-primary" ng-class="{'collapsed-box': favoriteCollapsed}" style="margin-bottom: 40px;"
|
||||
ng-show="!loading && (!main.searchVaultText || favoriteLogins.length)">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
|
@ -29,8 +29,9 @@
|
|||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" uib-tooltip="Collapse/Expand">
|
||||
<i class="fa fa-minus"></i>
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" uib-tooltip="Collapse/Expand"
|
||||
ng-click="collapseExpand(null, true)">
|
||||
<i class="fa" ng-class="{'fa-minus': !favoriteCollapsed, 'fa-plus': favoriteCollapsed}"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -74,7 +75,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box" ng-repeat="folder in folders | orderBy: folderSort"
|
||||
<div class="box" ng-class="{'collapsed-box': folder.collapsed}" ng-repeat="folder in folders | orderBy: folderSort"
|
||||
ng-show="folders.length && (!main.searchVaultText || folderLogins.length)">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
|
@ -105,8 +106,9 @@
|
|||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" uib-tooltip="Collapse/Expand">
|
||||
<i class="fa fa-minus"></i>
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" uib-tooltip="Collapse/Expand"
|
||||
ng-click="collapseExpand(folder)">
|
||||
<i class="fa" ng-class="{'fa-minus': !folder.collapsed, 'fa-plus': folder.collapsed}"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<div ng-show="!loading && !subvaults.length">
|
||||
<p>No subvaults.</p>
|
||||
</div>
|
||||
<div class="box" ng-repeat="subvault in subvaults | orderBy: ['name']"
|
||||
<div class="box" ng-class="{'collapsed-box': subvault.collapsed}" ng-repeat="subvault in subvaults | orderBy: ['name']"
|
||||
ng-show="subvaults.length && (!main.searchVaultText || subvaultLogins.length)">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
|
@ -19,8 +19,9 @@
|
|||
{{subvault.name}} <small>{{subvaultLogins.length}} logins</small>
|
||||
</h3>
|
||||
<div class="box-tools">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" uib-tooltip="Collapse/Expand">
|
||||
<i class="fa fa-minus"></i>
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" uib-tooltip="Collapse/Expand"
|
||||
ng-click="collapseExpand(subvault)">
|
||||
<i class="fa" ng-class="{'fa-minus': !subvault.collapsed, 'fa-plus': subvault.collapsed}"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue