Add getContributionsByCategory() and findUnusedCategories() method to group object

This commit is contained in:
Benjamin Renard 2014-08-02 16:39:13 +02:00
parent 727b1e5d6f
commit ddaa11ec4f

View file

@ -337,6 +337,36 @@ function Group(uuid,name,data) {
}; };
} }
this.getContributionsByCategory=function (category) {
var ret={};
for (uuid in this.contributions) {
if (this.contributions[uuid].category==category.uuid) {
ret[uuid]=this.contributions[uuid];
}
}
return ret;
}
this.findUnusedCategories=function() {
var cats={};
for (uuid in this.contributions) {
cid=this.contributions[uuid].category;
if ($.type(cats[cid])=='undefined') {
cats[cid]=1;
}
else {
cats[cid]++;
}
}
var ret={};
for (cid in this.categories) {
if ($.type(cats[cid])=='undefined') {
ret[cid]=this.categories[cid];
}
}
return ret;
}
/* /*
* Categories * Categories
*/ */