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
+1
View File
@@ -21,6 +21,7 @@ class FolderFactory extends Factory
return [
'user_id' => User::factory(),
'name' => fake()->unique()->words(2, true),
'color' => fake()->optional()->randomElement(Folder::COLORS),
'parent_id' => null,
];
}
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('todos', function (Blueprint $table) {
$table->integer('position')->nullable()->after('status');
$table->index(['user_id', 'position']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('todos', function (Blueprint $table) {
$table->dropIndex(['user_id', 'position']);
$table->dropColumn('position');
});
}
};
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('folders', function (Blueprint $table) {
$table->string('color', 20)->nullable()->after('name');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('folders', function (Blueprint $table) {
$table->dropColumn('color');
});
}
};
+33 -13
View File
@@ -5,6 +5,7 @@ namespace Database\Seeders;
use App\Models\Folder;
use App\Models\Todo;
use App\Models\User;
use App\TodoStatus;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
@@ -19,11 +20,14 @@ class DatabaseSeeder extends Seeder
{
$this->call(BaseDatabaseSeeder::class);
$user = User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
'is_admin' => true,
]);
$user = User::updateOrCreate(
['email' => 'test@example.com'],
[
'name' => 'Test User',
'password' => 'password',
'is_admin' => true,
],
);
$work = $this->createTopLevelFolder($user, 'Work');
$business = $this->createTopLevelFolder($user, 'Business');
@@ -63,29 +67,45 @@ class DatabaseSeeder extends Seeder
$foldersByName = $folders->keyBy(fn (Folder $folder) => $folder->name);
foreach ($samples as [$description, $folderName, $daysFromToday, $status]) {
$todo = Todo::factory()->recycle($user)->create([
'folder_id' => $foldersByName[$folderName]->id,
'description' => $description,
'due_date' => $daysFromToday === null ? null : today()->addDays($daysFromToday),
]);
$todo = Todo::firstOrCreate(
['user_id' => $user->id, 'folder_id' => $foldersByName[$folderName]->id, 'description' => $description],
['status' => TodoStatus::Open],
);
if ($daysFromToday === null) {
$todo->update(['due_date' => null]);
} else {
$todo->update(['due_date' => today()->addDays($daysFromToday)]);
}
if ($status === 'overdue') {
$todo->update(['due_date' => today()->subDays(3)]);
}
if ($status === 'completed') {
$todo->update(['completed_at' => now()->subDay()]);
$todo->update([
'status' => TodoStatus::Completed,
'completed_at' => now()->subDay(),
]);
} else {
$todo->update(['completed_at' => null]);
}
}
}
private function createTopLevelFolder(User $user, string $name): Folder
{
return Folder::factory()->recycle($user)->create(['name' => $name]);
return Folder::firstOrCreate(
['user_id' => $user->id, 'name' => $name, 'parent_id' => null],
['color' => fake()->optional()->randomElement(Folder::COLORS)],
);
}
private function createChildFolder(Folder $parent, string $name): Folder
{
return Folder::factory()->childOf($parent)->create(['name' => $name]);
return Folder::firstOrCreate(
['user_id' => $parent->user_id, 'name' => $name, 'parent_id' => $parent->id],
['color' => fake()->optional()->randomElement(Folder::COLORS)],
);
}
}