2026-09-17 23:01:26 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Models\Folder;
|
|
|
|
|
use App\Models\Todo;
|
2026-09-18 23:54:46 -07:00
|
|
|
use App\TodoStatus;
|
2026-09-17 23:01:26 -07:00
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
use Livewire\Attributes\Computed;
|
|
|
|
|
use Livewire\Attributes\Locked;
|
|
|
|
|
use Livewire\Attributes\Title;
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
new #[Title('Folders')] class extends Component
|
|
|
|
|
{
|
|
|
|
|
public string $newFolderName = '';
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
public string $newFolderColor = '';
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
#[Locked]
|
|
|
|
|
public ?int $creatingChildOf = null;
|
|
|
|
|
|
|
|
|
|
public string $newChildName = '';
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
public string $newChildColor = '';
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
#[Locked]
|
|
|
|
|
public ?int $renamingFolderId = null;
|
|
|
|
|
|
|
|
|
|
public string $renameName = '';
|
|
|
|
|
|
|
|
|
|
#[Locked]
|
|
|
|
|
public ?int $confirmingFolderDelete = null;
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
#[Locked]
|
|
|
|
|
public ?int $expandedFolderId = null;
|
|
|
|
|
|
|
|
|
|
#[Locked]
|
|
|
|
|
public ?int $colorEditingFolderId = null;
|
|
|
|
|
|
|
|
|
|
public string $colorDraft = '';
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
public bool $showTodoForm = false;
|
|
|
|
|
|
|
|
|
|
#[Locked]
|
|
|
|
|
public ?int $todoFolderId = null;
|
|
|
|
|
|
|
|
|
|
public string $todoDescription = '';
|
|
|
|
|
|
2026-09-18 23:54:46 -07:00
|
|
|
public string $todoStatus = 'open';
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
public ?string $todoDueDate = null;
|
|
|
|
|
|
|
|
|
|
public string $todoNotes = '';
|
|
|
|
|
|
|
|
|
|
public function createTopLevelFolder(): void
|
|
|
|
|
{
|
|
|
|
|
$validated = $this->validate([
|
|
|
|
|
'newFolderName' => $this->folderNameRules(parentId: null),
|
2026-09-21 00:33:10 -07:00
|
|
|
'newFolderColor' => $this->folderColorRules(),
|
2026-09-17 23:01:26 -07:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Folder::create([
|
|
|
|
|
'user_id' => auth()->id(),
|
|
|
|
|
'name' => $validated['newFolderName'],
|
2026-09-21 00:33:10 -07:00
|
|
|
'color' => filled($validated['newFolderColor']) ? $validated['newFolderColor'] : null,
|
2026-09-17 23:01:26 -07:00
|
|
|
'parent_id' => null,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
$this->reset('newFolderName', 'newFolderColor');
|
2026-09-17 23:01:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startChildCreate(int $folderId): void
|
|
|
|
|
{
|
|
|
|
|
$this->folderForUser($folderId);
|
|
|
|
|
|
|
|
|
|
$this->creatingChildOf = $folderId;
|
2026-09-21 00:33:10 -07:00
|
|
|
$this->reset('newChildName', 'newChildColor');
|
|
|
|
|
$this->resetErrorBag('newChildName', 'newChildColor');
|
2026-09-17 23:01:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function cancelChildCreate(): void
|
|
|
|
|
{
|
2026-09-21 00:33:10 -07:00
|
|
|
$this->reset('creatingChildOf', 'newChildName', 'newChildColor');
|
2026-09-17 23:01:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createChildFolder(): void
|
|
|
|
|
{
|
|
|
|
|
$this->folderForUser($this->creatingChildOf);
|
|
|
|
|
|
|
|
|
|
$validated = $this->validate([
|
|
|
|
|
'newChildName' => $this->folderNameRules(parentId: $this->creatingChildOf),
|
2026-09-21 00:33:10 -07:00
|
|
|
'newChildColor' => $this->folderColorRules(),
|
2026-09-17 23:01:26 -07:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Folder::create([
|
|
|
|
|
'user_id' => auth()->id(),
|
|
|
|
|
'name' => $validated['newChildName'],
|
2026-09-21 00:33:10 -07:00
|
|
|
'color' => filled($validated['newChildColor']) ? $validated['newChildColor'] : null,
|
2026-09-17 23:01:26 -07:00
|
|
|
'parent_id' => $this->creatingChildOf,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
$this->reset('creatingChildOf', 'newChildName', 'newChildColor');
|
2026-09-17 23:01:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startRename(int $folderId): void
|
|
|
|
|
{
|
|
|
|
|
$folder = $this->folderForUser($folderId);
|
|
|
|
|
|
|
|
|
|
$this->renamingFolderId = $folder->id;
|
|
|
|
|
$this->renameName = $folder->name;
|
|
|
|
|
$this->resetErrorBag('renameName');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function cancelRename(): void
|
|
|
|
|
{
|
|
|
|
|
$this->reset('renamingFolderId', 'renameName');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function saveRename(): void
|
|
|
|
|
{
|
|
|
|
|
$folder = $this->folderForUser($this->renamingFolderId);
|
|
|
|
|
|
|
|
|
|
$validated = $this->validate([
|
|
|
|
|
'renameName' => $this->folderNameRules(parentId: $folder->parent_id, ignoreId: $folder->id),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$folder->update(['name' => $validated['renameName']]);
|
|
|
|
|
|
|
|
|
|
$this->reset('renamingFolderId', 'renameName');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function confirmFolderDelete(int $folderId): void
|
|
|
|
|
{
|
|
|
|
|
$this->folderForUser($folderId);
|
|
|
|
|
|
|
|
|
|
$this->confirmingFolderDelete = $folderId;
|
|
|
|
|
$this->modal('confirm-folder-delete')->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function deleteFolder(): void
|
|
|
|
|
{
|
2026-09-21 00:33:10 -07:00
|
|
|
$folder = $this->folderForUser($this->confirmingFolderDelete);
|
|
|
|
|
|
|
|
|
|
if ($this->expandedFolderId === $folder->id) {
|
|
|
|
|
$this->expandedFolderId = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$folder->delete();
|
2026-09-17 23:01:26 -07:00
|
|
|
|
|
|
|
|
$this->confirmingFolderDelete = null;
|
|
|
|
|
$this->modal('confirm-folder-delete')->close();
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
public function toggleExpandFolder(int $folderId): void
|
|
|
|
|
{
|
|
|
|
|
$this->folderForUser($folderId);
|
|
|
|
|
|
|
|
|
|
$this->expandedFolderId = $this->expandedFolderId === $folderId ? null : $folderId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startColorEdit(int $folderId): void
|
|
|
|
|
{
|
|
|
|
|
$folder = $this->folderForUser($folderId);
|
|
|
|
|
|
|
|
|
|
$this->colorEditingFolderId = $folder->id;
|
|
|
|
|
$this->colorDraft = $folder->color ?? '';
|
|
|
|
|
$this->resetErrorBag('colorDraft');
|
|
|
|
|
$this->modal('folder-color')->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function saveFolderColor(): void
|
|
|
|
|
{
|
|
|
|
|
$folder = $this->folderForUser($this->colorEditingFolderId ?? 0);
|
|
|
|
|
|
|
|
|
|
$validated = $this->validate([
|
|
|
|
|
'colorDraft' => $this->folderColorRules(),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$folder->update([
|
|
|
|
|
'color' => filled($validated['colorDraft']) ? $validated['colorDraft'] : null,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->reset('colorEditingFolderId', 'colorDraft');
|
|
|
|
|
$this->modal('folder-color')->close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function moveTodoToFolder(int $todoId, int $folderId): void
|
|
|
|
|
{
|
|
|
|
|
$todo = Todo::query()->forUser(auth()->id())->findOrFail($todoId);
|
|
|
|
|
|
|
|
|
|
$folder = Folder::query()->forUser(auth()->id())->findOrFail($folderId);
|
|
|
|
|
|
|
|
|
|
$todo->update(['folder_id' => $folder->id]);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-24 22:48:34 -07:00
|
|
|
public function moveFolderToTopLevel(int $folderId): void
|
|
|
|
|
{
|
|
|
|
|
$folder = $this->folderForUser($folderId);
|
|
|
|
|
|
|
|
|
|
$hasSiblingConflict = Folder::query()
|
|
|
|
|
->forUser(auth()->id())
|
|
|
|
|
->whereNull('parent_id')
|
|
|
|
|
->whereKeyNot($folder->id)
|
|
|
|
|
->where('name', $folder->name)
|
|
|
|
|
->exists();
|
|
|
|
|
|
|
|
|
|
if ($hasSiblingConflict) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$folder->update(['parent_id' => null]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function moveFolderToFolder(int $folderId, int $targetFolderId): void
|
|
|
|
|
{
|
|
|
|
|
$folder = $this->folderForUser($folderId);
|
|
|
|
|
$target = $this->folderForUser($targetFolderId);
|
|
|
|
|
|
|
|
|
|
if ($folder->id === $target->id || $this->isDescendantOf($target, $folder)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$hasSiblingConflict = $target->children()
|
|
|
|
|
->whereKeyNot($folder->id)
|
|
|
|
|
->where('name', $folder->name)
|
|
|
|
|
->exists();
|
|
|
|
|
|
|
|
|
|
if ($hasSiblingConflict) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$folder->update(['parent_id' => $target->id]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function isDescendantOf(Folder $folder, Folder $ancestor): bool
|
|
|
|
|
{
|
|
|
|
|
$cursor = $folder->parent;
|
|
|
|
|
|
|
|
|
|
while ($cursor !== null) {
|
|
|
|
|
if ($cursor->id === $ancestor->id) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$cursor = $cursor->parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
public function todosForFolder(int $folderId): Collection
|
|
|
|
|
{
|
|
|
|
|
return Todo::query()
|
|
|
|
|
->forUser(auth()->id())
|
|
|
|
|
->where('folder_id', $folderId)
|
|
|
|
|
->active()
|
|
|
|
|
->priority()
|
|
|
|
|
->get();
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
public function startTodoCreate(int $folderId): void
|
|
|
|
|
{
|
|
|
|
|
$this->folderForUser($folderId);
|
|
|
|
|
|
|
|
|
|
$this->todoFolderId = $folderId;
|
2026-09-18 23:54:46 -07:00
|
|
|
$this->reset('todoDescription', 'todoStatus', 'todoDueDate', 'todoNotes');
|
|
|
|
|
$this->resetErrorBag('todoDescription', 'todoStatus', 'todoDueDate', 'todoNotes');
|
2026-09-17 23:01:26 -07:00
|
|
|
$this->showTodoForm = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function saveFolderTodo(): void
|
|
|
|
|
{
|
|
|
|
|
$folder = $this->folderForUser($this->todoFolderId ?? 0);
|
|
|
|
|
|
|
|
|
|
$validated = $this->validate([
|
|
|
|
|
'todoDescription' => ['required', 'string', 'max:255'],
|
2026-09-18 23:54:46 -07:00
|
|
|
'todoStatus' => ['required', Rule::enum(TodoStatus::class)],
|
2026-09-17 23:01:26 -07:00
|
|
|
'todoDueDate' => ['nullable', 'date'],
|
|
|
|
|
'todoNotes' => ['nullable', 'string', 'max:'.auth()->user()->notesLimit()],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Todo::create([
|
|
|
|
|
'user_id' => auth()->id(),
|
|
|
|
|
'folder_id' => $folder->id,
|
|
|
|
|
'description' => $validated['todoDescription'],
|
2026-09-18 23:54:46 -07:00
|
|
|
'status' => TodoStatus::from($validated['todoStatus']),
|
2026-09-17 23:01:26 -07:00
|
|
|
'due_date' => filled($validated['todoDueDate']) ? Carbon::parse($validated['todoDueDate']) : null,
|
|
|
|
|
'notes' => filled($validated['todoNotes']) ? $validated['todoNotes'] : null,
|
2026-09-21 00:33:10 -07:00
|
|
|
'position' => Todo::nextPositionFor(auth()->user()),
|
2026-09-17 23:01:26 -07:00
|
|
|
]);
|
|
|
|
|
|
2026-09-18 23:54:46 -07:00
|
|
|
$this->reset('showTodoForm', 'todoFolderId', 'todoDescription', 'todoStatus', 'todoDueDate', 'todoNotes');
|
2026-09-17 23:01:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Computed]
|
|
|
|
|
public function folderTree(): Collection
|
|
|
|
|
{
|
|
|
|
|
return Folder::treeForUser(auth()->id());
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-18 23:54:46 -07:00
|
|
|
#[Computed]
|
|
|
|
|
public function todoFolder(): ?Folder
|
|
|
|
|
{
|
|
|
|
|
if ($this->todoFolderId === null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Folder::query()->with('parent')->forUser(auth()->id())->find($this->todoFolderId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Computed]
|
|
|
|
|
public function todoFolderPath(): string
|
|
|
|
|
{
|
|
|
|
|
if ($this->todoFolder === null) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return collect([$this->todoFolder->parent?->name, $this->todoFolder->name])
|
|
|
|
|
->filter()
|
|
|
|
|
->implode(' / ');
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
#[Computed]
|
|
|
|
|
public function openCounts(): Collection
|
|
|
|
|
{
|
|
|
|
|
return Todo::query()
|
|
|
|
|
->forUser(auth()->id())
|
2026-09-18 23:54:46 -07:00
|
|
|
->active()
|
2026-09-17 23:01:26 -07:00
|
|
|
->pluck('folder_id')
|
|
|
|
|
->countBy();
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
/**
|
|
|
|
|
* @return array<int, mixed>
|
|
|
|
|
*/
|
|
|
|
|
private function folderColorRules(): array
|
|
|
|
|
{
|
|
|
|
|
return ['nullable', 'string', 'max:20', Rule::in([...Folder::COLORS, ''])];
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
/**
|
|
|
|
|
* @return array<int, mixed>
|
|
|
|
|
*/
|
|
|
|
|
private function folderNameRules(?int $parentId = null, ?int $ignoreId = null): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'required',
|
|
|
|
|
'string',
|
|
|
|
|
'max:255',
|
|
|
|
|
Rule::unique('folders', 'name')
|
|
|
|
|
->ignore($ignoreId)
|
|
|
|
|
->where(fn ($query) => $query
|
|
|
|
|
->where('user_id', auth()->id())
|
|
|
|
|
->where('parent_id', $parentId)),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function folderForUser(int $folderId): Folder
|
|
|
|
|
{
|
|
|
|
|
return Folder::query()->forUser(auth()->id())->findOrFail($folderId);
|
|
|
|
|
}
|
|
|
|
|
}; ?>
|
|
|
|
|
|
|
|
|
|
<div class="flex h-full w-full flex-1 flex-col gap-6">
|
|
|
|
|
<div class="flex flex-wrap items-center justify-between gap-4">
|
|
|
|
|
<div>
|
|
|
|
|
<flux:heading size="xl">{{ __('Folders') }}</flux:heading>
|
|
|
|
|
<flux:text class="mt-1">{{ __('Organize your todos into a top-level and nested folder hierarchy.') }}</flux:text>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@if ($this->folderTree->isEmpty())
|
|
|
|
|
<flux:callout variant="warning" icon="folder">
|
|
|
|
|
{{ __('No folders yet. Create your first top-level folder below.') }}
|
|
|
|
|
</flux:callout>
|
|
|
|
|
@endif
|
|
|
|
|
|
|
|
|
|
<flux:card>
|
|
|
|
|
<form wire:submit="createTopLevelFolder" class="flex flex-wrap items-end gap-3">
|
|
|
|
|
<div class="min-w-64 flex-1">
|
|
|
|
|
<flux:label>{{ __('New top-level folder') }}</flux:label>
|
|
|
|
|
<flux:input
|
|
|
|
|
wire:model="newFolderName"
|
|
|
|
|
placeholder="{{ __('e.g. Work, Business, Personal') }}"
|
|
|
|
|
data-test="new-folder-input"
|
|
|
|
|
/>
|
|
|
|
|
<flux:error name="newFolderName" />
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
<div>
|
|
|
|
|
<flux:label>{{ __('Color') }}</flux:label>
|
|
|
|
|
<x-color-picker model="newFolderColor" />
|
|
|
|
|
<flux:error name="newFolderColor" />
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
<flux:button variant="primary" type="submit" icon="plus" data-test="add-folder-button">
|
|
|
|
|
{{ __('Add folder') }}
|
|
|
|
|
</flux:button>
|
|
|
|
|
</form>
|
|
|
|
|
</flux:card>
|
|
|
|
|
|
2026-09-24 22:48:34 -07:00
|
|
|
<div
|
|
|
|
|
x-data="{
|
|
|
|
|
draggingFolder: false,
|
|
|
|
|
droppingTopLevel: false,
|
|
|
|
|
dropFolder(folderId) {
|
|
|
|
|
if (window.__mtFolderDrag) {
|
|
|
|
|
if (window.__mtFolderDrag.folderId !== folderId) $wire.moveFolderToFolder(window.__mtFolderDrag.folderId, folderId);
|
|
|
|
|
window.__mtFolderDrag = null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
dropTodo(folderId) {
|
|
|
|
|
if (window.__mtTodoDrag && window.__mtTodoDrag.folderId !== folderId) $wire.moveTodoToFolder(window.__mtTodoDrag.todoId, folderId);
|
|
|
|
|
window.__mtTodoDrag = null;
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
@folder-drag-start="draggingFolder = true; droppingTopLevel = false"
|
|
|
|
|
@folder-drag-end="draggingFolder = false; droppingTopLevel = false"
|
|
|
|
|
class="flex flex-col divide-y divide-zinc-200 rounded-xl border border-zinc-200 bg-white dark:divide-zinc-700 dark:border-zinc-700 dark:bg-zinc-900"
|
|
|
|
|
data-test="folder-list"
|
|
|
|
|
>
|
2026-09-17 23:01:26 -07:00
|
|
|
@forelse ($this->folderTree as $node)
|
2026-09-24 22:48:34 -07:00
|
|
|
<div
|
|
|
|
|
x-show="draggingFolder"
|
|
|
|
|
class="p-4"
|
|
|
|
|
:class="droppingTopLevel && 'rounded-lg bg-blue-50 ring-2 ring-inset ring-blue-400 dark:bg-blue-500/10'"
|
|
|
|
|
@dragover.prevent="droppingTopLevel = true"
|
|
|
|
|
@dragleave="!$el.contains($event.relatedTarget) && (droppingTopLevel = false)"
|
|
|
|
|
@drop.prevent="droppingTopLevel = false; if (window.__mtFolderDrag) { $wire.moveFolderToTopLevel(window.__mtFolderDrag.folderId); window.__mtFolderDrag = null; }"
|
|
|
|
|
data-test="top-level-drop-zone"
|
|
|
|
|
>
|
|
|
|
|
<div class="flex items-center justify-center gap-2 border-2 border-dashed border-zinc-300 p-3 text-sm text-zinc-500 dark:border-zinc-600 dark:text-zinc-400">
|
|
|
|
|
<flux:icon.arrow-up-on-square variant="micro" class="size-4" />
|
|
|
|
|
{{ __('Drop here to make it a top-level folder') }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-09-17 23:01:26 -07:00
|
|
|
<div class="p-4" :style="'margin-left: {{ $node['depth'] * 1.5 }}rem'">
|
2026-09-21 00:33:10 -07:00
|
|
|
<div
|
|
|
|
|
x-data="{ drop: false }"
|
|
|
|
|
class="flex flex-wrap items-center gap-3 transition-colors"
|
|
|
|
|
:class="drop && 'rounded-lg bg-blue-50 ring-2 ring-inset ring-blue-400 dark:bg-blue-500/10'"
|
|
|
|
|
@dragover.prevent="drop = true"
|
|
|
|
|
@dragleave="!$el.contains($event.relatedTarget) && (drop = false)"
|
2026-09-24 22:48:34 -07:00
|
|
|
@drop.prevent="drop = false; window.__mtFolderDrag ? dropFolder({{ $node['folder']->id }}) : dropTodo({{ $node['folder']->id }})"
|
2026-09-21 00:33:10 -07:00
|
|
|
data-test="folder-row-{{ $node['folder']->id }}"
|
|
|
|
|
>
|
2026-09-17 23:01:26 -07:00
|
|
|
@if ($renamingFolderId === $node['folder']->id)
|
|
|
|
|
<form wire:submit="saveRename" class="flex flex-1 flex-wrap items-center gap-3">
|
|
|
|
|
<flux:input
|
|
|
|
|
wire:model="renameName"
|
|
|
|
|
size="sm"
|
|
|
|
|
class="min-w-48 flex-1"
|
|
|
|
|
autofocus
|
|
|
|
|
data-test="rename-input"
|
|
|
|
|
/>
|
|
|
|
|
<div class="flex gap-2">
|
|
|
|
|
<flux:button size="sm" type="submit" variant="primary" icon="check" data-test="save-rename-button">
|
|
|
|
|
{{ __('Save') }}
|
|
|
|
|
</flux:button>
|
|
|
|
|
<flux:button size="sm" variant="ghost" wire:click="cancelRename">
|
|
|
|
|
{{ __('Cancel') }}
|
|
|
|
|
</flux:button>
|
|
|
|
|
</div>
|
|
|
|
|
<flux:error name="renameName" />
|
|
|
|
|
</form>
|
|
|
|
|
@else
|
2026-09-21 00:33:10 -07:00
|
|
|
<div class="flex min-w-0 items-center gap-2">
|
2026-09-24 22:48:34 -07:00
|
|
|
<div
|
|
|
|
|
x-data="{ dragging: false }"
|
|
|
|
|
draggable="true"
|
|
|
|
|
class="inline-flex shrink-0 cursor-grab text-zinc-400 dark:text-zinc-500"
|
|
|
|
|
:class="dragging && 'opacity-40'"
|
|
|
|
|
@dragstart="dragging = true; window.__mtFolderDrag = { folderId: {{ $node['folder']->id }} }; $dispatch('folder-drag-start')"
|
|
|
|
|
@dragend="dragging = false; window.__mtFolderDrag = null; $dispatch('folder-drag-end')"
|
|
|
|
|
:title="__('Drag to move this folder')"
|
|
|
|
|
data-test="drag-folder-{{ $node['folder']->id }}"
|
|
|
|
|
>
|
|
|
|
|
<flux:icon.chevrons-up-down variant="micro" />
|
|
|
|
|
</div>
|
2026-09-21 00:33:10 -07:00
|
|
|
<x-folder-dot :color="$node['folder']->color" data-test="folder-dot-{{ $node['folder']->id }}" />
|
|
|
|
|
<flux:heading size="sm" class="truncate" data-test="folder-name-{{ $node['folder']->id }}">
|
|
|
|
|
{{ $node['folder']->name }}
|
|
|
|
|
</flux:heading>
|
|
|
|
|
</div>
|
2026-09-17 23:01:26 -07:00
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
<flux:badge
|
|
|
|
|
size="sm"
|
|
|
|
|
color="blue"
|
|
|
|
|
class="cursor-pointer select-none"
|
|
|
|
|
wire:click="toggleExpandFolder({{ $node['folder']->id }})"
|
|
|
|
|
data-test="expand-folder-{{ $node['folder']->id }}"
|
|
|
|
|
>
|
|
|
|
|
<flux:icon.chevron-down
|
|
|
|
|
variant="micro"
|
|
|
|
|
:class="'me-0.5' . ($expandedFolderId === $node['folder']->id ? ' rotate-180 transition-transform' : ' transition-transform')"
|
|
|
|
|
/>
|
2026-09-17 23:01:26 -07:00
|
|
|
{{ $this->openCounts->get($node['folder']->id, 0) }} {{ __('open') }}
|
|
|
|
|
</flux:badge>
|
|
|
|
|
|
|
|
|
|
<flux:spacer />
|
|
|
|
|
|
|
|
|
|
<div class="flex items-center gap-1">
|
2026-09-21 00:33:10 -07:00
|
|
|
<flux:tooltip :content="__('Choose color')">
|
|
|
|
|
<flux:button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
icon="swatch"
|
|
|
|
|
wire:click="startColorEdit({{ $node['folder']->id }})"
|
|
|
|
|
data-test="color-folder-{{ $node['folder']->id }}"
|
|
|
|
|
/>
|
|
|
|
|
</flux:tooltip>
|
2026-09-17 23:01:26 -07:00
|
|
|
<flux:tooltip :content="__('View todos')">
|
|
|
|
|
<flux:button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
icon="magnifying-glass"
|
|
|
|
|
:href="route('dashboard', ['folder' => $node['folder']->id])"
|
|
|
|
|
wire:navigate
|
|
|
|
|
data-test="view-todos-{{ $node['folder']->id }}"
|
|
|
|
|
/>
|
|
|
|
|
</flux:tooltip>
|
|
|
|
|
<flux:tooltip :content="__('Add todo')">
|
|
|
|
|
<flux:button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
icon="document-plus"
|
|
|
|
|
wire:click="startTodoCreate({{ $node['folder']->id }})"
|
|
|
|
|
data-test="add-todo-{{ $node['folder']->id }}"
|
|
|
|
|
/>
|
|
|
|
|
</flux:tooltip>
|
|
|
|
|
<flux:tooltip :content="__('Add sub-folder')">
|
|
|
|
|
<flux:button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
icon="folder-plus"
|
|
|
|
|
wire:click="startChildCreate({{ $node['folder']->id }})"
|
|
|
|
|
data-test="add-child-{{ $node['folder']->id }}"
|
|
|
|
|
/>
|
|
|
|
|
</flux:tooltip>
|
|
|
|
|
<flux:tooltip :content="__('Rename')">
|
|
|
|
|
<flux:button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
icon="pencil-square"
|
|
|
|
|
wire:click="startRename({{ $node['folder']->id }})"
|
|
|
|
|
data-test="rename-folder-{{ $node['folder']->id }}"
|
|
|
|
|
/>
|
|
|
|
|
</flux:tooltip>
|
|
|
|
|
<flux:tooltip :content="__('Delete')">
|
|
|
|
|
<flux:button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
icon="trash"
|
|
|
|
|
wire:click="confirmFolderDelete({{ $node['folder']->id }})"
|
|
|
|
|
data-test="delete-folder-{{ $node['folder']->id }}"
|
|
|
|
|
/>
|
|
|
|
|
</flux:tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
@endif
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
@if ($expandedFolderId === $node['folder']->id)
|
|
|
|
|
<div class="mt-3 flex flex-col gap-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-700 dark:bg-zinc-800/50" data-test="folder-todos-{{ $node['folder']->id }}">
|
|
|
|
|
<flux:text size="sm" class="text-zinc-500">{{ __('Drag a todo onto any folder row to move it.') }}</flux:text>
|
|
|
|
|
|
|
|
|
|
@forelse ($this->todosForFolder($node['folder']->id) as $todo)
|
|
|
|
|
<div
|
|
|
|
|
x-data="{ dragging: false }"
|
|
|
|
|
draggable="true"
|
|
|
|
|
class="flex cursor-grab select-none flex-wrap items-center gap-3"
|
|
|
|
|
:class="dragging && 'opacity-40'"
|
|
|
|
|
@dragstart="dragging = true; window.__mtTodoDrag = { todoId: {{ $todo->id }}, folderId: {{ $node['folder']->id }} }"
|
|
|
|
|
@dragend="dragging = false; window.__mtTodoDrag = null"
|
|
|
|
|
data-test="folder-todo-row-{{ $todo->id }}"
|
|
|
|
|
>
|
|
|
|
|
<flux:icon.chevrons-up-down variant="micro" class="text-zinc-400 dark:text-zinc-500" />
|
|
|
|
|
|
|
|
|
|
<flux:heading size="sm" class="min-w-0 flex-1 truncate" data-test="folder-todo-description-{{ $todo->id }}">
|
|
|
|
|
{{ $todo->description }}
|
|
|
|
|
</flux:heading>
|
|
|
|
|
|
|
|
|
|
<flux:badge size="sm" :color="$todo->status->badgeColor()">
|
|
|
|
|
{{ $todo->status->label() }}
|
|
|
|
|
</flux:badge>
|
|
|
|
|
</div>
|
|
|
|
|
@empty
|
|
|
|
|
<flux:text class="text-sm text-zinc-500">{{ __('No open todos in this folder.') }}</flux:text>
|
|
|
|
|
@endforelse
|
|
|
|
|
</div>
|
|
|
|
|
@endif
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
@if ($creatingChildOf === $node['folder']->id)
|
|
|
|
|
<form wire:submit="createChildFolder" class="mt-3 flex flex-wrap items-end gap-3">
|
|
|
|
|
<div class="min-w-64 flex-1">
|
|
|
|
|
<flux:label size="sm">{{ __('Sub-folder of') }} {{ $node['folder']->name }}</flux:label>
|
|
|
|
|
<flux:input
|
|
|
|
|
wire:model="newChildName"
|
|
|
|
|
size="sm"
|
|
|
|
|
placeholder="{{ __('Sub-folder name') }}"
|
|
|
|
|
data-test="new-child-input"
|
|
|
|
|
/>
|
|
|
|
|
<flux:error name="newChildName" />
|
|
|
|
|
</div>
|
2026-09-21 00:33:10 -07:00
|
|
|
<div>
|
|
|
|
|
<flux:label size="sm">{{ __('Color') }}</flux:label>
|
|
|
|
|
<x-color-picker model="newChildColor" />
|
|
|
|
|
<flux:error name="newChildColor" />
|
|
|
|
|
</div>
|
2026-09-17 23:01:26 -07:00
|
|
|
<div class="flex gap-2">
|
|
|
|
|
<flux:button size="sm" variant="primary" type="submit" icon="plus" data-test="add-child-button">
|
|
|
|
|
{{ __('Add') }}
|
|
|
|
|
</flux:button>
|
|
|
|
|
<flux:button size="sm" variant="ghost" wire:click="cancelChildCreate">
|
|
|
|
|
{{ __('Cancel') }}
|
|
|
|
|
</flux:button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
@endif
|
|
|
|
|
</div>
|
|
|
|
|
@empty
|
|
|
|
|
<div class="p-8">
|
|
|
|
|
<flux:text align="center" class="text-sm text-zinc-500">{{ __('No folders to display.') }}</flux:text>
|
|
|
|
|
</div>
|
|
|
|
|
@endforelse
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<flux:modal wire:model.self="showTodoForm" class="md:w-xl">
|
|
|
|
|
<form wire:submit="saveFolderTodo" class="space-y-6">
|
|
|
|
|
<div>
|
2026-09-18 23:54:46 -07:00
|
|
|
@if ($this->todoFolder !== null)
|
|
|
|
|
<flux:heading size="lg" class="truncate">
|
|
|
|
|
{{ __('Add todo') }} - <span class="text-zinc-500 dark:text-zinc-400" data-test="add-todo-title-folder">{{ $this->todoFolderPath }}</span>
|
|
|
|
|
</flux:heading>
|
|
|
|
|
@else
|
|
|
|
|
<flux:heading size="lg">{{ __('Add todo') }}</flux:heading>
|
|
|
|
|
@endif
|
2026-09-17 23:01:26 -07:00
|
|
|
<flux:text class="mt-2">{{ __('Add a task with a description. A due date is optional.') }}</flux:text>
|
2026-09-18 23:54:46 -07:00
|
|
|
|
|
|
|
|
@if ($this->todoFolder !== null)
|
|
|
|
|
<div class="mt-3 flex items-center gap-1.5" data-test="add-todo-folder-name">
|
|
|
|
|
<flux:icon.folder variant="micro" class="text-zinc-500 dark:text-zinc-400" />
|
|
|
|
|
<flux:text size="sm" class="text-zinc-600 dark:text-zinc-300">
|
|
|
|
|
{{ __('Adding to') }}
|
|
|
|
|
<strong class="text-zinc-900 dark:text-zinc-100">
|
|
|
|
|
{{ $this->todoFolderPath }}
|
|
|
|
|
</strong>
|
|
|
|
|
</flux:text>
|
|
|
|
|
</div>
|
|
|
|
|
@endif
|
2026-09-17 23:01:26 -07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<flux:field>
|
|
|
|
|
<flux:label>{{ __('Description') }}</flux:label>
|
|
|
|
|
<flux:input
|
|
|
|
|
wire:model="todoDescription"
|
|
|
|
|
type="text"
|
|
|
|
|
autofocus
|
|
|
|
|
placeholder="{{ __('What needs to be done?') }}"
|
|
|
|
|
data-test="todo-description-input"
|
|
|
|
|
/>
|
|
|
|
|
<flux:error name="todoDescription" />
|
|
|
|
|
</flux:field>
|
|
|
|
|
|
2026-09-18 23:54:46 -07:00
|
|
|
<flux:field>
|
|
|
|
|
<flux:label>{{ __('Status') }}</flux:label>
|
|
|
|
|
<flux:select wire:model="todoStatus" data-test="todo-status-select">
|
|
|
|
|
@foreach (TodoStatus::cases() as $status)
|
|
|
|
|
<flux:select.option :value="$status->value">{{ $status->label() }}</flux:select.option>
|
|
|
|
|
@endforeach
|
|
|
|
|
</flux:select>
|
|
|
|
|
<flux:error name="todoStatus" />
|
|
|
|
|
</flux:field>
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
<flux:field>
|
|
|
|
|
<flux:label>{{ __('Due date') }}</flux:label>
|
|
|
|
|
<flux:input wire:model="todoDueDate" type="date" data-test="todo-due-date-input" />
|
|
|
|
|
<flux:error name="todoDueDate" />
|
|
|
|
|
</flux:field>
|
|
|
|
|
|
|
|
|
|
<flux:field>
|
|
|
|
|
<flux:label>{{ __('Notes') }}</flux:label>
|
|
|
|
|
<flux:textarea
|
|
|
|
|
wire:model="todoNotes"
|
|
|
|
|
rows="3"
|
|
|
|
|
placeholder="{{ __('Add any extra details…') }}"
|
|
|
|
|
data-test="todo-notes-input"
|
|
|
|
|
/>
|
|
|
|
|
<flux:error name="todoNotes" />
|
|
|
|
|
</flux:field>
|
|
|
|
|
|
|
|
|
|
<div class="flex justify-end gap-3">
|
|
|
|
|
<flux:modal.close>
|
|
|
|
|
<flux:button variant="ghost">{{ __('Cancel') }}</flux:button>
|
|
|
|
|
</flux:modal.close>
|
|
|
|
|
<flux:button type="submit" variant="primary">{{ __('Add todo') }}</flux:button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</flux:modal>
|
|
|
|
|
|
2026-09-21 00:33:10 -07:00
|
|
|
<flux:modal name="folder-color" class="md:w-lg">
|
|
|
|
|
<form wire:submit="saveFolderColor" class="space-y-6">
|
|
|
|
|
<div>
|
|
|
|
|
<flux:heading size="lg">{{ __('Folder color') }}</flux:heading>
|
|
|
|
|
<flux:text class="mt-2">{{ __('Choose a color for this folder, or clear it to remove any color.') }}</flux:text>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<flux:field>
|
|
|
|
|
<flux:label>{{ __('Color') }}</flux:label>
|
|
|
|
|
<x-color-picker model="colorDraft" />
|
|
|
|
|
<flux:error name="colorDraft" />
|
|
|
|
|
</flux:field>
|
|
|
|
|
|
|
|
|
|
<div class="flex justify-end gap-3">
|
|
|
|
|
<flux:modal.close>
|
|
|
|
|
<flux:button variant="ghost">{{ __('Cancel') }}</flux:button>
|
|
|
|
|
</flux:modal.close>
|
|
|
|
|
<flux:button type="submit" variant="primary" data-test="save-folder-color">
|
|
|
|
|
{{ __('Save color') }}
|
|
|
|
|
</flux:button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</flux:modal>
|
|
|
|
|
|
2026-09-17 23:01:26 -07:00
|
|
|
<flux:modal name="confirm-folder-delete" class="md:w-lg">
|
|
|
|
|
<div class="space-y-6">
|
|
|
|
|
<div>
|
|
|
|
|
<flux:heading size="lg">{{ __('Delete folder?') }}</flux:heading>
|
|
|
|
|
<flux:text class="mt-2">
|
|
|
|
|
{{ __('Deleting a folder also deletes its sub-folders and every todo inside them. This action cannot be undone.') }}
|
|
|
|
|
</flux:text>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex justify-end gap-3">
|
|
|
|
|
<flux:modal.close>
|
|
|
|
|
<flux:button variant="ghost">{{ __('Cancel') }}</flux:button>
|
|
|
|
|
</flux:modal.close>
|
|
|
|
|
<flux:button variant="danger" wire:click="deleteFolder" data-test="confirm-delete-folder">
|
|
|
|
|
{{ __('Delete folder') }}
|
|
|
|
|
</flux:button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</flux:modal>
|
|
|
|
|
</div>
|