+

Sort contributions search result

Benjamin Renard [2014-12-01 22:19:05]
Sort contributions search result
Filename
inc/myco.js
inc/myco_objects.js
diff --git a/inc/myco.js b/inc/myco.js
index 06174f9..07e672f 100644
--- a/inc/myco.js
+++ b/inc/myco.js
@@ -180,7 +180,6 @@ show_contributions=function(group,contributor_email,contributions) {
   tbody.html('');
   if (!contributions) {
     contributions=group.contributionsByContributorEmail(contributor_email);
-    contributions.reverse();
   }
   _current_displayed_contributions=contributions;
   _current_displayed_contributions_group=group;
diff --git a/inc/myco_objects.js b/inc/myco_objects.js
index 5bac102..1f464ee 100644
--- a/inc/myco_objects.js
+++ b/inc/myco_objects.js
@@ -230,18 +230,22 @@ function Group(uuid,name,data) {
         ret.push(this.contributions[uuid]);
       }
     }
-    ret.sort(function(a,b) {
+    return this.sortContributionsByDate(ret);
+  }
+
+  this.sortContributionsByDate=function(contributions) {
+    contributions.sort(function(a,b) {
       if (a.date==b.date) {
         return 0;
       }
       else if(a.date<b.date) {
-        return -1;
+        return 1;
       }
       else {
-        return 1;
+        return -1;
       }
     });
-    return ret;
+    return contributions;
   }

   this.deletedContributionsByContributorEmail=function(email) {
@@ -345,7 +349,7 @@ function Group(uuid,name,data) {
         ret.push(this.contributions[uuid]);
       }
     }
-    return ret;
+    return this.sortContributionsByDate(ret);
   }

   this.getContributionsByCategory=function (category) {
ViewGit