Working on the time tracker

This commit is contained in:
Hillel Coren 2017-10-01 12:01:31 +03:00
parent 40bb7d6b35
commit 1189d7c8e8
2 changed files with 32 additions and 6 deletions

View File

@ -127,7 +127,7 @@
} }
.ui-timepicker-wrapper { .ui-timepicker-wrapper {
width: 10em !important; width: 200px !important;
} }
.footer { .footer {
@ -217,28 +217,35 @@
<table class="table times-table" style="margin-bottom: 0px !important;"> <table class="table times-table" style="margin-bottom: 0px !important;">
<tbody data-bind="foreach: selectedTask().time_log"> <tbody data-bind="foreach: selectedTask().time_log">
<tr data-bindx="event: { mouseover: showActions, mouseout: hideActions }"> <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')
->placeholder('date')
->data_bind("datepicker: startDate, valueUpdate: 'afterkeydown'") ->data_bind("datepicker: startDate, valueUpdate: 'afterkeydown'")
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT)) ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))
->raw() !!} ->raw() !!}
</td> </td>
<td style="padding: 0 6px 10px 6px"> <td style="padding: 0 6px 10px 6px">
{!! Former::text('start_time') {!! Former::text('start_time')
->placeholder('start_time')
->data_bind("timepicker: startTime, timepickerOptions: {scrollDefault: 'now', timeFormat: '" . ($account->military_time ? 'H:i:s' : 'g:i:s A') . "'}") ->data_bind("timepicker: startTime, timepickerOptions: {scrollDefault: 'now', timeFormat: '" . ($account->military_time ? 'H:i:s' : 'g:i:s A') . "'}")
->raw() !!} ->raw() !!}
</td> </td>
<td style="padding: 0 6px 10px 6px"> <td style="padding: 0 6px 10px 6px">
{!! Former::text('end_time') {!! Former::text('end_time')
->placeholder('end_time')
->data_bind("timepicker: endTime, timepickerOptions: {scrollDefault: 'now', timeFormat: '" . ($account->military_time ? 'H:i:s' : 'g:i:s A') . "'}") ->data_bind("timepicker: endTime, timepickerOptions: {scrollDefault: 'now', timeFormat: '" . ($account->military_time ? 'H:i:s' : 'g:i:s A') . "'}")
->raw() !!} ->raw() !!}
</td> </td>
<td style="padding: 0 0 10px 6px"> <td style="padding: 0 0 10px 6px">
{!! Former::text('duration') {!! Former::text('duration')
->placeholder('duration')
->data_bind("timepicker: duration, timepickerOptions: {timeFormat: 'H:i:s', showAsDuration: true}") ->data_bind("timepicker: duration, timepickerOptions: {timeFormat: 'H:i:s', showAsDuration: true}")
->raw() !!} ->raw() !!}
</td> </td>
<td style="width:38px; padding-top: 0px; padding-right: 8px">
<i style="cursor:pointer;float:right" data-bind="click: $root.selectedTask().removeTime, visible: actionButtonVisible" class="fa fa-minus-circle redlink" title="{{ trans('texts.remove') }}"/>
</td>
<!-- <!--
<td style="padding: 0px 12px 12px 0 !important"> <td style="padding: 0px 12px 12px 0 !important">

View File

@ -73,10 +73,11 @@
} }
} }
//console.log(field + ': ' + value);
if (field == 'start_time') { if (field == 'start_time') {
setTimeout(function() {
$input = $(element).closest('td').next('td').find('input').show(); $input = $(element).closest('td').next('td').find('input').show();
$input.timepicker('option', 'durationTime', $(element).val()); $input.timepicker('option', 'durationTime', $(element).val());
}, 1);
} }
} }
}; };
@ -894,6 +895,12 @@
var duration = self.seconds(false); var duration = self.seconds(false);
return Math.floor(duration.asHours()) + moment.utc(duration.asMilliseconds()).format(":mm:ss"); return Math.floor(duration.asHours()) + moment.utc(duration.asMilliseconds()).format(":mm:ss");
}); });
self.removeTime = function(time) {
console.log('removed..');
model.formChanged(true);
self.time_log.remove(time);
}
} }
function ProjectModel(data) { function ProjectModel(data) {
@ -963,15 +970,27 @@
var self = this; var self = this;
self.startTime = ko.observable(0); self.startTime = ko.observable(0);
self.endTime = ko.observable(0); self.endTime = ko.observable(0);
self.actionsVisible = ko.observable(false);
self.isStartValid = ko.observable(true); self.isStartValid = ko.observable(true);
self.isEndValid = ko.observable(true); self.isEndValid = ko.observable(true);
self.isHovered = ko.observable(false);
if (data) { if (data) {
self.startTime(data[0]); self.startTime(data[0]);
self.endTime(data[1]); self.endTime(data[1]);
}; };
self.actionButtonVisible = ko.computed(function() {
return self.isHovered() && ! self.isEmpty();
});
self.onMouseOver = function() {
self.isHovered(true);
}
self.onMouseOut = function() {
self.isHovered(false);
}
self.startDate = ko.computed({ self.startDate = ko.computed({
read: function () { read: function () {
return self.startTime(); return self.startTime();