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
16e2f261e4
commit
858724ff94
@ -242,7 +242,11 @@ class TaskController extends BaseController
|
|||||||
return self::bulk();
|
return self::bulk();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Redirect::to("tasks/{$task->public_id}/edit");
|
if (request()->wantsJson()) {
|
||||||
|
return $task->toJson();
|
||||||
|
} else {
|
||||||
|
return Redirect::to("tasks/{$task->public_id}/edit");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +117,10 @@ class TaskRepository extends BaseRepository
|
|||||||
|
|
||||||
if (isset($data['client'])) {
|
if (isset($data['client'])) {
|
||||||
$task->client_id = $data['client'] ? Client::getPrivateId($data['client']) : null;
|
$task->client_id = $data['client'] ? Client::getPrivateId($data['client']) : null;
|
||||||
|
} elseif (isset($data['client_id'])) {
|
||||||
|
$task->client_id = $data['client_id'] ? Client::getPrivateId($data['client_id']) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data['project_id'])) {
|
if (isset($data['project_id'])) {
|
||||||
$task->project_id = $data['project_id'] ? Project::getPrivateId($data['project_id']) : null;
|
$task->project_id = $data['project_id'] ? Project::getPrivateId($data['project_id']) : null;
|
||||||
}
|
}
|
||||||
@ -134,10 +137,6 @@ class TaskRepository extends BaseRepository
|
|||||||
$timeLog = [];
|
$timeLog = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($data['client_id'])) {
|
|
||||||
$task->client_id = Client::getPrivateId($data['client_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
array_multisort($timeLog);
|
array_multisort($timeLog);
|
||||||
|
|
||||||
if (isset($data['action'])) {
|
if (isset($data['action'])) {
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
|
button .glyphicon {
|
||||||
|
vertical-align: text-top;
|
||||||
|
}
|
||||||
|
|
||||||
.panel-body label:not(:first-child) {
|
.panel-body label:not(:first-child) {
|
||||||
margin-top: 20px !important;
|
margin-top: 20px !important;
|
||||||
}
|
}
|
||||||
@ -75,7 +79,7 @@
|
|||||||
<!-- Navbar Filter -->
|
<!-- Navbar Filter -->
|
||||||
<div class="input-group input-group-lg">
|
<div class="input-group input-group-lg">
|
||||||
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-time"></span></span>
|
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-time"></span></span>
|
||||||
<input type="text" class="form-control search" autocomplete="off" autofocus="autofocus"
|
<input type="search" class="form-control search" autocomplete="off" autofocus="autofocus"
|
||||||
data-bind="event: { focus: onFilterFocus, input: onFilterChanged, keypress: onFilterKeyPress }, value: filter, valueUpdate: 'afterkeydown', attr: {placeholder: placeholder}">
|
data-bind="event: { focus: onFilterFocus, input: onFilterChanged, keypress: onFilterKeyPress }, value: filter, valueUpdate: 'afterkeydown', attr: {placeholder: placeholder}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -100,19 +104,50 @@
|
|||||||
<div class="well" data-bind="visible: selectedTask" style="padding-bottom:0px; margin-bottom:0px; display:none;">
|
<div class="well" data-bind="visible: selectedTask" style="padding-bottom:0px; margin-bottom:0px; display:none;">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{!! Former::select('client_id')
|
<form id="taskForm">
|
||||||
->addOption('', '')
|
<span class="client-select">
|
||||||
->label('client')
|
{!! Former::select('client_id')
|
||||||
->data_bind("dropdown: selectedTask().client_id")
|
->addOption('', '')
|
||||||
->addGroupClass('client-select') !!}
|
->label('client')
|
||||||
{!! Former::select('project_id')
|
->data_bind("dropdown: selectedTask().client_id") !!}
|
||||||
->addOption('', '')
|
</span>
|
||||||
->addGroupClass('project-select')
|
<span class="project-select">
|
||||||
->data_bind("dropdown: selectedTask().project_id")
|
{!! Former::select('project_id')
|
||||||
->label(trans('texts.project')) !!}
|
->addOption('', '')
|
||||||
{!! Former::textarea('description')
|
->data_bind("dropdown: selectedTask().project_id")
|
||||||
->data_bind("value: selectedTask().description, valueUpdate: 'afterkeydown'")
|
->label(trans('texts.project')) !!}
|
||||||
->rows(4) !!}
|
</span>
|
||||||
|
{!! Former::textarea('description')
|
||||||
|
->data_bind("value: selectedTask().description, valueUpdate: 'afterkeydown'")
|
||||||
|
->rows(4) !!}
|
||||||
|
|
||||||
|
<center style="padding-top: 30px">
|
||||||
|
<span data-bind="visible: !!selectedTask().public_id">
|
||||||
|
{!! DropdownButton::normal(trans('texts.archive'))
|
||||||
|
->withAttributes([
|
||||||
|
'class' => 'archive-dropdown',
|
||||||
|
])
|
||||||
|
->large()
|
||||||
|
->withContents([
|
||||||
|
['label' => trans('texts.delete_task'), 'url' => '#'],
|
||||||
|
]
|
||||||
|
)->split() !!}
|
||||||
|
</span>
|
||||||
|
{!! Button::normal(trans('texts.cancel'))
|
||||||
|
->appendIcon(Icon::create('remove-circle'))
|
||||||
|
->withAttributes([
|
||||||
|
'data-bind' => 'click: onCancelClick, visible: !selectedTask().public_id',
|
||||||
|
])
|
||||||
|
->large() !!}
|
||||||
|
|
||||||
|
{!! Button::success(trans('texts.save'))
|
||||||
|
->large()
|
||||||
|
->appendIcon(Icon::create('floppy-disk'))
|
||||||
|
->withAttributes([
|
||||||
|
'data-bind' => 'click: onSaveClick',
|
||||||
|
]) !!}
|
||||||
|
</center>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -127,7 +162,7 @@
|
|||||||
data-bindx="style : { visibility : actionButtonVisible() ? '' : 'hidden' }">
|
data-bindx="style : { visibility : actionButtonVisible() ? '' : 'hidden' }">
|
||||||
|
|
||||||
<button type="button" data-bind="css: startClass, click: onStartClick"
|
<button type="button" data-bind="css: startClass, click: onStartClick"
|
||||||
class="btn btn-sm" style="padding-left:0px; padding-right: 12px; margin-top:5px;">
|
class="btn btn-sm" style="padding-left:0px; padding-right: 12px; padding-bottom: 6px; margin-top:5px;">
|
||||||
<span data-bind="css: startIcon"></span>
|
<span data-bind="css: startIcon"></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -166,6 +201,32 @@
|
|||||||
self.selectedTask = ko.observable(false);
|
self.selectedTask = ko.observable(false);
|
||||||
self.clock = ko.observable(0);
|
self.clock = ko.observable(0);
|
||||||
|
|
||||||
|
self.onSaveClick = function() {
|
||||||
|
var data = $('#taskForm').serialize();
|
||||||
|
var url = '{{ url('/tasks') }}';
|
||||||
|
$.ajax({
|
||||||
|
dataType: 'json',
|
||||||
|
type: 'post',
|
||||||
|
data: data,
|
||||||
|
url: url,
|
||||||
|
accepts: {
|
||||||
|
json: 'application/json'
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
console.log(response);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
self.onCancelClick = function() {
|
||||||
|
sweetConfirm(function() {
|
||||||
|
self.selectedTask(false);
|
||||||
|
$('.search').focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
self.onFilterFocus = function(data) {
|
self.onFilterFocus = function(data) {
|
||||||
self.selectedTask(false);
|
self.selectedTask(false);
|
||||||
}
|
}
|
||||||
@ -200,9 +261,9 @@
|
|||||||
var task = new TaskModel();
|
var task = new TaskModel();
|
||||||
task.description(self.filter());
|
task.description(self.filter());
|
||||||
task.addTime(time);
|
task.addTime(time);
|
||||||
self.addTask(task);
|
|
||||||
self.selectedTask(task);
|
self.selectedTask(task);
|
||||||
self.filter('');
|
self.filter('');
|
||||||
|
$('.client-select input.form-control').focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,11 +303,14 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.placeholder = ko.computed(function() {
|
self.placeholder = ko.computed(function() {
|
||||||
|
return "{{ trans('texts.what_are_you_working_on') }}";
|
||||||
|
/*
|
||||||
if (self.selectedTask() && self.selectedTask().description) {
|
if (self.selectedTask() && self.selectedTask().description) {
|
||||||
return self.selectedTask().description.truncated();
|
return self.selectedTask().description.truncated();
|
||||||
} else {
|
} else {
|
||||||
return "{{ trans('texts.what_are_you_working_on') }}";
|
return "{{ trans('texts.what_are_you_working_on') }}";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
self.filteredTasks = ko.computed(function() {
|
self.filteredTasks = ko.computed(function() {
|
||||||
@ -263,7 +327,9 @@
|
|||||||
|
|
||||||
// sort the data
|
// sort the data
|
||||||
tasks.sort(function (left, right) {
|
tasks.sort(function (left, right) {
|
||||||
return right.firstTime().order() - left.firstTime().order()
|
right = right.firstTime() ? right.firstTime().order() : right.createdAt();
|
||||||
|
left = left.firstTime() ? left.firstTime().order() : left.createdAt();
|
||||||
|
return right - left;
|
||||||
});
|
});
|
||||||
|
|
||||||
return tasks;
|
return tasks;
|
||||||
@ -288,6 +354,7 @@
|
|||||||
self.client = ko.observable();
|
self.client = ko.observable();
|
||||||
self.project = ko.observable();
|
self.project = ko.observable();
|
||||||
self.actionButtonVisible = ko.observable(false);
|
self.actionButtonVisible = ko.observable(false);
|
||||||
|
self.created_at = ko.observable(moment().unix());
|
||||||
|
|
||||||
self.mapping = {
|
self.mapping = {
|
||||||
'client': {
|
'client': {
|
||||||
@ -396,6 +463,10 @@
|
|||||||
return truncate(self.description(), self.actionButtonVisible() ? 60 : 80);
|
return truncate(self.description(), self.actionButtonVisible() ? 60 : 80);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.createdAt = function() {
|
||||||
|
return moment(self.created_at()).unix();
|
||||||
|
}
|
||||||
|
|
||||||
self.firstTime = function() {
|
self.firstTime = function() {
|
||||||
return self.time_log()[0];
|
return self.time_log()[0];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user