Benjamin Renard commited on 2016-09-07 17:06:11
Showing 3 changed files, with 38 additions and 4 deletions.
... | ... |
@@ -481,9 +481,19 @@ on_back_to_scases_btn_click=function(e) { |
481 | 481 |
* Show scases |
482 | 482 |
*******************/ |
483 | 483 |
show_scases=function() { |
484 |
- clear_page('<ul class="list-group" id="scases"></ul>'); |
|
484 |
+ clear_page('<h3>Vos valises</h3><ul class="list-group" id="scases"></ul>'); |
|
485 | 485 |
scases.each(function(idx,scase) { |
486 |
- var li=$('<li class="list-group-item" data-name="'+scase.name+'">'+scase.name+'</li>'); |
|
486 |
+ var stats=scase.stats(); |
|
487 |
+ var tag='<span class="count-tag pull-right">'; |
|
488 |
+ if (stats.things==stats.done) { |
|
489 |
+ tag+='<span class="label label-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></span>'; |
|
490 |
+ } |
|
491 |
+ else { |
|
492 |
+ tag+='<span class="badge">'+stats.done+' / '+stats.things+'</span>'; |
|
493 |
+ } |
|
494 |
+ tag+='</span>'; |
|
495 |
+ |
|
496 |
+ var li=$('<li class="list-group-item" data-name="'+scase.name+'"><span class="scase-name"><span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span> '+scase.name+'</span>'+tag+'</li>'); |
|
487 | 497 |
li.bind('click',on_scase_click); |
488 | 498 |
$('#scases').append(li); |
489 | 499 |
}); |
... | ... |
@@ -215,8 +215,24 @@ function SCase(name,data) { |
215 | 215 |
return false; |
216 | 216 |
} |
217 | 217 |
|
218 |
- this.count=function() { |
|
219 |
- return this.cats.length; |
|
218 |
+ this.stats=function() { |
|
219 |
+ var cats=0; |
|
220 |
+ var things=0; |
|
221 |
+ var things_done=0; |
|
222 |
+ this.cats.each(function(cidx,cat) { |
|
223 |
+ cats++; |
|
224 |
+ for (idx in cat.things) { |
|
225 |
+ things++; |
|
226 |
+ if (cat.things[idx].checked) { |
|
227 |
+ things_done++; |
|
228 |
+ } |
|
229 |
+ } |
|
230 |
+ }); |
|
231 |
+ return { |
|
232 |
+ 'cats': cats, |
|
233 |
+ 'things': things, |
|
234 |
+ 'done': things_done |
|
235 |
+ } |
|
220 | 236 |
} |
221 | 237 |
|
222 | 238 |
this.reset=function() { |