Skip to content

Commit

Permalink
delegation list displays unilateral received delegations
Browse files Browse the repository at this point in the history
  • Loading branch information
santisiri committed Oct 27, 2017
1 parent 947dbf4 commit ec40bd4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
20 changes: 19 additions & 1 deletion imports/ui/modules/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,27 @@ const _getDelegatesMenu = () => {
let sent;
let received;
let source;
let contracts = [];
const politics = [];

// unilaterally received delegations
if (Meteor.user()) {
contracts = _.pluck(Contracts.find({ signatures: { $elemMatch: { username: Meteor.user().username } } }).fetch(), '_id');
}

// sent delegations
const transactions = _.filter(Transactions.find({ kind: 'DELEGATION' }).fetch(),
(item) => { return (item.input.entityId === Meteor.userId() || item.output.entityId === Meteor.userId()); }, 0);
(item) => {
if (contracts.length > 0) {
for (const signed in contracts) {
if (item.input.entityId === contracts[signed] || item.output.entityId === contracts[signed]) {
return true;
}
}
}
return (item.input.entityId === Meteor.userId() || item.output.entityId === Meteor.userId());
}, 0);


if (transactions.length > 0) {
delegations = _.uniq(_.pluck(transactions, 'contractId'));
Expand Down
2 changes: 0 additions & 2 deletions imports/ui/templates/layout/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ Meteor.startup(() => {
});

// geographical Info
// HTTP.get(Meteor.absoluteUrl('data/geo.json'), (err, result) => {
// });
globalObj.geoJSON = geo;
Session.set('filteredCountries', geo.country);
});
Expand Down
1 change: 1 addition & 0 deletions imports/ui/templates/layout/sidebar/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function getList(db, sort) {
*/
function getDelegates() {
const delegates = _.sortBy(getDelegatesMenu(), (user) => { return parseInt(0 - (user.sent + user.received), 10); });
console.log(delegates);
const delegateList = [];
for (const i in delegates) {
delegateList.push(Meteor.users.find({ _id: delegates[i].userId }).fetch()[0]);
Expand Down

0 comments on commit ec40bd4

Please sign in to comment.