Remove duplicate checklists functionality
Checklists were duplicating subtasks functionality. Removed: - Migration for task_checklists table - TaskChecklistModel - Checklist methods from TaskService - Checklist routes from Routes.php - Checklist controller methods - Checklist UI section from show.twig - Checklist JavaScript functions Updated TASKS_MODULE_ROADMAP.md
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Tasks\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Traits\TenantScopedModel;
|
||||
|
||||
class TaskChecklistModel extends Model
|
||||
{
|
||||
use TenantScopedModel;
|
||||
|
||||
protected $table = 'task_checklists';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $tenantField = 'task.organization_id';
|
||||
protected $allowedFields = [
|
||||
'task_id',
|
||||
'title',
|
||||
'is_completed',
|
||||
'order_index',
|
||||
];
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
/**
|
||||
* Получить элементы чек-листа задачи
|
||||
*/
|
||||
public function getByTask(int $taskId): array
|
||||
{
|
||||
return $this->where('task_id', $taskId)
|
||||
->orderBy('order_index', 'ASC')
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить следующий порядковый номер для элемента чек-листа
|
||||
*/
|
||||
public function getNextOrder(int $taskId): int
|
||||
{
|
||||
$max = $this->selectMax('order_index')
|
||||
->where('task_id', $taskId)
|
||||
->first();
|
||||
|
||||
return ($max['order_index'] ?? 0) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Переключить статус элемента чек-листа
|
||||
*/
|
||||
public function toggle(int $checklistId): bool
|
||||
{
|
||||
$checklist = $this->find($checklistId);
|
||||
if (!$checklist) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->update($checklistId, [
|
||||
'is_completed' => !$checklist['is_completed'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить количество незавершённых элементов чек-листа
|
||||
*/
|
||||
public function getIncompleteCount(int $taskId): int
|
||||
{
|
||||
return $this->where('task_id', $taskId)
|
||||
->where('is_completed', false)
|
||||
->countAllResults();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user