Rework on home page

This commit is contained in:
Benjamin Renard 2016-09-07 19:06:11 +02:00
parent f591a94c40
commit 93caf40a09
3 changed files with 38 additions and 4 deletions

View file

@ -481,9 +481,19 @@ on_back_to_scases_btn_click=function(e) {
* Show scases * Show scases
*******************/ *******************/
show_scases=function() { show_scases=function() {
clear_page('<ul class="list-group" id="scases"></ul>'); clear_page('<h3>Vos valises</h3><ul class="list-group" id="scases"></ul>');
scases.each(function(idx,scase) { scases.each(function(idx,scase) {
var li=$('<li class="list-group-item" data-name="'+scase.name+'">'+scase.name+'</li>'); var stats=scase.stats();
var tag='<span class="count-tag pull-right">';
if (stats.things==stats.done) {
tag+='<span class="label label-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></span>';
}
else {
tag+='<span class="badge">'+stats.done+' / '+stats.things+'</span>';
}
tag+='</span>';
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>');
li.bind('click',on_scase_click); li.bind('click',on_scase_click);
$('#scases').append(li); $('#scases').append(li);
}); });

View file

@ -215,8 +215,24 @@ function SCase(name,data) {
return false; return false;
} }
this.count=function() { this.stats=function() {
return this.cats.length; var cats=0;
var things=0;
var things_done=0;
this.cats.each(function(cidx,cat) {
cats++;
for (idx in cat.things) {
things++;
if (cat.things[idx].checked) {
things_done++;
}
}
});
return {
'cats': cats,
'things': things,
'done': things_done
}
} }
this.reset=function() { this.reset=function() {

View file

@ -37,6 +37,14 @@ div.panel-heading, li.list-group-item, a {
color: #999; color: #999;
text-decoration: line-through; text-decoration: line-through;
} }
.center {
text-align: center;
}
.scase-name {
font-size: 1.5em;
}
</style> </style>
<body> <body>