Skip to content

Commit

Permalink
Fix selection on the navbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
caedesvvv committed Feb 3, 2016
1 parent e48cb55 commit b3a48a6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 deletions.
12 changes: 6 additions & 6 deletions src/html/partials/sidebar.html
Expand Up @@ -3,16 +3,16 @@
<a ng-click="titleClick()" id="maintitle"><img id="logo" src="../images/logo.svg" width="32" height="32" ng-class="{'busy': status.syncing}" /> Darkwallet</a>
<a class="fa fa-arrow-left" ng-click="titleClick()"></a>
</li>
<li id="mainpocket" ng-class="{active: pocket.isAll}"><a ng-click="selectPocket()" id="maintitle"><img id="logo" src="../images/logo.svg" width="32" height="32" ng-class="{'busy': status.syncing}" /> Darkwallet</a></li>
<li><label>{{'my pockets'|_}} <a class="cornerbutton right" ng-class="{active: forms.selectedPocket==='newPocket'}" ng-click="newPocket()" title="{{'Add a new pocket'|_}}"> + </a></label></li>
<li ng-show="hdPocket" ng-class="{active: 'hd:'+$index===pocket.type+':'+pocket.lastIndex}" ng-repeat="hdPocket in hdPockets track by $index">
<li id="mainpocket" ng-class="{active: pocket.isAll}"><a ng-click="selectOverview()" id="maintitle"><img id="logo" src="../images/logo.svg" width="32" height="32" ng-class="{'busy': status.syncing}" /> Darkwallet</a></li>
<li><label>{{'my pockets'|_}} <a class="cornerbutton right" ng-class="{active: forms.selectedPocket==='newPocket'&&isActive('/wallet')}" ng-click="newPocket()" title="{{'Add a new pocket'|_}}"> + </a></label></li>
<li ng-show="hdPocket" ng-class="{active: 'hd:'+$index===pocket.type+':'+pocket.lastIndex&&isActive('/wallet')}" ng-repeat="hdPocket in hdPockets track by $index">
<a href="" ng-click="selectPocket(hdPocket.name, $index)">{{hdPocket.name | pocket}}</a>
</li>
<li class="divider"></li>
<li><label>{{'multisig funds'|_}} <a class="cornerbutton right" ng-class="{active: forms.selectedPocket==='newMultisig'}" ng-click="newMultiSig()" title="{{'Add new multisig'|_}}"> + </a></label></li>
<li ng-class="{active: 'multisig:'+$index===forms.selectedPocket}" ng-click="selectFund(fund, $index)" ng-repeat="fund in allFunds track by $index"><a href="">{{fund.name}}</a></li>
<li><label>{{'multisig funds'|_}} <a class="cornerbutton right" ng-class="{active: forms.selectedPocket==='newMultisig'&&isActive('/wallet')}" ng-click="newMultiSig()" title="{{'Add new multisig'|_}}"> + </a></label></li>
<li ng-class="{active: 'multisig:'+$index===forms.selectedPocket&&isActive('/wallet')}" ng-click="selectFund(fund, $index)" ng-repeat="fund in allFunds track by $index"><a href="">{{fund.name}}</a></li>
<li ng-show="forms.readOnlyArray.length"><label>{{'Watch-only pockets'|_}}</label></li>
<li ng-class="{active: 'readonly:'+$index===forms.selectedPocket}" ng-repeat="readOnlyPocket in forms.readOnlyArray track by $index"><a ng-click="selectReadOnly(readOnlyPocket, $index)"href="">{{readOnlyPocket.name}}</a></li>
<li ng-class="{active: 'readonly:'+$index===forms.selectedPocket&&isActive('/wallet')}" ng-repeat="readOnlyPocket in forms.readOnlyArray track by $index"><a ng-click="selectReadOnly(readOnlyPocket, $index)"href="">{{readOnlyPocket.name}}</a></li>


<li><label>Management</label></li>
Expand Down
23 changes: 9 additions & 14 deletions src/js/frontend/controllers/history.js
Expand Up @@ -86,20 +86,15 @@ function (controllers, DarkWallet, Port) {
var mainAddress = identity.wallet.getAddress([0]);
$scope.pocket.mainAddress = mainAddress.stealth;
}
if ($history.previousIdentity != identity.name) {
// prevents loading the first time...
//if ($history.previousIdentity) {
var pocketId = $routeParams.pocketId;
checkChanges($routeParams.pocketType, pocketId?parseInt(pocketId):undefined, true);

// Update tabs
$scope.tabs.updateTabs($scope.pocket.type, $scope.pocket.tasks);
//}

$history.previousIdentity = identity.name;
if (!$scope.$$phase) {
$scope.$apply();
}
var pocketId = $routeParams.pocketId;
checkChanges($routeParams.pocketType, pocketId?parseInt(pocketId):undefined, true);

// Update tabs
$scope.tabs.updateTabs($scope.pocket.type, $scope.pocket.tasks);

$history.previousIdentity = identity.name;
if (!$scope.$$phase) {
$scope.$apply();
}
}

Expand Down
21 changes: 17 additions & 4 deletions src/js/frontend/controllers/sidebar.js
Expand Up @@ -17,6 +17,10 @@ function (controllers, DarkWallet, Port) {
// Link tabs from service
$scope.tabs = $tabs;

$history.watch('selectedPocket', function(value) {
$scope.forms.selectedPocket = value;
$scope.pocket = $history.getCurrentPocket();
});

/**
* Identity Loading
Expand Down Expand Up @@ -51,17 +55,26 @@ function (controllers, DarkWallet, Port) {
$tabs.open('multisig', rowIndex);
};

/**
* Select the wallet overview
*/
$scope.selectOverview = function() {
if ($scope.forms.selectedPocket !== 'pocket:all') {
$scope.forms.overviewPocket = false;
$scope.forms.selectedPocket = false;
$tabs.open();
}
}

/**
* Select an hd pocket
*/
$scope.selectPocket = function(pocketName, rowIndex) {
console.log("selectPocket");
$scope.forms.overviewPocket = false;
$scope.forms.selectedPocket = false;
if (pocketName === undefined) {
$tabs.open();
$scope.selectOverview();
} else {
$scope.forms.overviewPocket = false;
$scope.forms.selectedPocket = false;
$tabs.open(undefined, rowIndex);
}
};
Expand Down
12 changes: 12 additions & 0 deletions src/js/frontend/providers/history.js
Expand Up @@ -15,9 +15,17 @@ function (providers, BtcUtils, DarkWallet, MultisigFund) {
this.txFilter = 'last';
this.addrFilter = 'unused';
this.$wallet = $wallet;
this.$scope = $scope;
this.rows = [];
}

/**
* Subscribe for changes on history provider scope.
*/
HistoryProvider.prototype.watch = function(name, cb) {
this.$scope.$watch(name, cb);
};

/**
* Balance
*/
Expand Down Expand Up @@ -88,6 +96,7 @@ function (providers, BtcUtils, DarkWallet, MultisigFund) {
if (this.selectGenericPocket('hd', keys.indexOf(''+idx))) {
this.selectedPocket = 'hd:' + idx;
this.pocket.lastIndex = idx;
this.$scope.selectedPocket = 'hd:' + idx;
}
break;
case 'readonly':
Expand Down Expand Up @@ -121,6 +130,7 @@ function (providers, BtcUtils, DarkWallet, MultisigFund) {
this.pocket.tasks = this.pocket.fund.tasks;
this.pocket.isFund = true;
this.selectedPocket = 'multisig:' + fundIndex;
this.$scope.selectedPocket = 'multisig:' + fundIndex;
}
};

Expand All @@ -147,6 +157,7 @@ function (providers, BtcUtils, DarkWallet, MultisigFund) {

this.pocket.tasks = [];
this.selectedPocket = 'pocket:all';
this.$scope.selectedPocket = 'pocket:all';
return this.chooseRows();
};

Expand Down Expand Up @@ -202,6 +213,7 @@ function (providers, BtcUtils, DarkWallet, MultisigFund) {

this.selectedPocket = type+':' + rowIndex;
this.chooseRows();
this.$scope.selectedPocket = type+':' + rowIndex;
return true;
};

Expand Down

0 comments on commit b3a48a6

Please sign in to comment.