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