diff --git a/inc/myco.js b/inc/myco.js
index 8cd1f7c..d0bbbf9 100644
--- a/inc/myco.js
+++ b/inc/myco.js
@@ -135,7 +135,7 @@ on_home_grp_cat_btn_click=function(e) {
grp=groups[grp_id];
ul=$('#grp_cat_modal ul');
html="";
- for(cid in grp.categories) {
+ for(cid in grp.getSortedCategories()) {
html+="
"+grp.categories[cid]['name']+"";
}
ul.html(html);
@@ -392,11 +392,13 @@ on_show_add_contribution_modal=function(e) {
$('#add_contribution_modal #add_contribution_contributor_email')[0].value=$('#view-group #contributor')[0].value;
gid=$('#add_contribution_modal').data('group-uuid');
group=groups[gid];
+ current_cat=$('#add_contribution_modal #add_contribution_category')[0].value;
cats="";
- for (u in group.categories) {
+ for (u in group.getSortedCategories()) {
cats+="";
}
$('#add_contribution_modal #add_contribution_category').html(cats);
+ $('#add_contribution_modal #add_contribution_category')[0].value=current_cat;
$('#add_contribution_modal #add_contribution_title').focus();
}
diff --git a/inc/myco_objects.js b/inc/myco_objects.js
index 598d38d..319bcf4 100644
--- a/inc/myco_objects.js
+++ b/inc/myco_objects.js
@@ -338,6 +338,22 @@ function Group(uuid,name,data) {
data.lastChange
);
}
+
+ this.getSortedCategories=function() {
+ uuids=[];
+ for (uuid in this.categories) {
+ uuids.push(uuid);
+ }
+ tmp_cats=this.categories;
+ uuids.sort(function(a,b) {
+ return tmp_cats[a]['name'].localeCompare(tmp_cats[b]['name']);
+ });
+ var ret={};
+ for (idx in uuids) {
+ ret[uuids[idx]]=this.categories[uuids[idx]];
+ }
+ return ret;
+ }
/*
* Balance