updated folder colors, reordering, new todo page, updated sidebar
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-09-21 00:33:10 -07:00
parent df016dad14
commit f8fc561602
25 changed files with 1980 additions and 264 deletions
+7 -1
View File
@@ -16,17 +16,23 @@ use Illuminate\Support\Collection;
* @property int $id
* @property int $user_id
* @property string $name
* @property string|null $color
* @property int|null $parent_id
* @property Folder|null $parent
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*/
#[Fillable(['user_id', 'name', 'parent_id'])]
#[Fillable(['user_id', 'name', 'parent_id', 'color'])]
class Folder extends Model
{
/** @use HasFactory<FolderFactory> */
use HasFactory;
public const COLORS = [
'zinc', 'red', 'orange', 'amber', 'green', 'emerald',
'sky', 'blue', 'indigo', 'violet', 'fuchsia', 'pink',
];
/** @return BelongsTo<User, $this> */
public function user(): BelongsTo
{
+32 -1
View File
@@ -18,13 +18,14 @@ use Illuminate\Support\Carbon;
* @property string $description
* @property string|null $notes
* @property TodoStatus $status
* @property int|null $position
* @property Carbon|null $due_date
* @property Carbon|null $completed_at
* @property Folder $folder
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*/
#[Fillable(['user_id', 'folder_id', 'description', 'notes', 'status', 'due_date', 'completed_at'])]
#[Fillable(['user_id', 'folder_id', 'description', 'notes', 'status', 'position', 'due_date', 'completed_at'])]
class Todo extends Model
{
/** @use HasFactory<TodoFactory> */
@@ -101,6 +102,7 @@ class Todo extends Model
return $query->incomplete()->whereNotIn('status', [
TodoStatus::Cancelled->value,
TodoStatus::Deferred->value,
TodoStatus::Completed->value,
]);
}
@@ -125,4 +127,33 @@ class Todo extends Model
{
return $query->active()->whereDate('due_date', today());
}
public function scopePriority(Builder $query): Builder
{
return $query
->orderByRaw('completed_at IS NOT NULL')
->orderByRaw('position IS NULL')
->orderBy('position')
->orderByDesc('id');
}
/**
* Get the position to assign to a new todo so it appears at the top of the
* priority order for the given user.
*/
public static function nextPositionFor(User|int $user): int
{
$min = static::query()->forUser($user)->min('position');
return $min === null ? 1 : $min - 1;
}
/**
* Get the number of days between creation and completion, or null when the
* todo has not been completed.
*/
public function daysToComplete(): ?int
{
return $this->completed_at === null ? null : $this->created_at->diffInDays($this->completed_at);
}
}