Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 3d64cef

Browse files
committed
Merge pull request #554 from appirio-tech/sup-2578-no-money
Hide money if $0
2 parents bc7ab18 + 4c88d8c commit 3d64cef

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

app/directives/page-state-header/page-state-header.directive.jade

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
header
33
.page-info
44
h1 {{pageTitle}}
5+
56
div(ng-transclude)
7+
68
.info
79
.pic
810
a(ui-sref="profile.about({userHandle: vm.profile.handle})")
911
img.profile-circle(ng-if="vm.profile.photoURL", ng-src="{{vm.profile.photoURL}}")
12+
1013
img.profile-circle(ng-if="!vm.profile.photoURL", src="/images/ico-user-default.svg")
11-
14+
1215
.user-stats(id="metrics", ng-hide="vm.loading")
1316
a.handle(style="color:{{vm.handleColor}};", ui-sref="profile.about({userHandle: vm.profile.handle})") {{vm.profile.handle}}
17+
1418
.money-earned(ng-hide="hideMoney")
1519
p.number(ng-bind="vm.moneyEarned | currency:'$':0")
20+
1621
p Earned
22+
1723
.back-link(ng-if="showBackLink && vm.previousStateLabel")
1824
a(ng-click="vm.backHandler()") Back to {{vm.previousStateLabel}}
1925

app/directives/page-state-header/page-state-header.directive.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@
1414
defaultState: '@'
1515
},
1616
controller: ['CONSTANTS', '$rootScope', '$scope', 'NotificationService', 'ProfileService', '$log', '$state', pageStateHeader],
17-
controllerAs: "vm"
17+
controllerAs: 'vm'
1818
};
1919
});
2020

2121
function pageStateHeader(CONSTANTS, $rootScope, $scope, NotificationService, ProfileService, $log, $state) {
2222
var vm = this;
23-
vm.handle = $scope.handle;
24-
vm.profile = null;
25-
vm.handleColor = null;
26-
vm.hideMoney = _.get($scope, 'hideMoney', true);
27-
vm.previousStateName = null;
28-
vm.previousStateLabel = null;
29-
vm.previousState = null;
30-
vm.showBackLink = _.get($scope, 'showBackLink', false);
3123
vm.backHandler = backHandler;
24+
3225
activate();
3326

3427
// watch for profile update event in case handle/image are updated
@@ -37,12 +30,21 @@
3730
});
3831

3932
function activate() {
33+
vm.handle = $scope.handle;
34+
vm.profile = null;
35+
vm.handleColor = null;
36+
$scope.hideMoney = _.get($scope, 'hideMoney', true);
37+
vm.previousStateName = null;
38+
vm.previousStateLabel = null;
39+
vm.previousState = null;
40+
vm.showBackLink = _.get($scope, 'showBackLink', false);
4041
vm.loading = true;
4142

4243
// identifies the previous state
4344
if ($scope.$root.previousState && $scope.$root.previousState.name.length > 0) {
4445
vm.previousState = $scope.$root.previousState;
4546
vm.previousStateName = vm.previousState.name;
47+
4648
} else if ($scope.defaultState) {
4749
vm.previousStateName = $scope.defaultState;
4850
}
@@ -51,6 +53,7 @@
5153
if (vm.previousStateName) {
5254
if (vm.previousStateName === 'dashboard') {
5355
vm.previousStateLabel = 'Dashboard';
56+
5457
} else if (vm.previousStateName.indexOf('profile') > -1) {
5558
vm.previousStateLabel = 'Profile';
5659
}
@@ -60,7 +63,8 @@
6063
ProfileService.getUserProfile(vm.handle).then(function(profile) {
6164
vm.profile = profile;
6265
vm.handleColor = ProfileService.getUserHandleColor(vm.profile);
63-
if (!vm.hideMoney) {
66+
67+
if (!$scope.hideMoney) {
6468
displayMoneyEarned(vm.handle);
6569
} else {
6670
vm.loading = false;
@@ -71,6 +75,7 @@
7175
function backHandler() {
7276
var _params = {};
7377
var _name = vm.previousStateName;
78+
7479
switch (vm.previousStateName) {
7580
case 'profile.about':
7681
_params = {userHandle: vm.profile.handle};
@@ -80,6 +85,7 @@
8085
_name = 'dashboard';
8186
break;
8287
}
88+
8389
$state.go(_name, _params);
8490
}
8591

@@ -89,13 +95,13 @@
8995
vm.moneyEarned = _.sum(_.pluck(financials, 'amount'));
9096

9197
if (!vm.moneyEarned) {
92-
vm.hideMoney = true;
98+
$scope.hideMoney = true;
9399
}
94100

95101
vm.loading = false;
96102
})
97103
.catch(function(err) {
98-
vm.hideMoney = true;
104+
$scope.hideMoney = true;
99105
vm.loading = false;
100106
});
101107
}

0 commit comments

Comments
 (0)