Working on time tracker

This commit is contained in:
Hillel Coren 2017-09-19 22:08:22 +03:00
parent ad33481c5e
commit ebff337a02

View File

@ -153,7 +153,7 @@
<!-- Task List --> <!-- Task List -->
<div class="list-group col-sm-5 col-sm-pull-7" data-bind="foreach: filteredTasks"> <div class="list-group col-sm-5 col-sm-pull-7" data-bind="foreach: filteredTasks">
<a href="#" data-bind="click: $parent.selectTask, hasFocus: $data == $parent.selectedTask(), event: { mouseover: showActionButton, mouseout: hideActionButton }, css: projectColor" <a href="#" data-bind="click: $parent.selectTask, event: { mouseover: showActionButton, mouseout: hideActionButton }, css: projectColor"
class="list-group-item" stylex="white-space: nowrap; text-overflow: ellipsis; overflow: hidden;"> class="list-group-item" stylex="white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">
<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()"
@ -223,10 +223,10 @@
success: function(response) { success: function(response) {
console.log(response); console.log(response);
//var task = new TaskModel(response); //var task = new TaskModel(response);
var isNew = self.selectedTask().isNew(); var task = self.selectedTask();
self.selectedTask().update(response); task.update(response);
if (isNew) { if (task.isNew()) {
self.addTask(self.selectedTask()); self.addTask(task);
} }
}, },
}); });
@ -325,13 +325,6 @@
self.placeholder = ko.computed(function() { self.placeholder = ko.computed(function() {
return "{{ trans('texts.what_are_you_working_on') }}"; return "{{ trans('texts.what_are_you_working_on') }}";
/*
if (self.selectedTask() && self.selectedTask().description) {
return self.selectedTask().description.truncated();
} else {
return "{{ trans('texts.what_are_you_working_on') }}";
}
*/
}); });
self.filteredTasks = ko.computed(function() { self.filteredTasks = ko.computed(function() {
@ -360,12 +353,22 @@
self.tasks.push(task); self.tasks.push(task);
} }
self.removeTask = function(task) {
console.log('remove:');
console.log(task);
self.tasks.remove(task);
}
self.selectTask = function(task) { self.selectTask = function(task) {
// if a client is selected the project list will be filtered // if a client is selected the project list will be filtered
// this prevents the new task's project from being show // this prevents the new task's project from being show
// to fix it we're clearing the list and then firing a // to fix it we're clearing the list and then firing a
// client change event to re-filter the list // client change event to re-filter the list
refreshProjectList(true); refreshProjectList(true);
//var clone = new TaskModel(task.data);
//clone.original = task;
self.selectedTask(task); self.selectedTask(task);
if (! task.project()) { if (! task.project()) {
$('select#client_id').trigger('change'); $('select#client_id').trigger('change');
@ -406,6 +409,7 @@
} }
self.update = function(data) { self.update = function(data) {
self.data = data;
var times = JSON.parse(data.time_log); var times = JSON.parse(data.time_log);
data.time_log = false; data.time_log = false;
ko.mapping.fromJS(data, self.mapping, this); ko.mapping.fromJS(data, self.mapping, this);