Skip to content

Commit

Permalink
displays wallet values on profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
santisiri committed Nov 7, 2017
1 parent f22ce38 commit 7249696
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
8 changes: 5 additions & 3 deletions imports/ui/modules/Vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import { transact, getVotes } from '/imports/api/transactions/transaction';
* @param {string} targetId the id of the targeted element
* @return {string} type VOTE, DELEGATION, UNKNOWN
*/
const _getVoteType = (targetId) => {
if (targetId === Meteor.userId()) { return 'BALANCE'; }
const _getVoteType = (targetId, sessionId) => {
if (targetId === Meteor.userId() || sessionId.first(17) === 'vote-user-balance') {
return 'BALANCE';
}
const contract = Contracts.findOne({ _id: targetId });
if (contract) {
return contract.kind;
Expand Down Expand Up @@ -132,7 +134,7 @@ export class Vote {
this.initialized = true;
this.enabled = true;
this.mode = 'PENDING';
this.voteType = _getVoteType(targetId);
this.voteType = _getVoteType(targetId, sessionId);
this.targetId = targetId;
this.sourceId = sourceId;
this.maxVotes = parseInt(this.available + this.inBallot, 10);
Expand Down
2 changes: 1 addition & 1 deletion imports/ui/templates/components/decision/liquid/liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ Template.capital.helpers({
return 'stage-finish-rejected';
}
if (Session.get(this._id).voteType === 'BALANCE') {
return 'stage-finish-approved';
return 'stage-placed';
}
return 'stage-placed';
case 'received':
Expand Down
7 changes: 5 additions & 2 deletions imports/ui/templates/components/identity/card/card.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<template name="card">
<div class="login">
{{> avatar profile=this includeName=true includeNation=true editable=false disabled=true includeRole=false}}

{{#with profile}}
{{> liquid _id=this.balanceId targetId=this.targetId wallet=this.wallet isDelegation=false editable=false hideBar=true balanceMode=true}}
{{/with}}

{{#if currentUser}}
{{#unless myself}}

<div class="login-label title-label">
{{_ 'delegation-status'}}
</div>

{{#with voteSettings}}
{{> liquid _id=this.voteId sourceId=this.sourceId contract=contract targetId=this.targetId wallet=this.wallet editable=true}}
{{/with}}
Expand Down
8 changes: 8 additions & 0 deletions imports/ui/templates/components/identity/card/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ Template.card.helpers({
contract() {
return getDelegationContract(Meteor.userId(), this._id);
},
profile() {
const userId = this.toString();
return {
balanceId: `vote-user-balance-${userId}`,
targetId: userId,
wallet: Meteor.users.findOne({ _id: userId }).profile.wallet,
};
},
});

0 comments on commit 7249696

Please sign in to comment.