Improve category selection
This commit is contained in:
parent
824225b5d6
commit
996c19ba8f
2 changed files with 20 additions and 2 deletions
|
@ -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+="<li><span class='cat-color' style='background-color: "+grp.categories[cid]['color']+"'></span> "+grp.categories[cid]['name']+"</li>";
|
||||
}
|
||||
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="<option value=''>Non définie</option>";
|
||||
for (u in group.categories) {
|
||||
for (u in group.getSortedCategories()) {
|
||||
cats+="<option value='"+u+"'>"+group.categories[u]['name']+"</option>";
|
||||
}
|
||||
$('#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -339,6 +339,22 @@ function Group(uuid,name,data) {
|
|||
);
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue