From 5eb426449f564409023a31db54bedba7a948fb4c Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 1 Dec 2014 23:20:18 +0100 Subject: [PATCH] Filter contributions by current contributor on contribution search --- inc/myco.js | 3 ++- inc/myco_objects.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/inc/myco.js b/inc/myco.js index 07e672f..7fec6fa 100644 --- a/inc/myco.js +++ b/inc/myco.js @@ -342,8 +342,9 @@ on_nav_search_form_input=function(e) { var pattern=ipt.val(); group=groups[$('#view-group').data('uuid')]; + contributor_email=$('#view-group #contributor')[0].value; - var found=group.searchContributions(pattern); + var found=group.searchContributions(pattern,contributor_email); show_contributions(group,null,found); } diff --git a/inc/myco_objects.js b/inc/myco_objects.js index 1f464ee..1311c29 100644 --- a/inc/myco_objects.js +++ b/inc/myco_objects.js @@ -341,10 +341,13 @@ function Group(uuid,name,data) { }; } - this.searchContributions=function(pattern) { + this.searchContributions=function(pattern,contributor) { var ret=[]; substrRegex = new RegExp(pattern, 'i'); for (uuid in this.contributions) { + if (contributor && contributor!=this.contributions[uuid].contributor.email) { + continue; + } if (substrRegex.test(this.contributions[uuid].title) || substrRegex.test(this.contributions[uuid].cost)) { ret.push(this.contributions[uuid]); }