1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

remove login from individual subvault

This commit is contained in:
Kyle Spearrin 2017-04-19 09:57:47 -04:00
parent 051703234c
commit 0b9083915a
4 changed files with 49 additions and 2 deletions

View File

@ -94,4 +94,26 @@
}
});
};
$scope.removeLogin = function (login, subvault) {
if (!confirm('Are you sure you want to remove this login (' + login.name + ') from the ' +
'subvault (' + subvault.name + ') ?')) {
return;
}
var request = {
subvaultIds: []
};
for (var i = 0; i < login.subvaultIds.length; i++) {
if (login.subvaultIds[i] !== subvault.id) {
request.subvaultIds.push(login.subvaultIds[i]);
}
}
apiService.ciphers.putSubvaults({ id: login.id }, request).$promise.then(function (response) {
$analytics.eventTrack('Removed From Subvault');
login.subvaultIds = request.subvaultIds;
});
};
});

View File

@ -47,7 +47,7 @@
</a>
</li>
<li>
<a href="javascript:void(0)" ng-click="deleteLogin(login)" class="text-red"
<a href="javascript:void(0)" ng-click="removeLogin(login, subvault)" class="text-red"
ng-if="subvault.id">
<i class="fa fa-fw fa-remove"></i> Remove
</a>

View File

@ -113,6 +113,31 @@
});
};
$scope.removeLogin = function (login, subvault) {
if (!confirm('Are you sure you want to remove this login (' + login.name + ') from the ' +
'subvault (' + subvault.name + ') ?')) {
return;
}
var request = {
subvaultIds: []
};
for (var i = 0; i < login.subvaultIds.length; i++) {
if (login.subvaultIds[i] !== subvault.id) {
request.subvaultIds.push(login.subvaultIds[i]);
}
}
apiService.ciphers.putSubvaults({ id: login.id }, request).$promise.then(function (response) {
$analytics.eventTrack('Removed From Subvault');
login.subvaultIds = request.subvaultIds;
if (!login.subvaultIds.length) {
removeRootLogin(findRootLogin(login));
}
});
};
function findRootLogin(login) {
if ($rootScope.vaultLogins) {
var rootLogins = $filter('filter')($rootScope.vaultLogins, { id: login.id });

View File

@ -70,7 +70,7 @@
</a>
</li>
<li>
<a href="javascript:void(0)" ng-click="deleteLogin(login)" class="text-red">
<a href="javascript:void(0)" ng-click="removeLogin(login, subvault)" class="text-red">
<i class="fa fa-fw fa-remove"></i> Remove
</a>
</li>