Benjamin Renard commited on 2014-07-19 22:37:25
Showing 2 changed files, with 20 additions and 2 deletions.
... | ... |
@@ -135,7 +135,7 @@ on_home_grp_cat_btn_click=function(e) { |
135 | 135 |
grp=groups[grp_id]; |
136 | 136 |
ul=$('#grp_cat_modal ul'); |
137 | 137 |
html=""; |
138 |
- for(cid in grp.categories) { |
|
138 |
+ for(cid in grp.getSortedCategories()) { |
|
139 | 139 |
html+="<li><span class='cat-color' style='background-color: "+grp.categories[cid]['color']+"'></span> "+grp.categories[cid]['name']+"</li>"; |
140 | 140 |
} |
141 | 141 |
ul.html(html); |
... | ... |
@@ -392,11 +392,13 @@ on_show_add_contribution_modal=function(e) { |
392 | 392 |
$('#add_contribution_modal #add_contribution_contributor_email')[0].value=$('#view-group #contributor')[0].value; |
393 | 393 |
gid=$('#add_contribution_modal').data('group-uuid'); |
394 | 394 |
group=groups[gid]; |
395 |
+ current_cat=$('#add_contribution_modal #add_contribution_category')[0].value; |
|
395 | 396 |
cats="<option value=''>Non définie</option>"; |
396 |
- for (u in group.categories) { |
|
397 |
+ for (u in group.getSortedCategories()) { |
|
397 | 398 |
cats+="<option value='"+u+"'>"+group.categories[u]['name']+"</option>"; |
398 | 399 |
} |
399 | 400 |
$('#add_contribution_modal #add_contribution_category').html(cats); |
401 |
+ $('#add_contribution_modal #add_contribution_category')[0].value=current_cat; |
|
400 | 402 |
$('#add_contribution_modal #add_contribution_title').focus(); |
401 | 403 |
} |
402 | 404 |
|
... | ... |
@@ -339,6 +339,22 @@ function Group(uuid,name,data) { |
339 | 339 |
); |
340 | 340 |
} |
341 | 341 |
|
342 |
+ this.getSortedCategories=function() { |
|
343 |
+ uuids=[]; |
|
344 |
+ for (uuid in this.categories) { |
|
345 |
+ uuids.push(uuid); |
|
346 |
+ } |
|
347 |
+ tmp_cats=this.categories; |
|
348 |
+ uuids.sort(function(a,b) { |
|
349 |
+ return tmp_cats[a]['name'].localeCompare(tmp_cats[b]['name']); |
|
350 |
+ }); |
|
351 |
+ var ret={}; |
|
352 |
+ for (idx in uuids) { |
|
353 |
+ ret[uuids[idx]]=this.categories[uuids[idx]]; |
|
354 |
+ } |
|
355 |
+ return ret; |
|
356 |
+ } |
|
357 |
+ |
|
342 | 358 |
/* |
343 | 359 |
* Balance |
344 | 360 |
*/ |
345 | 361 |