Working on time tracker

This commit is contained in:
Hillel Coren 2017-09-28 12:34:02 +03:00
parent 657eb454d9
commit b98dfa254d
2 changed files with 32 additions and 15 deletions

View File

@ -101,6 +101,16 @@
.list-group-item-type7:before { background-color: #a87821; } .list-group-item-type7:before { background-color: #a87821; }
.list-group-item-type8:before { background-color: #676767; } .list-group-item-type8:before { background-color: #676767; }
.list-group-item-running:after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 6px;
content: "";
background-color: #c9302c;
}
body { body {
margin-bottom: 60px; margin-bottom: 60px;
} }
@ -254,7 +264,7 @@
</div> </div>
<div data-bind="foreach: filteredTasks"> <div data-bind="foreach: filteredTasks">
<a href="#" data-bind="click: $parent.selectTask, event: { mouseover: showActionButton, mouseout: hideActionButton }, css: listItemState" <a href="#" data-bind="click: $parent.selectTask, event: { mouseover: onMouseOver, mouseout: onMouseOut }, css: listItemState"
class="list-group-item"> class="list-group-item">
<div class="pull-right" style="text-align:right;"> <div class="pull-right" style="text-align:right;">
<div data-bind="visible: actionButtonVisible()" <div data-bind="visible: actionButtonVisible()"

View File

@ -424,7 +424,7 @@
self.project_id = ko.observable(); self.project_id = ko.observable();
self.client = ko.observable(); self.client = ko.observable();
self.project = ko.observable(); self.project = ko.observable();
self.actionButtonVisible = ko.observable(false); self.isHovered = ko.observable(false);
self.created_at = ko.observable(moment().format('YYYY-MM-DD HH:mm:ss')); self.created_at = ko.observable(moment().format('YYYY-MM-DD HH:mm:ss'));
self.mapping = { self.mapping = {
@ -603,16 +603,29 @@
return self.public_id(); return self.public_id();
}); });
self.isRunning = ko.computed(function() {
var timeLog = self.time_log();
if (! timeLog.length) {
return false;
}
var time = timeLog[timeLog.length-1];
return time.isRunning();
});
self.actionButtonVisible = ko.computed(function() {
return self.isHovered();
});
self.hasFocus = function() { self.hasFocus = function() {
console.log('focused... ' + self.public_id()); console.log('focused... ' + self.public_id());
} }
self.showActionButton = function() { self.onMouseOver = function() {
self.actionButtonVisible(true); self.isHovered(true);
} }
self.hideActionButton = function() { self.onMouseOut = function() {
self.actionButtonVisible(false); self.isHovered(false);
} }
self.addTime = function(time) { self.addTime = function(time) {
@ -703,6 +716,9 @@
str += ' changed fade-color'; str += ' changed fade-color';
} }
} }
if (self.isRunning()) {
str += ' list-group-item-running';
}
if (! self.project()) { if (! self.project()) {
return str; return str;
} }
@ -712,15 +728,6 @@
}); });
self.isRunning = ko.computed(function() {
var timeLog = self.time_log();
if (! timeLog.length) {
return false;
}
var time = timeLog[timeLog.length-1];
return time.isRunning();
});
self.clientName = ko.computed(function() { self.clientName = ko.computed(function() {
return self.client() ? self.client().displayName() : ''; return self.client() ? self.client().displayName() : '';
}); });