Fixed disappearing credentials on foldermove to new folder

Signed-off-by: Felix Nüsse <Felix.nuesse@t-online.de>
This commit is contained in:
Felix Nüsse 2018-12-31 17:58:48 +01:00
parent b79547edc1
commit 02040f6b0e
No known key found for this signature in database
GPG key ID: 2089A3431243E819
2 changed files with 14 additions and 21 deletions

View file

@ -540,24 +540,26 @@
$scope.TempFolderList=Temp;
};
$rootScope.$on('updateFolderInMainList', function (updated_credential) {
$scope.buildFolderList(updated_credential);
$rootScope.$on('updateFolderInMainList', function (evt, updated_credential) {
for (var i = 0; i < $scope.active_vault.credentials.length; i++) {
if($scope.active_vault.credentials[i].guid === updated_credential.guid){
$scope.active_vault.credentials[i]=updated_credential;
}
}
$scope.buildFolderList(true);
$scope.getCurrentFolderList();
$scope.createBreadCrumbList();
});
$rootScope.$on('credentials_loaded', function () {
//create all folders after fetching credentials
$scope.buildFolderList();
$scope.buildFolderList(false);
$scope.getCurrentFolderList();
});
$scope.buildFolderList = function (updated_credential) {
var update=false;
if(typeof updated_credential !== 'undefined'){
update=true;
}
$scope.buildFolderList = function (update) {
$scope.FolderList=["/"];
$scope.TempFolderList=[];
@ -567,7 +569,7 @@
var _credential = $scope.active_vault.credentials[i];
if(_credential.folderpath !== null){
if(_credential.folderpath.startsWith($scope.currentFolder) || update){
if(String(_credential.folderpath).startsWith(String($scope.currentFolder)) || update){
if($scope.FolderList.indexOf(_credential.folderpath) <= -1){
$scope.FolderList.push(_credential.folderpath);
}
@ -580,19 +582,10 @@
$scope.active_vault.credentials[i]=_credential;
}
if(update){
if(!$scope.FolderList.includes(updated_credential.folderpath)){
$scope.FolderList.push(updated_credential.folderpath);
}
}
if(!$scope.FolderList.includes($scope.currentFolder)){
$scope.currentFolder="/";
}
console.log($scope.FolderList);
console.log($scope.TempFolderList);
};
$scope.selectedtags = [];

View file

@ -39,9 +39,9 @@
link: function(scope, element) {
scope.save = function() {
CredentialService.updateCredential(scope.credential).then(function (updated_cred) {
CredentialService.updateCredential(scope.credential).then(function () {
NotificationService.showNotification($translate.instant('folderpath.moved'), 5000);
$rootScope.$broadcast('updateFolderInMainList', updated_cred);
$rootScope.$broadcast('updateFolderInMainList', scope.credential);
$('#folderPicker').dialog('close');
});
};