2019-07-30 16:50:10 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function renderChecklist($check, $level = 0)
|
|
|
|
{
|
|
|
|
$user = auth()->getUser();
|
2019-07-30 17:15:38 +02:00
|
|
|
$enabled = $check->assignedUsers ? $check->assignedUsers->pluck('id')->search($user->id) !== false : true;
|
2019-07-30 16:50:10 +02:00
|
|
|
|
|
|
|
$result = '
|
|
|
|
<li id="check_'.$check->id.'" class="check-item'.(!empty($check->checked_at) ? ' done' : '').'" '.(!$enabled ? 'style="opacity: 0.4"' : '').' data-id="'.$check->id.'">
|
|
|
|
<input type="checkbox" value="'.(!empty($check->checked_at) ? '1' : '0').'" '.(!empty($check->checked_at) ? 'checked' : '').'>
|
|
|
|
|
|
|
|
<span class="text">'.$check->content.'</span>
|
2019-07-30 17:44:15 +02:00
|
|
|
<span class="badge">'.(!empty($check->checked_at) ? timestampFormat($check->checked_at).' - '.$check->checkUser->username : '').'</span>';
|
2019-07-30 16:50:10 +02:00
|
|
|
|
|
|
|
if ($level == 0) {
|
|
|
|
$result .= '
|
|
|
|
<span class="handle pull-right">
|
|
|
|
<i class="fa fa-ellipsis-v"></i>
|
|
|
|
<i class="fa fa-ellipsis-v"></i>
|
|
|
|
</span>';
|
|
|
|
}
|
|
|
|
|
2019-07-30 17:44:15 +02:00
|
|
|
if (empty($check->user) || $check->user->id == $user->id) {
|
|
|
|
$result .= '
|
2019-07-30 16:50:10 +02:00
|
|
|
<div class="tools">
|
|
|
|
<i class="fa fa-trash-o check-delete"></i>
|
2019-07-30 17:44:15 +02:00
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$result .= '
|
2019-07-30 16:50:10 +02:00
|
|
|
<ul class="todo-list">';
|
|
|
|
|
|
|
|
$children = $check->children;
|
|
|
|
foreach ($children as $child) {
|
|
|
|
$result .= renderChecklist($child, $level + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$result .= '
|
|
|
|
</ul>
|
|
|
|
</li>';
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|