1
0
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:
Hillel Coren 2017-12-19 15:52:24 +02:00
parent 7be486664f
commit 2eedbc008f
2 changed files with 21 additions and 7 deletions

View File

@ -15,13 +15,13 @@ class TaskKanbanController extends BaseController
public function index()
{
$tasks = Task::scope()->with(['project', 'client', 'task_status'])->orderBy('task_status_sort_order')->get();
$stauses = TaskStatus::scope()->orderBy('sort_order')->get();
$statuses = TaskStatus::scope()->orderBy('sort_order')->get();
$projects = Project::scope()->get();
$clients = Client::scope()->get();
// check initial statuses exist
if (! $stauses->count()) {
$stauses = [];
if (! $statuses->count()) {
$statuses = collect([]);
$defaults = [
'backlog',
'ready_to_do',
@ -33,13 +33,13 @@ class TaskKanbanController extends BaseController
$status->name = trans('texts.' . $defaults[$i]);
$status->sort_order = $i;
$status->save();
$stauses[] = $status;
$statuses[] = $status;
}
}
$data = [
'title' => trans('texts.kanban'),
'statuses' => $stauses,
'statuses' => $statuses,
'tasks' => $tasks,
'clients' => $clients,
'projects' => $projects,
@ -68,6 +68,20 @@ class TaskKanbanController extends BaseController
public function updateStatus($publicId)
{
$status = TaskStatus::scope($publicId)->firstOrFail();
if ($status->sort_order != request('sort_order')) {
$origSortOrder = $status->sort_order;
$newSortOrder = request('sort_order');
TaskStatus::scope()
->where('sort_order', '>', $origSortOrder)
->decrement('sort_order');
TaskStatus::scope()
->where('sort_order', '>=', $newSortOrder)
->increment('sort_order');
}
$status->fill(request()->all());
$status->save();

View File

@ -235,8 +235,8 @@
var status = dragged.item;
status.sort_order(dragged.targetIndex);
var url = '{{ url('/task_status') }}/' + status.public_id();
var data = task.toData();
var url = '{{ url('/task_statuses') }}/' + status.public_id();
var data = status.toData();
model.ajax('put', url, data, function(response) {
// do nothing