mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on time tracker
This commit is contained in:
parent
6dedc4ba68
commit
208d422d76
@ -124,7 +124,7 @@
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<center style="padding-top: 30px">
|
<center style="padding-top: 30px">
|
||||||
<span data-bind="visible: !!selectedTask().public_id">
|
<span data-bind="visible: selectedTask().isNew">
|
||||||
{!! DropdownButton::normal(trans('texts.archive'))
|
{!! DropdownButton::normal(trans('texts.archive'))
|
||||||
->withAttributes([
|
->withAttributes([
|
||||||
'class' => 'archive-dropdown',
|
'class' => 'archive-dropdown',
|
||||||
@ -138,7 +138,7 @@
|
|||||||
{!! Button::normal(trans('texts.cancel'))
|
{!! Button::normal(trans('texts.cancel'))
|
||||||
->appendIcon(Icon::create('remove-circle'))
|
->appendIcon(Icon::create('remove-circle'))
|
||||||
->withAttributes([
|
->withAttributes([
|
||||||
'data-bind' => 'click: onCancelClick, visible: !selectedTask().public_id',
|
'data-bind' => 'click: onCancelClick, visible: selectedTask().isNew',
|
||||||
])
|
])
|
||||||
->large() !!}
|
->large() !!}
|
||||||
|
|
||||||
@ -208,12 +208,17 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = $('#taskForm').serialize();
|
var data = $('#taskForm').serialize();
|
||||||
var times = model.selectedTask().times();
|
var task = model.selectedTask();
|
||||||
data += '&time_log=' + JSON.stringify(times);
|
data += '&time_log=' + JSON.stringify(task.times());
|
||||||
var url = '{{ url('/tasks') }}';
|
var url = '{{ url('/tasks') }}';
|
||||||
|
var method = 'post';
|
||||||
|
if (task.public_id()) {
|
||||||
|
method = 'put';
|
||||||
|
url += '/' + task.public_id();
|
||||||
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'post',
|
type: method,
|
||||||
data: data,
|
data: data,
|
||||||
url: url,
|
url: url,
|
||||||
accepts: {
|
accepts: {
|
||||||
@ -222,8 +227,11 @@
|
|||||||
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();
|
||||||
self.selectedTask().update(response);
|
self.selectedTask().update(response);
|
||||||
self.addTask(self.selectedTask());
|
if (isNew) {
|
||||||
|
self.addTask(self.selectedTask());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -364,6 +372,7 @@
|
|||||||
|
|
||||||
function TaskModel(data) {
|
function TaskModel(data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
self.public_id = ko.observable();
|
||||||
self.description = ko.observable('test');
|
self.description = ko.observable('test');
|
||||||
self.time_log = ko.observableArray();
|
self.time_log = ko.observableArray();
|
||||||
self.client_id = ko.observable();
|
self.client_id = ko.observable();
|
||||||
@ -387,7 +396,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'ignore': [
|
'ignore': [
|
||||||
'time_log'
|
'time_log',
|
||||||
|
'client_id',
|
||||||
|
'project_id',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,6 +416,10 @@
|
|||||||
self.update(data);
|
self.update(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.isNew = function() {
|
||||||
|
return ! self.public_id();
|
||||||
|
}
|
||||||
|
|
||||||
self.showActionButton = function() {
|
self.showActionButton = function() {
|
||||||
self.actionButtonVisible(true);
|
self.actionButtonVisible(true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user