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

Hide money if $0 #554

Merged
merged 1 commit into from
Nov 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
header
.page-info
h1 {{pageTitle}}

div(ng-transclude)

.info
.pic
a(ui-sref="profile.about({userHandle: vm.profile.handle})")
img.profile-circle(ng-if="vm.profile.photoURL", ng-src="{{vm.profile.photoURL}}")

img.profile-circle(ng-if="!vm.profile.photoURL", src="/images/ico-user-default.svg")

.user-stats(id="metrics", ng-hide="vm.loading")
a.handle(style="color:{{vm.handleColor}};", ui-sref="profile.about({userHandle: vm.profile.handle})") {{vm.profile.handle}}

.money-earned(ng-hide="hideMoney")
p.number(ng-bind="vm.moneyEarned | currency:'$':0")

p Earned

.back-link(ng-if="showBackLink && vm.previousStateLabel")
a(ng-click="vm.backHandler()") Back to {{vm.previousStateLabel}}

30 changes: 18 additions & 12 deletions app/directives/page-state-header/page-state-header.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,14 @@
defaultState: '@'
},
controller: ['CONSTANTS', '$rootScope', '$scope', 'NotificationService', 'ProfileService', '$log', '$state', pageStateHeader],
controllerAs: "vm"
controllerAs: 'vm'
};
});

function pageStateHeader(CONSTANTS, $rootScope, $scope, NotificationService, ProfileService, $log, $state) {
var vm = this;
vm.handle = $scope.handle;
vm.profile = null;
vm.handleColor = null;
vm.hideMoney = _.get($scope, 'hideMoney', true);
vm.previousStateName = null;
vm.previousStateLabel = null;
vm.previousState = null;
vm.showBackLink = _.get($scope, 'showBackLink', false);
vm.backHandler = backHandler;

activate();

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

function activate() {
vm.handle = $scope.handle;
vm.profile = null;
vm.handleColor = null;
$scope.hideMoney = _.get($scope, 'hideMoney', true);
vm.previousStateName = null;
vm.previousStateLabel = null;
vm.previousState = null;
vm.showBackLink = _.get($scope, 'showBackLink', false);
vm.loading = true;

// identifies the previous state
if ($scope.$root.previousState && $scope.$root.previousState.name.length > 0) {
vm.previousState = $scope.$root.previousState;
vm.previousStateName = vm.previousState.name;

} else if ($scope.defaultState) {
vm.previousStateName = $scope.defaultState;
}
Expand All @@ -51,6 +53,7 @@
if (vm.previousStateName) {
if (vm.previousStateName === 'dashboard') {
vm.previousStateLabel = 'Dashboard';

} else if (vm.previousStateName.indexOf('profile') > -1) {
vm.previousStateLabel = 'Profile';
}
Expand All @@ -60,7 +63,8 @@
ProfileService.getUserProfile(vm.handle).then(function(profile) {
vm.profile = profile;
vm.handleColor = ProfileService.getUserHandleColor(vm.profile);
if (!vm.hideMoney) {

if (!$scope.hideMoney) {
displayMoneyEarned(vm.handle);
} else {
vm.loading = false;
Expand All @@ -71,6 +75,7 @@
function backHandler() {
var _params = {};
var _name = vm.previousStateName;

switch (vm.previousStateName) {
case 'profile.about':
_params = {userHandle: vm.profile.handle};
Expand All @@ -80,6 +85,7 @@
_name = 'dashboard';
break;
}

$state.go(_name, _params);
}

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

if (!vm.moneyEarned) {
vm.hideMoney = true;
$scope.hideMoney = true;
}

vm.loading = false;
})
.catch(function(err) {
vm.hideMoney = true;
$scope.hideMoney = true;
vm.loading = false;
});
}
Expand Down