Working on time tracker

This commit is contained in:
Hillel Coren 2017-09-26 10:19:33 +03:00
parent 50fdf31121
commit 63c1e651cc
2 changed files with 21 additions and 0 deletions

View File

@ -421,6 +421,7 @@
} }
ko.applyBindings(model); ko.applyBindings(model);
model.refreshTitle();
model.tock(); model.tock();
if (isStorageSupported()) { if (isStorageSupported()) {

View File

@ -30,6 +30,23 @@
location.reload(); location.reload();
} }
self.refreshTitle = function() {
var tasks = self.tasks();
var count = 0;
for (var i=0; i<tasks.length; i++) {
var task = tasks[i];
if (task.isRunning()) {
count++;
}
}
var title = '';
if (count > 0) {
title = '(' + count + ') ';
}
title += "{{ trans('texts.time_tracker') }} | {{ APP_NAME }}";
document.title = title;
}
self.submitBulkAction = function(action, task) { self.submitBulkAction = function(action, task) {
if (! task || ! action) { if (! task || ! action) {
return false; return false;
@ -53,6 +70,7 @@
self.selectTask(false); self.selectTask(false);
$('#search').focus(); $('#search').focus();
} }
self.refreshTitle();
if (action == 'archive') { if (action == 'archive') {
toastr.success("{{ trans('texts.archived_task') }}"); toastr.success("{{ trans('texts.archived_task') }}");
} else if (action == 'delete') { } else if (action == 'delete') {
@ -185,6 +203,7 @@
task.addTime(time); task.addTime(time);
self.selectedTask(task); self.selectedTask(task);
self.addTask(task); self.addTask(task);
model.refreshTitle();
self.filter(''); self.filter('');
task.focus(); task.focus();
} }
@ -480,6 +499,7 @@
toastr.success("{{ trans('texts.stopped_task') }}"); toastr.success("{{ trans('texts.stopped_task') }}");
} }
} }
model.refreshTitle();
setTimeout(function() { setTimeout(function() {
model.isStartEnabled(true); model.isStartEnabled(true);
}, 1000); }, 1000);