mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-26 17:08:33 +01:00
manage root scope from subvault list edits
This commit is contained in:
parent
9863a95a71
commit
e89e48014c
@ -9,7 +9,8 @@
|
||||
</section>
|
||||
<section class="content">
|
||||
<p ng-show="loading && !subvaults.length">Loading...</p>
|
||||
<div class="box" ng-class="{'collapsed-box': subvault.collapsed}" ng-repeat="subvault in subvaults | orderBy: subvaultSort"
|
||||
<div class="box" ng-class="{'collapsed-box': subvault.collapsed}" ng-repeat="subvault in subvaults |
|
||||
orderBy: subvaultSort track by subvault.id"
|
||||
ng-show="subvaults.length">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
@ -32,7 +33,7 @@
|
||||
<table class="table table-striped table-hover table-vmiddle">
|
||||
<tbody>
|
||||
<tr ng-repeat="login in subvaultLogins = (logins | filter: filterBySubvault(subvault) |
|
||||
orderBy: ['name', 'username'])">
|
||||
orderBy: ['name', 'username']) track by login.id">
|
||||
<td style="width: 70px;">
|
||||
<div class="btn-group" data-append-to="body">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
|
@ -5,7 +5,6 @@
|
||||
$uibModal, $filter, $rootScope) {
|
||||
$scope.logins = [];
|
||||
$scope.subvaults = [];
|
||||
$scope.folders = [];
|
||||
$scope.loading = true;
|
||||
|
||||
$scope.$on('$viewContentLoaded', function () {
|
||||
@ -70,21 +69,25 @@
|
||||
});
|
||||
|
||||
editModel.result.then(function (returnVal) {
|
||||
var rootLogin = findRootLogin(login) || {};
|
||||
|
||||
if (returnVal.action === 'edit') {
|
||||
login.folderId = returnVal.data.folderId;
|
||||
login.name = returnVal.data.name;
|
||||
login.username = returnVal.data.username;
|
||||
login.favorite = returnVal.data.favorite;
|
||||
login.folderId = rootLogin.folderId = returnVal.data.folderId;
|
||||
login.name = rootLogin.name = returnVal.data.name;
|
||||
login.username = rootLogin.username = returnVal.data.username;
|
||||
login.favorite = rootLogin.favorite = returnVal.data.favorite;
|
||||
}
|
||||
else if (returnVal.action === 'partialEdit') {
|
||||
login.folderId = returnVal.data.folderId;
|
||||
login.favorite = returnVal.data.favorite;
|
||||
login.folderId = rootLogin.folderId = returnVal.data.folderId;
|
||||
login.favorite = rootLogin.favorite = returnVal.data.favorite;
|
||||
}
|
||||
else if (returnVal.action === 'delete') {
|
||||
var index = $scope.logins.indexOf(login);
|
||||
if (index > -1) {
|
||||
$scope.logins.splice(index, 1);
|
||||
}
|
||||
|
||||
removeRootLogin(rootLogin);
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -102,7 +105,31 @@
|
||||
modal.result.then(function (response) {
|
||||
if (response.subvaultIds) {
|
||||
login.subvaultIds = response.subvaultIds;
|
||||
|
||||
if (!response.subvaultIds.length) {
|
||||
removeRootLogin(findRootLogin(login));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function findRootLogin(login) {
|
||||
if ($rootScope.vaultLogins) {
|
||||
var rootLogins = $filter('filter')($rootScope.vaultLogins, { id: login.id });
|
||||
if (rootLogins && rootLogins.length) {
|
||||
return rootLogins[0];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function removeRootLogin(rootLogin) {
|
||||
if (rootLogin && rootLogin.id) {
|
||||
var index = $rootScope.vaultLogins.indexOf(rootLogin);
|
||||
if (index > -1) {
|
||||
$rootScope.vaultLogins.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -21,8 +21,9 @@
|
||||
Create an Organization
|
||||
</a>
|
||||
</div>
|
||||
<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" ng-class="{'collapsed-box': subvault.collapsed}" ng-repeat="subvault in subvaults |
|
||||
orderBy: ['name'] track by subvault.id"
|
||||
ng-show="subvaults.length">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
<i class="fa fa-share-alt-square"></i>
|
||||
@ -47,7 +48,7 @@
|
||||
<table class="table table-striped table-hover table-vmiddle">
|
||||
<tbody>
|
||||
<tr ng-repeat="login in subvaultLogins = (logins | filter: filterBySubvault(subvault) |
|
||||
filter: (main.searchVaultText || '') | orderBy: ['name', 'username'])">
|
||||
orderBy: ['name', 'username']) track by login.id">
|
||||
<td style="width: 70px;">
|
||||
<div class="btn-group" data-append-to="body">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
|
Loading…
Reference in New Issue
Block a user