mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 05:24:29 -04:00
Working on the time tracker
This commit is contained in:
parent
43cbb7e3cd
commit
026d440831
@ -215,7 +215,7 @@
|
|||||||
<label>{{ trans('texts.times') }}</label>
|
<label>{{ trans('texts.times') }}</label>
|
||||||
|
|
||||||
|
|
||||||
<table class="table times-table" 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().time_log">
|
||||||
<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">
|
||||||
|
@ -50,19 +50,6 @@
|
|||||||
var value = valueAccessor();
|
var value = valueAccessor();
|
||||||
var seconds = $(element).timepicker('getSecondsFromMidnight');
|
var seconds = $(element).timepicker('getSecondsFromMidnight');
|
||||||
value(seconds);
|
value(seconds);
|
||||||
/*
|
|
||||||
var field = $(element).attr('name');
|
|
||||||
var time = 0;
|
|
||||||
if (field == 'duration') {
|
|
||||||
time = $(element).timepicker('getSecondsFromMidnight');
|
|
||||||
} else {
|
|
||||||
var dateTime = $(element).timepicker('getTime');
|
|
||||||
if (dateTime) {
|
|
||||||
time = dateTime.getTime() / 1000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
value(time);
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
update: function (element, valueAccessor) {
|
update: function (element, valueAccessor) {
|
||||||
@ -75,6 +62,8 @@
|
|||||||
} else {
|
} else {
|
||||||
$(element).timepicker('setTime', new Date(value * 1000));
|
$(element).timepicker('setTime', new Date(value * 1000));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$(element).val('');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field == 'start_time') {
|
if (field == 'start_time') {
|
||||||
@ -661,24 +650,31 @@
|
|||||||
var times = data.time_log instanceof Array ? data.time_log : JSON.parse(data.time_log);
|
var times = data.time_log instanceof Array ? data.time_log : JSON.parse(data.time_log);
|
||||||
ko.mapping.fromJS(data, self.mapping, this);
|
ko.mapping.fromJS(data, self.mapping, this);
|
||||||
self.time_log.removeAll();
|
self.time_log.removeAll();
|
||||||
|
console.log('removing all...');
|
||||||
for (var i=0; i<times.length; i++) {
|
for (var i=0; i<times.length; i++) {
|
||||||
self.time_log.push(new TimeModel(times[i]));
|
self.time_log.push(new TimeModel(times[i]));
|
||||||
}
|
}
|
||||||
|
//self.addTime();
|
||||||
self.checkForEmpty();
|
self.checkForEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.checkForEmpty = function() {
|
self.checkForEmpty = function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
console.log('checking..');
|
||||||
var hasEmpty = false;
|
var hasEmpty = false;
|
||||||
var lastTime = 0;
|
var times = self.time_log();
|
||||||
for (var i=0; i<self.time_log().length; i++) {
|
for (var i=0; i<times.length; i++) {
|
||||||
var timeLog = self.time_log()[i];
|
var timeLog = times[i];
|
||||||
if (timeLog.isEmpty() || timeLog.isRunning()) {
|
console.log('end time: ' + timeLog.endTime());
|
||||||
|
if (! timeLog.endTime()) {
|
||||||
hasEmpty = true;
|
hasEmpty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasEmpty) {
|
if (! hasEmpty) {
|
||||||
|
console.log('addng blank');
|
||||||
self.addTime();
|
self.addTime();
|
||||||
}
|
}
|
||||||
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.sortValue = function(field) {
|
self.sortValue = function(field) {
|
||||||
@ -714,6 +710,10 @@
|
|||||||
return self.isHovered();
|
return self.isHovered();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.onChange = function() {
|
||||||
|
self.checkForEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
self.onMouseOver = function() {
|
self.onMouseOver = function() {
|
||||||
self.isHovered(true);
|
self.isHovered(true);
|
||||||
}
|
}
|
||||||
@ -880,6 +880,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.seconds = function(total) {
|
self.seconds = function(total) {
|
||||||
|
//model.clock(); // bind to the clock
|
||||||
if (! self.time_log().length) {
|
if (! self.time_log().length) {
|
||||||
return moment.duration(0);
|
return moment.duration(0);
|
||||||
}
|
}
|
||||||
@ -913,7 +914,6 @@
|
|||||||
self.removeTime = function(time) {
|
self.removeTime = function(time) {
|
||||||
model.formChanged(true);
|
model.formChanged(true);
|
||||||
self.time_log.remove(time);
|
self.time_log.remove(time);
|
||||||
self.checkForEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user