+

Filter contributions by current contributor on contribution search

Benjamin Renard [2014-12-01 22:20:18]
Filter contributions by current contributor on contribution search
Filename
inc/myco.js
inc/myco_objects.js
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]);
       }
ViewGit