Working on task kanban

This commit is contained in:
Hillel Coren 2017-12-19 18:33:41 +02:00
parent 6fba242ac5
commit f1b9bd3d8a
3 changed files with 25 additions and 1 deletions

View File

@ -100,6 +100,20 @@ class TaskKanbanController extends BaseController
->where('sort_order', '>', $status->sort_order) ->where('sort_order', '>', $status->sort_order)
->decrement('sort_order'); ->decrement('sort_order');
$firstStatus = TaskStatus::scope()
->orderBy('sort_order')
->first();
// Move linked tasks to the end of the first status
if ($firstStatus) {
$firstCount = $firstStatus->tasks->count();
Task::scope()
->where('task_status_id', '=', $status->id)
->increment('task_status_sort_order', $firstCount, [
'task_status_id' => $firstStatus->id
]);
}
return response()->json(['message' => RESULT_SUCCESS]); return response()->json(['message' => RESULT_SUCCESS]);
} }

View File

@ -37,4 +37,13 @@ class TaskStatus extends EntityModel
{ {
return ENTITY_TASK_STATUS; return ENTITY_TASK_STATUS;
} }
/**
* @return mixed
*/
public function tasks()
{
return $this->hasMany('App\Models\Task')->orderBy('task_status_sort_order');
}
} }

View File

@ -299,7 +299,8 @@
sweetConfirm(function() { sweetConfirm(function() {
var url = '{{ url('/task_statuses') }}/' + self.public_id(); var url = '{{ url('/task_statuses') }}/' + self.public_id();
model.ajax('delete', url, null, function(response) { model.ajax('delete', url, null, function(response) {
model.statuses.remove(self); //model.statuses.remove(self);
location.reload();
}) })
}, "{{ trans('texts.archive_status')}}"); }, "{{ trans('texts.archive_status')}}");
} }