mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Working on task kanban
This commit is contained in:
parent
ccf91ea1e0
commit
81dec9156f
@ -90,13 +90,42 @@ class TaskKanbanController extends BaseController
|
||||
*/
|
||||
public function deleteStatus($publicId)
|
||||
{
|
||||
$status = TaskStatus::scope($publicId)->first();
|
||||
|
||||
if ($status) {
|
||||
$status = TaskStatus::scope($publicId)->firstOrFail();
|
||||
$status->delete();
|
||||
}
|
||||
|
||||
return response()->json(['message' => RESULT_SUCCESS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $publicId
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function updateTask($publicId)
|
||||
{
|
||||
$task = Task::scope($publicId)->firstOrFail();
|
||||
|
||||
$origStatusId = $task->task_status_id;
|
||||
$origSortOrder = $task->task_status_sort_order;
|
||||
|
||||
$newStatusId = request('task_status_id');
|
||||
$newSortOrder = request('task_status_sort_order');
|
||||
|
||||
Task::scope()
|
||||
->where('task_status_id', '=', $origStatusId)
|
||||
->where('task_status_sort_order', '>', $origSortOrder)
|
||||
->decrement('task_status_sort_order');
|
||||
|
||||
Task::scope()
|
||||
->where('task_status_id', '=', $newStatusId)
|
||||
->where('task_status_sort_order', '>=', $newSortOrder)
|
||||
->increment('task_status_sort_order');
|
||||
|
||||
$task->task_status_id = request('task_status_id');
|
||||
$task->task_status_sort_order = $newSortOrder;
|
||||
$task->save();
|
||||
|
||||
return response()->json($task);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -230,8 +230,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
self.onDragged = function() {
|
||||
|
||||
self.onStatusDragged = function() {
|
||||
console.log('onStatusDragged..');
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,8 +274,20 @@
|
||||
self.is_editing_status(false);
|
||||
}
|
||||
|
||||
self.onDragged = function() {
|
||||
self.onTaskDragged = function(dragged) {
|
||||
console.log('onTaskDragged..');
|
||||
//console.log(dragged);
|
||||
var task = dragged.item;
|
||||
task.task_status_sort_order(dragged.targetIndex);
|
||||
task.task_status_id(self.public_id());
|
||||
|
||||
var url = '{{ url('/task_status_order') }}/' + task.public_id();
|
||||
var data = task.toData();
|
||||
console.log(data);
|
||||
//return;
|
||||
model.ajax('put', url, data, function(response) {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
self.archiveStatus = function() {
|
||||
@ -347,10 +359,6 @@
|
||||
$('.kanban-column-row.editing textarea').focus();
|
||||
}
|
||||
|
||||
self.onDragged = function() {
|
||||
|
||||
}
|
||||
|
||||
self.toData = function() {
|
||||
return 'description=' + encodeURIComponent(self.description()) +
|
||||
'&task_status_id=' + self.task_status_id() +
|
||||
@ -480,7 +488,7 @@
|
||||
</script>
|
||||
|
||||
<div class="kanban" style="display: none">
|
||||
<div data-bind="sortable: { data: statuses, as: 'status', afterMove: onDragged, allowDrop: true, connectClass: 'connect-column' }" style="float:left">
|
||||
<div data-bind="sortable: { data: statuses, as: 'status', afterMove: onStatusDragged, allowDrop: true, connectClass: 'connect-column' }" style="float:left">
|
||||
<div class="well kanban-column">
|
||||
|
||||
<div class="kanban-column-header" data-bind="css: { editing: is_editing_status }, event: { mouseover: onHeaderMouseOver, mouseout: onHeaderMouseOut }">
|
||||
@ -494,7 +502,7 @@
|
||||
</div><br/>
|
||||
</div>
|
||||
|
||||
<div data-bind="sortable: { data: tasks, as: 'task', afterMove: onDragged, allowDrop: true, connectClass: 'connect-row' }" style="min-height:8px">
|
||||
<div data-bind="sortable: { data: tasks, as: 'task', afterMove: onTaskDragged, allowDrop: true, connectClass: 'connect-row' }" style="min-height:8px">
|
||||
<div class="kanban-column-row" data-bind="css: { editing: is_editing_task }, visible: task.matchesFilter($root.filter())">
|
||||
<div data-bind="event: { click: startEditTask }">
|
||||
<div class="view panel">
|
||||
|
@ -147,6 +147,7 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
|
||||
Route::post('task_statuses', 'TaskKanbanController@storeStatus');
|
||||
Route::put('task_statuses/{task_status_id}', 'TaskKanbanController@updateStatus');
|
||||
Route::delete('task_statuses/{task_status_id}', 'TaskKanbanController@deleteStatus');
|
||||
Route::put('task_status_order/{task_id}', 'TaskKanbanController@updateTask');
|
||||
Route::resource('tasks', 'TaskController');
|
||||
Route::get('api/tasks/{client_id?}', 'TaskController@getDatatable');
|
||||
Route::get('tasks/create/{client_id?}/{project_id?}', 'TaskController@create');
|
||||
|
Loading…
Reference in New Issue
Block a user