From 3f72d429be80d95231eb1e319f5252400ebaf4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20N=C3=BCsse?= Date: Sat, 12 Oct 2019 15:22:11 +0200 Subject: [PATCH] Fix selection of different vaults by propagating the correct guid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Felix NĂ¼sse --- js/app/controllers/menu.js | 18 +++++++++--------- js/app/controllers/vault.js | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/js/app/controllers/menu.js b/js/app/controllers/menu.js index 5e8c125d..ab33bbb0 100644 --- a/js/app/controllers/menu.js +++ b/js/app/controllers/menu.js @@ -226,26 +226,26 @@ $scope.buildVaultList(args); }); + $scope.informVaultJs = function (event) { + var caller = event.target || event.srcElement; + console.log( caller ); + $rootScope.$broadcast('vault_listelement_clicked', caller.getAttribute("guid")); + }; + $scope.buildVaultList = function (vaults) { var list = document.getElementById("app-navigation-vaultlist"); for (var j = 0; j < vaults.length; j++){ var li = document.createElement("li"); - - li.setAttribute("ng-click", "selectVault(vaults[j])"); - - var guid = vaults[j].guid; - li.onclick = function(){ - $rootScope.$broadcast('vault_listelement_clicked', guid); - }; + li.onclick = $scope.informVaultJs; var a = document.createElement("a"); + a.setAttribute("guid", vaults[j].guid); a.classList="icon-category-security svg"; a.textContent = vaults[j].name; + li.appendChild(a); list.appendChild(li); - - //a.onclick = $scope.selectVault(vaults[j]); } var newVault = document.getElementById("app-navigation-vaultlist-new"); diff --git a/js/app/controllers/vault.js b/js/app/controllers/vault.js index 5dae4789..2d89667b 100644 --- a/js/app/controllers/vault.js +++ b/js/app/controllers/vault.js @@ -57,10 +57,11 @@ $scope.creating_vault = false; $scope.vault_selected = true; + console.log("show vault "+guid); for (var i = 0; i < vaults.length; i++) { if(vaults[i].guid === guid){ $scope.selectVault(vaults[i]); - console.log("show vault "+guid); + console.log("found vault "+guid); } } });