Working on the time tracker

This commit is contained in:
Hillel Coren 2017-10-02 11:54:22 +03:00
parent 33ea69474c
commit 6fd6cf0ec5
2 changed files with 20 additions and 3 deletions

View File

@ -112,8 +112,8 @@
bottom: 0; bottom: 0;
width: 6px; width: 6px;
content: ""; content: "";
background-color: #d9534f; /* red */ background-color: #36c157; /* green */
xbackground-color: #36c157; /* green */ xbackground-color: #d9534f; /* red */
xbackground-color: orange; /* orange */ xbackground-color: orange; /* orange */
} }
@ -221,7 +221,7 @@
<table class="table times-table" data-bind="event: { change: selectedTask().onChange }" style="margin-bottom: 0px !important;"> <table class="table times-table" data-bind="event: { change: selectedTask().onChange }" style="margin-bottom: 0px !important;">
<tbody data-bind="foreach: selectedTask().time_log"> <tbody data-bind="foreach: selectedTask().sortedTimes">
<tr data-bind="event: { mouseover: onMouseOver, mouseout: onMouseOut }"> <tr data-bind="event: { mouseover: onMouseOver, mouseout: onMouseOut }">
<td style="padding: 0 6px 10px 0"> <td style="padding: 0 6px 10px 0">
{!! Former::text('date') {!! Former::text('date')

View File

@ -385,6 +385,10 @@
task.setProject(self.selectedProject()); task.setProject(self.selectedProject());
} else if (self.selectedClient()) { } else if (self.selectedClient()) {
task.setClient(self.selectedClient()); task.setClient(self.selectedClient());
setTimeout(function() {
$('select#client_id').trigger('change');
}, 1);
} else { } else {
task.description(self.filter()); task.description(self.filter());
} }
@ -800,6 +804,19 @@
return self.public_id(); return self.public_id();
}); });
self.sortedTimes = ko.computed(function() {
var times = self.time_log();
times.sort(function (left, right) {
if (! left.startTime()) {
return 1;
} else if (! right.startTime()) {
return -1;
}
return left.startTime() - right.startTime();
});
return times;
});
self.isRunning = ko.computed(function() { self.isRunning = ko.computed(function() {
var timeLog = self.time_log(); var timeLog = self.time_log();
if (! timeLog.length) { if (! timeLog.length) {