Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8be732ada8 | ||
|
|
9eac4c4d4e | ||
|
|
e274a8d2b1 | ||
|
|
f3d2b3e39e | ||
|
|
1d9bcefb41 | ||
|
|
38c5b43018 | ||
|
|
f24bd3cc35 |
+4
-1
@@ -34,7 +34,10 @@ class EloquentExpenseQueries implements ExpenseQueries
|
|||||||
|
|
||||||
return $this->summaries(ExpenseModel::query()
|
return $this->summaries(ExpenseModel::query()
|
||||||
->where('user_id', $userId)
|
->where('user_id', $userId)
|
||||||
->whereBetween('spent_on', [$start->toDateString(), $start->copy()->endOfMonth()->toDateString()]));
|
// An upper bound before the next month: SQLite keeps date casts as "Y-m-d 00:00:00",
|
||||||
|
// which a between ending at the month's last "Y-m-d" would leave out.
|
||||||
|
->where('spent_on', '>=', $start->toDateString())
|
||||||
|
->where('spent_on', '<', $start->copy()->addMonth()->toDateString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find(int $id): ?ExpenseSummary
|
public function find(int $id): ?ExpenseSummary
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ final class MoveBoardCard
|
|||||||
$jobPositions = [];
|
$jobPositions = [];
|
||||||
$taskPositions = [];
|
$taskPositions = [];
|
||||||
|
|
||||||
foreach (array_values($orderedKeys) as $index => $key) {
|
foreach ($orderedKeys as $index => $key) {
|
||||||
if (preg_match('/^(job|task)-(\d+)$/', $key, $matches) !== 1) {
|
if (preg_match('/^(job|task)-(\d+)$/', $key, $matches) !== 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,20 +12,26 @@ use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* One user's Kanban board settings: card density, the urgent threshold,
|
* One user's Kanban board settings: card density, the urgent threshold,
|
||||||
* and their own colour and order for each column. A column without a
|
* their own colour and order for each column, and which cards they keep
|
||||||
* colour of its own uses the design's default colour.
|
* open (task list shown). A column without a colour of its own uses the
|
||||||
|
* design's default colour.
|
||||||
*/
|
*/
|
||||||
final readonly class BoardPreferences
|
final readonly class BoardPreferences
|
||||||
{
|
{
|
||||||
|
/** At most this many open cards are remembered, the latest kept. */
|
||||||
|
public const int MAX_EXPANDED_CARDS = 500;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, HexColor> $columnColors by BoardColumn value
|
* @param array<string, HexColor> $columnColors by BoardColumn value
|
||||||
* @param array<string, ColumnSort> $columnSorts by BoardColumn value
|
* @param array<string, ColumnSort> $columnSorts by BoardColumn value
|
||||||
|
* @param list<string> $expandedCards card keys ("job-12", "task-34"), oldest first
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public BoardDensity $density = BoardDensity::Normal,
|
public BoardDensity $density = BoardDensity::Normal,
|
||||||
public UrgentThreshold $urgentThreshold = UrgentThreshold::Urgent,
|
public UrgentThreshold $urgentThreshold = UrgentThreshold::Urgent,
|
||||||
public array $columnColors = [],
|
public array $columnColors = [],
|
||||||
public array $columnSorts = [],
|
public array $columnSorts = [],
|
||||||
|
public array $expandedCards = [],
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public static function defaults(): self
|
public static function defaults(): self
|
||||||
@@ -33,14 +39,20 @@ final readonly class BoardPreferences
|
|||||||
return new self;
|
return new self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isCardKey(string $key): bool
|
||||||
|
{
|
||||||
|
return preg_match('/^(job|task)-\d+$/', $key) === 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuilds stored settings, dropping unknown columns and invalid values
|
* Rebuilds stored settings, dropping unknown columns and invalid values
|
||||||
* so a bad stored value never breaks the board.
|
* so a bad stored value never breaks the board.
|
||||||
*
|
*
|
||||||
* @param array<array-key, mixed> $colors
|
* @param array<array-key, mixed> $colors
|
||||||
* @param array<array-key, mixed> $sorts
|
* @param array<array-key, mixed> $sorts
|
||||||
|
* @param array<array-key, mixed> $expanded
|
||||||
*/
|
*/
|
||||||
public static function fromStored(?string $density, ?string $threshold, array $colors, array $sorts): self
|
public static function fromStored(?string $density, ?string $threshold, array $colors, array $sorts, array $expanded = []): self
|
||||||
{
|
{
|
||||||
$columnColors = [];
|
$columnColors = [];
|
||||||
|
|
||||||
@@ -60,11 +72,14 @@ final readonly class BoardPreferences
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$expandedCards = array_values(array_unique(array_filter($expanded, fn ($key): bool => is_string($key) && self::isCardKey($key))));
|
||||||
|
|
||||||
return new self(
|
return new self(
|
||||||
BoardDensity::tryFrom((string) $density) ?? BoardDensity::Normal,
|
BoardDensity::tryFrom((string) $density) ?? BoardDensity::Normal,
|
||||||
UrgentThreshold::tryFrom((string) $threshold) ?? UrgentThreshold::Urgent,
|
UrgentThreshold::tryFrom((string) $threshold) ?? UrgentThreshold::Urgent,
|
||||||
$columnColors,
|
$columnColors,
|
||||||
$columnSorts,
|
$columnSorts,
|
||||||
|
array_slice($expandedCards, -self::MAX_EXPANDED_CARDS),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,14 +98,19 @@ final readonly class BoardPreferences
|
|||||||
return $this->columnSorts[$column->value] ?? ColumnSort::Manual;
|
return $this->columnSorts[$column->value] ?? ColumnSort::Manual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isCardExpanded(string $key): bool
|
||||||
|
{
|
||||||
|
return in_array($key, $this->expandedCards, true);
|
||||||
|
}
|
||||||
|
|
||||||
public function withDensity(BoardDensity $density): self
|
public function withDensity(BoardDensity $density): self
|
||||||
{
|
{
|
||||||
return new self($density, $this->urgentThreshold, $this->columnColors, $this->columnSorts);
|
return new self($density, $this->urgentThreshold, $this->columnColors, $this->columnSorts, $this->expandedCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withUrgentThreshold(UrgentThreshold $threshold): self
|
public function withUrgentThreshold(UrgentThreshold $threshold): self
|
||||||
{
|
{
|
||||||
return new self($this->density, $threshold, $this->columnColors, $this->columnSorts);
|
return new self($this->density, $threshold, $this->columnColors, $this->columnSorts, $this->expandedCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,7 +126,7 @@ final readonly class BoardPreferences
|
|||||||
$colors[$column->value] = $color;
|
$colors[$column->value] = $color;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new self($this->density, $this->urgentThreshold, $colors, $this->columnSorts);
|
return new self($this->density, $this->urgentThreshold, $colors, $this->columnSorts, $this->expandedCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withColumnSort(BoardColumn $column, ColumnSort $sort): self
|
public function withColumnSort(BoardColumn $column, ColumnSort $sort): self
|
||||||
@@ -114,7 +134,26 @@ final readonly class BoardPreferences
|
|||||||
$sorts = $this->columnSorts;
|
$sorts = $this->columnSorts;
|
||||||
$sorts[$column->value] = $sort;
|
$sorts[$column->value] = $sort;
|
||||||
|
|
||||||
return new self($this->density, $this->urgentThreshold, $this->columnColors, $sorts);
|
return new self($this->density, $this->urgentThreshold, $this->columnColors, $sorts, $this->expandedCards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens or closes a card's task list for this user. A card key that is
|
||||||
|
* not one ("job-12" / "task-34") changes nothing.
|
||||||
|
*/
|
||||||
|
public function withCardExpanded(string $key, bool $expanded): self
|
||||||
|
{
|
||||||
|
if (! self::isCardKey($key)) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cards = array_values(array_diff($this->expandedCards, [$key]));
|
||||||
|
|
||||||
|
if ($expanded) {
|
||||||
|
$cards[] = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new self($this->density, $this->urgentThreshold, $this->columnColors, $this->columnSorts, array_slice($cards, -self::MAX_EXPANDED_CARDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
* @property string $urgent_threshold
|
* @property string $urgent_threshold
|
||||||
* @property array<string, string>|null $column_colors
|
* @property array<string, string>|null $column_colors
|
||||||
* @property array<string, string>|null $column_sorts
|
* @property array<string, string>|null $column_sorts
|
||||||
|
* @property list<string>|null $expanded_cards
|
||||||
*/
|
*/
|
||||||
#[Table('job_board_preferences')]
|
#[Table('job_board_preferences')]
|
||||||
#[Fillable(['user_id', 'density', 'urgent_threshold', 'column_colors', 'column_sorts'])]
|
#[Fillable(['user_id', 'density', 'urgent_threshold', 'column_colors', 'column_sorts', 'expanded_cards'])]
|
||||||
class JobBoardPreferenceModel extends Model
|
class JobBoardPreferenceModel extends Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -29,6 +30,7 @@ class JobBoardPreferenceModel extends Model
|
|||||||
'user_id' => 'integer',
|
'user_id' => 'integer',
|
||||||
'column_colors' => 'array',
|
'column_colors' => 'array',
|
||||||
'column_sorts' => 'array',
|
'column_sorts' => 'array',
|
||||||
|
'expanded_cards' => 'array',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -38,7 +38,7 @@ class EloquentBoardRepository implements BoardRepository
|
|||||||
|
|
||||||
return $model === null
|
return $model === null
|
||||||
? BoardPreferences::defaults()
|
? BoardPreferences::defaults()
|
||||||
: BoardPreferences::fromStored($model->density, $model->urgent_threshold, $model->column_colors ?? [], $model->column_sorts ?? []);
|
: BoardPreferences::fromStored($model->density, $model->urgent_threshold, $model->column_colors ?? [], $model->column_sorts ?? [], $model->expanded_cards ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function savePreferences(int $userId, BoardPreferences $preferences): void
|
public function savePreferences(int $userId, BoardPreferences $preferences): void
|
||||||
@@ -48,6 +48,7 @@ class EloquentBoardRepository implements BoardRepository
|
|||||||
'urgent_threshold' => $preferences->urgentThreshold->value,
|
'urgent_threshold' => $preferences->urgentThreshold->value,
|
||||||
'column_colors' => $preferences->colorValues(),
|
'column_colors' => $preferences->colorValues(),
|
||||||
'column_sorts' => $preferences->sortValues(),
|
'column_sorts' => $preferences->sortValues(),
|
||||||
|
'expanded_cards' => $preferences->expandedCards,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ use App\Modules\Users\Domain\Enums\Role;
|
|||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Livewire\Attributes\Computed;
|
use Livewire\Attributes\Computed;
|
||||||
use Livewire\Attributes\On;
|
use Livewire\Attributes\On;
|
||||||
|
use Livewire\Attributes\Renderless;
|
||||||
use Livewire\Attributes\Url;
|
use Livewire\Attributes\Url;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
@@ -387,9 +388,24 @@ new class extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->refreshBoard();
|
$this->refreshBoard();
|
||||||
|
$this->dispatch('customer-color-changed', customerId: $customerId);
|
||||||
$this->statusMessage = __('jobs.board.customer_color_saved', ['customer' => $card->customerName ?? '']);
|
$this->statusMessage = __('jobs.board.customer_color_saved', ['customer' => $card->customerName ?? '']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A card's task list opened or closed: remembered for this user only.
|
||||||
|
* Renderless, so opening a card does not redraw the board.
|
||||||
|
*/
|
||||||
|
#[Renderless]
|
||||||
|
public function setCardExpanded(string $key, bool $expanded): void
|
||||||
|
{
|
||||||
|
if ($this->findCard($key) === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->savePreferences($this->preferences->withCardExpanded($key, $expanded));
|
||||||
|
}
|
||||||
|
|
||||||
public function setColumnColor(string $columnValue, ?string $color): void
|
public function setColumnColor(string $columnValue, ?string $color): void
|
||||||
{
|
{
|
||||||
$column = BoardColumn::tryFrom($columnValue);
|
$column = BoardColumn::tryFrom($columnValue);
|
||||||
@@ -771,6 +787,7 @@ new class extends Component
|
|||||||
@elseif ($card->isOngoing())
|
@elseif ($card->isOngoing())
|
||||||
<x-jobs.board.ongoing-card
|
<x-jobs.board.ongoing-card
|
||||||
:card="$card"
|
:card="$card"
|
||||||
|
:expanded="$this->preferences->isCardExpanded($card->key())"
|
||||||
:compact="$compact"
|
:compact="$compact"
|
||||||
:can-move="$canMove"
|
:can-move="$canMove"
|
||||||
:can-color="$canColor"
|
:can-color="$canColor"
|
||||||
@@ -780,6 +797,7 @@ new class extends Component
|
|||||||
@else
|
@else
|
||||||
<x-jobs.board.job-card
|
<x-jobs.board.job-card
|
||||||
:card="$card"
|
:card="$card"
|
||||||
|
:expanded="$this->preferences->isCardExpanded($card->key())"
|
||||||
:compact="$compact"
|
:compact="$compact"
|
||||||
:can-move="$canMove"
|
:can-move="$canMove"
|
||||||
:can-color="$canColor"
|
:can-color="$canColor"
|
||||||
|
|||||||
@@ -130,6 +130,23 @@ new class extends Component
|
|||||||
return $this->jobId === null ? [] : app(TaskQueries::class)->pinnedTaskIds($this->jobId);
|
return $this->jobId === null ? [] : app(TaskQueries::class)->pinnedTaskIds($this->jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The colour picker lives on the board, so the board tells the editor
|
||||||
|
* when a customer's colour changed; the header colour is read on render.
|
||||||
|
*/
|
||||||
|
#[On('customer-color-changed')]
|
||||||
|
public function customerColorChanged(): void
|
||||||
|
{
|
||||||
|
unset($this->job);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[On('task-comments-changed')]
|
||||||
|
#[On('task-images-changed')]
|
||||||
|
public function refreshTasks(): void
|
||||||
|
{
|
||||||
|
unset($this->tasks);
|
||||||
|
}
|
||||||
|
|
||||||
public function canEdit(): bool
|
public function canEdit(): bool
|
||||||
{
|
{
|
||||||
return Gate::allows('jobs.manage');
|
return Gate::allows('jobs.manage');
|
||||||
@@ -436,6 +453,7 @@ new class extends Component
|
|||||||
$staff = collect($this->users)->reject(fn ($user) => $user->role === Role::Subcontractor);
|
$staff = collect($this->users)->reject(fn ($user) => $user->role === Role::Subcontractor);
|
||||||
$headerColor = new HexColor($job?->customer->id !== null ? (app(\App\Modules\Customers\Application\Contracts\CustomerQueries::class)->headerColorsByIds([$job->customer->id])[$job->customer->id] ?? '#23476a') : '#23476a');
|
$headerColor = new HexColor($job?->customer->id !== null ? (app(\App\Modules\Customers\Application\Contracts\CustomerQueries::class)->headerColorsByIds([$job->customer->id])[$job->customer->id] ?? '#23476a') : '#23476a');
|
||||||
$fieldClass = 'w-full rounded-lg border border-neutral-400 bg-white px-2.5 py-1.5 text-xs text-neutral-900 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:bg-[#24262a] dark:text-white dark:focus-visible:outline-primary-300';
|
$fieldClass = 'w-full rounded-lg border border-neutral-400 bg-white px-2.5 py-1.5 text-xs text-neutral-900 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:bg-[#24262a] dark:text-white dark:focus-visible:outline-primary-300';
|
||||||
|
$controlClass = 'w-auto max-w-full rounded-lg border border-neutral-400 bg-white px-2.5 py-1.5 text-xs text-neutral-900 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:bg-[#24262a] dark:text-white dark:focus-visible:outline-primary-300';
|
||||||
$labelClass = 'mb-1 block text-[11px] font-semibold text-neutral-800 dark:text-neutral-100';
|
$labelClass = 'mb-1 block text-[11px] font-semibold text-neutral-800 dark:text-neutral-100';
|
||||||
$boxClass = 'space-y-2.5 rounded-xl border border-neutral-200 bg-neutral-100 p-3.5 dark:border-[#36393f] dark:bg-[#18191b]';
|
$boxClass = 'space-y-2.5 rounded-xl border border-neutral-200 bg-neutral-100 p-3.5 dark:border-[#36393f] dark:bg-[#18191b]';
|
||||||
$boxHeading = 'text-[10px] font-extrabold tracking-wider text-neutral-700 uppercase dark:text-neutral-200';
|
$boxHeading = 'text-[10px] font-extrabold tracking-wider text-neutral-700 uppercase dark:text-neutral-200';
|
||||||
@@ -598,7 +616,7 @@ new class extends Component
|
|||||||
@if (Gate::allows('jobs.manage-tasks', [$job->id]) && $this->templates !== [] && $job->status->allowsTasks())
|
@if (Gate::allows('jobs.manage-tasks', [$job->id]) && $this->templates !== [] && $job->status->allowsTasks())
|
||||||
<form wire:submit="applyTemplate" class="flex items-center gap-1.5">
|
<form wire:submit="applyTemplate" class="flex items-center gap-1.5">
|
||||||
<label for="job-editor-template" class="sr-only">{{ __('jobs.editor.template') }}</label>
|
<label for="job-editor-template" class="sr-only">{{ __('jobs.editor.template') }}</label>
|
||||||
<select id="job-editor-template" wire:model="templateId" class="{{ $fieldClass }} w-auto py-1 text-[11px]">
|
<select id="job-editor-template" wire:model="templateId" class="{{ $controlClass }} py-1 text-[11px]">
|
||||||
<option value="">{{ __('jobs.editor.template_choose') }}</option>
|
<option value="">{{ __('jobs.editor.template_choose') }}</option>
|
||||||
@foreach ($this->templates as $template)
|
@foreach ($this->templates as $template)
|
||||||
<option value="{{ $template->id }}">{{ $template->name }}</option>
|
<option value="{{ $template->id }}">{{ $template->name }}</option>
|
||||||
@@ -616,7 +634,7 @@ new class extends Component
|
|||||||
<ul class="space-y-2">
|
<ul class="space-y-2">
|
||||||
@foreach ($this->tasks as $task)
|
@foreach ($this->tasks as $task)
|
||||||
@php($canManageTask = Gate::allows('jobs.manage-tasks', [$job->id]))
|
@php($canManageTask = Gate::allows('jobs.manage-tasks', [$job->id]))
|
||||||
<li wire:key="editor-task-{{ $task->id }}" x-data="{ checklist: false }" class="space-y-2 rounded-xl border border-neutral-200 bg-white p-2.5 text-xs dark:border-[#36393f] dark:bg-[#25272b]">
|
<li wire:key="editor-task-{{ $task->id }}" x-data="{ checklist: false, extras: false }" class="space-y-2 rounded-xl border border-neutral-200 bg-white p-2.5 text-xs dark:border-[#36393f] dark:bg-[#25272b]">
|
||||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||||
<div class="flex min-w-0 flex-1 items-center gap-2">
|
<div class="flex min-w-0 flex-1 items-center gap-2">
|
||||||
<input
|
<input
|
||||||
@@ -646,20 +664,20 @@ new class extends Component
|
|||||||
@if ($canManageTask)
|
@if ($canManageTask)
|
||||||
<div class="flex flex-wrap items-center gap-1.5">
|
<div class="flex flex-wrap items-center gap-1.5">
|
||||||
<label for="editor-task-status-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_status', ['task' => $task->title]) }}</label>
|
<label for="editor-task-status-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_status', ['task' => $task->title]) }}</label>
|
||||||
<select id="editor-task-status-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'status', $event.target.value)" class="{{ $fieldClass }} w-auto py-0.5 text-[11px]">
|
<select id="editor-task-status-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'status', $event.target.value)" class="{{ $controlClass }} py-0.5 text-[11px]">
|
||||||
@foreach (TaskStatus::cases() as $taskStatus)
|
@foreach (TaskStatus::cases() as $taskStatus)
|
||||||
<option value="{{ $taskStatus->value }}" @selected($taskStatus === $task->status)>{{ __('jobs.tasks.statuses.'.$taskStatus->value) }}</option>
|
<option value="{{ $taskStatus->value }}" @selected($taskStatus === $task->status)>{{ __('jobs.tasks.statuses.'.$taskStatus->value) }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
<label for="editor-task-assignee-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_assignee', ['task' => $task->title]) }}</label>
|
<label for="editor-task-assignee-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_assignee', ['task' => $task->title]) }}</label>
|
||||||
<select id="editor-task-assignee-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'assignee', $event.target.value)" class="{{ $fieldClass }} w-auto py-0.5 text-[11px]">
|
<select id="editor-task-assignee-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'assignee', $event.target.value)" class="{{ $controlClass }} py-0.5 text-[11px]">
|
||||||
<option value="">{{ __('jobs.editor.no_assignee') }}</option>
|
<option value="">{{ __('jobs.editor.no_assignee') }}</option>
|
||||||
@foreach ($this->users as $user)
|
@foreach ($this->users as $user)
|
||||||
<option value="{{ $user->id }}" @selected($user->id === $task->assignee?->id)>{{ $user->name }}</option>
|
<option value="{{ $user->id }}" @selected($user->id === $task->assignee?->id)>{{ $user->name }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
<label for="editor-task-due-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_due', ['task' => $task->title]) }}</label>
|
<label for="editor-task-due-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_due', ['task' => $task->title]) }}</label>
|
||||||
<input id="editor-task-due-{{ $task->id }}" type="date" value="{{ $task->dueOn }}" wire:change="updateTaskField({{ $task->id }}, 'due_on', $event.target.value)" class="{{ $fieldClass }} w-auto py-0.5 text-[11px]" />
|
<input id="editor-task-due-{{ $task->id }}" type="date" value="{{ $task->dueOn }}" wire:change="updateTaskField({{ $task->id }}, 'due_on', $event.target.value)" class="{{ $controlClass }} py-0.5 text-[11px]" />
|
||||||
@if ($job->status === JobStatus::Ongoing)
|
@if ($job->status === JobStatus::Ongoing)
|
||||||
@php($pinned = $this->pinnedTasks[$task->id] ?? false)
|
@php($pinned = $this->pinnedTasks[$task->id] ?? false)
|
||||||
<button
|
<button
|
||||||
@@ -674,20 +692,49 @@ new class extends Component
|
|||||||
</div>
|
</div>
|
||||||
@error('tasks.'.$task->id) <p class="text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
@error('tasks.'.$task->id) <p class="text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||||||
|
|
||||||
<div class="pl-6">
|
<div class="space-y-1 pl-6">
|
||||||
<button
|
<div class="flex flex-wrap gap-3">
|
||||||
type="button"
|
<button
|
||||||
x-on:click="checklist = ! checklist"
|
type="button"
|
||||||
x-bind:aria-expanded="checklist.toString()"
|
x-on:click="checklist = ! checklist"
|
||||||
aria-controls="editor-checklist-{{ $task->id }}"
|
x-bind:aria-expanded="checklist.toString()"
|
||||||
class="inline-flex min-h-6 items-center gap-1 rounded text-[11px] font-semibold text-indigo-800 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-indigo-100 dark:focus-visible:outline-primary-300"
|
aria-controls="editor-checklist-{{ $task->id }}"
|
||||||
>
|
class="inline-flex min-h-6 items-center gap-1 rounded text-[11px] font-semibold text-indigo-800 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-indigo-100 dark:focus-visible:outline-primary-300"
|
||||||
<x-icon name="chevron-right" class="size-3 transition" x-bind:class="checklist && 'rotate-90'" aria-hidden="true" />
|
>
|
||||||
{{ __('jobs.editor.checklist') }}
|
<x-icon name="chevron-right" class="size-3 transition" x-bind:class="checklist && 'rotate-90'" aria-hidden="true" />
|
||||||
</button>
|
{{ __('jobs.editor.checklist') }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
x-on:click="extras = ! extras"
|
||||||
|
x-bind:aria-expanded="extras.toString()"
|
||||||
|
aria-controls="editor-extras-{{ $task->id }}"
|
||||||
|
class="inline-flex min-h-6 items-center gap-1 rounded text-[11px] font-semibold text-indigo-800 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-indigo-100 dark:focus-visible:outline-primary-300"
|
||||||
|
>
|
||||||
|
<x-icon name="chevron-right" class="size-3 transition" x-bind:class="extras && 'rotate-90'" aria-hidden="true" />
|
||||||
|
{{ __('jobs.editor.extras', ['comments' => $task->commentCount, 'images' => $task->imageCount]) }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div id="editor-checklist-{{ $task->id }}" x-show="checklist" x-cloak class="pt-1">
|
<div id="editor-checklist-{{ $task->id }}" x-show="checklist" x-cloak class="pt-1">
|
||||||
<livewire:jobs::task-checklist :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-checklist-'.$task->id" />
|
<livewire:jobs::task-checklist :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-checklist-'.$task->id" />
|
||||||
</div>
|
</div>
|
||||||
|
<div id="editor-extras-{{ $task->id }}" x-show="extras" x-cloak class="pt-1">
|
||||||
|
<x-tabs
|
||||||
|
id="editor-task-{{ $task->id }}-tabs"
|
||||||
|
:label="__('jobs.tasks.tabs.label', ['title' => $task->title])"
|
||||||
|
:tabs="[
|
||||||
|
'comments' => __('jobs.editor.tab_comments', ['count' => $task->commentCount]),
|
||||||
|
'images' => __('jobs.editor.tab_images', ['count' => $task->imageCount]),
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<x-tabs.panel tabs-id="editor-task-{{ $task->id }}-tabs" name="comments">
|
||||||
|
<livewire:jobs::task-comments :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-comments-'.$task->id" />
|
||||||
|
</x-tabs.panel>
|
||||||
|
<x-tabs.panel tabs-id="editor-task-{{ $task->id }}-tabs" name="images">
|
||||||
|
<livewire:jobs::task-images :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-images-'.$task->id" />
|
||||||
|
</x-tabs.panel>
|
||||||
|
</x-tabs>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
@@ -699,7 +746,7 @@ new class extends Component
|
|||||||
<label for="job-editor-new-task" class="sr-only">{{ __('jobs.editor.new_task') }}</label>
|
<label for="job-editor-new-task" class="sr-only">{{ __('jobs.editor.new_task') }}</label>
|
||||||
<input id="job-editor-new-task" type="text" wire:model="newTaskTitle" maxlength="255" placeholder="{{ __('jobs.editor.new_task_placeholder') }}" class="{{ $fieldClass }} min-w-[200px] flex-1 placeholder:text-neutral-600 dark:placeholder:text-neutral-300" />
|
<input id="job-editor-new-task" type="text" wire:model="newTaskTitle" maxlength="255" placeholder="{{ __('jobs.editor.new_task_placeholder') }}" class="{{ $fieldClass }} min-w-[200px] flex-1 placeholder:text-neutral-600 dark:placeholder:text-neutral-300" />
|
||||||
<label for="job-editor-new-task-assignee" class="sr-only">{{ __('jobs.editor.new_task_assignee') }}</label>
|
<label for="job-editor-new-task-assignee" class="sr-only">{{ __('jobs.editor.new_task_assignee') }}</label>
|
||||||
<select id="job-editor-new-task-assignee" wire:model="newTaskAssignee" class="{{ $fieldClass }} w-auto">
|
<select id="job-editor-new-task-assignee" wire:model="newTaskAssignee" class="{{ $controlClass }}">
|
||||||
<option value="">{{ __('jobs.editor.no_assignee') }}</option>
|
<option value="">{{ __('jobs.editor.no_assignee') }}</option>
|
||||||
@foreach ($this->users as $user)
|
@foreach ($this->users as $user)
|
||||||
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
||||||
@@ -809,6 +856,7 @@ new class extends Component
|
|||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
<x-checkbox-group
|
<x-checkbox-group
|
||||||
|
:columns="2"
|
||||||
:legend="__('jobs.fields.members')"
|
:legend="__('jobs.fields.members')"
|
||||||
model="form.member_user_ids"
|
model="form.member_user_ids"
|
||||||
:options="collect($this->users)->map(fn ($user) => ['value' => $user->id, 'label' => $user->name, 'note' => $user->role === Role::Subcontractor ? __('users.roles.subcontractor') : null])->all()"
|
:options="collect($this->users)->map(fn ($user) => ['value' => $user->id, 'label' => $user->name, 'note' => $user->role === Role::Subcontractor ? __('users.roles.subcontractor') : null])->all()"
|
||||||
@@ -817,7 +865,7 @@ new class extends Component
|
|||||||
|
|
||||||
<section aria-labelledby="job-editor-units-heading" class="{{ $boxClass }}">
|
<section aria-labelledby="job-editor-units-heading" class="{{ $boxClass }}">
|
||||||
<h3 id="job-editor-units-heading" class="{{ $boxHeading }}">{{ __('jobs.editor.units_section') }}</h3>
|
<h3 id="job-editor-units-heading" class="{{ $boxHeading }}">{{ __('jobs.editor.units_section') }}</h3>
|
||||||
<x-checkbox-group :legend="__('jobs.fields.service_units')" model="form.service_unit_ids" :options="$this->serviceUnitOptions" />
|
<x-checkbox-group :columns="2" :legend="__('jobs.fields.service_units')" model="form.service_unit_ids" :options="$this->serviceUnitOptions" />
|
||||||
<div class="space-y-1.5">
|
<div class="space-y-1.5">
|
||||||
<p id="editor-tags-label" class="{{ $labelClass }}">{{ __('jobs.fields.tags') }}</p>
|
<p id="editor-tags-label" class="{{ $labelClass }}">{{ __('jobs.fields.tags') }}</p>
|
||||||
@if ($form->tags !== [])
|
@if ($form->tags !== [])
|
||||||
|
|||||||
+6
-3
@@ -42,7 +42,8 @@ class EloquentTimeEntryQueries implements TimeEntryQueries
|
|||||||
|
|
||||||
$entries = TimeEntryModel::query()
|
$entries = TimeEntryModel::query()
|
||||||
->where('user_id', $userId)
|
->where('user_id', $userId)
|
||||||
->whereBetween('worked_on', [$days[0], $days[6]])
|
->where('worked_on', '>=', $days[0])
|
||||||
|
->where('worked_on', '<', CarbonImmutable::parse($days[6])->addDay()->toDateString())
|
||||||
->get();
|
->get();
|
||||||
$pinnedIds = $this->pins->pinnedTaskIds($userId);
|
$pinnedIds = $this->pins->pinnedTaskIds($userId);
|
||||||
$scheduledIds = $this->tasks->scheduledTaskIdsFor($userId, $days[0], $days[6]);
|
$scheduledIds = $this->tasks->scheduledTaskIdsFor($userId, $days[0], $days[6]);
|
||||||
@@ -100,7 +101,8 @@ class EloquentTimeEntryQueries implements TimeEntryQueries
|
|||||||
$start = CarbonImmutable::createFromFormat('!Y-m', $month) ?: CarbonImmutable::now()->startOfMonth();
|
$start = CarbonImmutable::createFromFormat('!Y-m', $month) ?: CarbonImmutable::now()->startOfMonth();
|
||||||
$entries = TimeEntryModel::query()
|
$entries = TimeEntryModel::query()
|
||||||
->where('user_id', $userId)
|
->where('user_id', $userId)
|
||||||
->whereBetween('worked_on', [$start->toDateString(), $start->endOfMonth()->toDateString()])
|
->where('worked_on', '>=', $start->toDateString())
|
||||||
|
->where('worked_on', '<', $start->addMonth()->toDateString())
|
||||||
->get();
|
->get();
|
||||||
$paymentBases = [];
|
$paymentBases = [];
|
||||||
|
|
||||||
@@ -135,7 +137,8 @@ class EloquentTimeEntryQueries implements TimeEntryQueries
|
|||||||
|
|
||||||
$entries = TimeEntryModel::query()
|
$entries = TimeEntryModel::query()
|
||||||
->where('user_id', $userId)
|
->where('user_id', $userId)
|
||||||
->whereBetween('worked_on', [$days[0], $days[6]])
|
->where('worked_on', '>=', $days[0])
|
||||||
|
->where('worked_on', '<', CarbonImmutable::parse($days[6])->addDay()->toDateString())
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$taskIds = array_values(array_unique(array_merge(
|
$taskIds = array_values(array_unique(array_merge(
|
||||||
|
|||||||
+3
-1
@@ -55,7 +55,9 @@ class EloquentTimeEntryRepository implements TimeEntryRepository
|
|||||||
{
|
{
|
||||||
return TimeEntryModel::query()
|
return TimeEntryModel::query()
|
||||||
->where('user_id', $userId)
|
->where('user_id', $userId)
|
||||||
->whereBetween('worked_on', [$from->format('Y-m-d'), $to->format('Y-m-d')])
|
// Exclusive upper bound: SQLite keeps date casts as "Y-m-d 00:00:00".
|
||||||
|
->where('worked_on', '>=', $from->format('Y-m-d'))
|
||||||
|
->where('worked_on', '<', $to->modify('+1 day')->format('Y-m-d'))
|
||||||
->orderBy('worked_on')
|
->orderBy('worked_on')
|
||||||
->get()
|
->get()
|
||||||
->map(fn (TimeEntryModel $model): TimeEntry => $this->toEntity($model))
|
->map(fn (TimeEntryModel $model): TimeEntry => $this->toEntity($model))
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Cards whose task list the user keeps open on the board ("job-12", "task-34").
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('job_board_preferences', function (Blueprint $table) {
|
||||||
|
$table->json('expanded_cards')->nullable()->after('column_sorts');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('job_board_preferences', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('expanded_cards');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -308,6 +308,9 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
'editor' => [
|
'editor' => [
|
||||||
|
'extras' => 'Comments and images (comments :comments, images :images)',
|
||||||
|
'tab_comments' => 'Comments (:count)',
|
||||||
|
'tab_images' => 'Images (:count)',
|
||||||
'heading' => 'Customer job :number',
|
'heading' => 'Customer job :number',
|
||||||
'close' => 'Close the card',
|
'close' => 'Close the card',
|
||||||
'color' => 'Colour',
|
'color' => 'Colour',
|
||||||
|
|||||||
@@ -308,6 +308,9 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
'editor' => [
|
'editor' => [
|
||||||
|
'extras' => 'Kommentit ja kuvat (kommentit :comments, kuvat :images)',
|
||||||
|
'tab_comments' => 'Kommentit (:count)',
|
||||||
|
'tab_images' => 'Kuvat (:count)',
|
||||||
'heading' => 'Asiakastyö :number',
|
'heading' => 'Asiakastyö :number',
|
||||||
'close' => 'Sulje kortti',
|
'close' => 'Sulje kortti',
|
||||||
'color' => 'Väri',
|
'color' => 'Väri',
|
||||||
|
|||||||
@@ -60,6 +60,15 @@ html {
|
|||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Native controls (the date picker's calendar icon and popup, select arrows,
|
||||||
|
* scrollbars) follow the page theme. html.dark, not .dark: the header always
|
||||||
|
* carries .dark.
|
||||||
|
*/
|
||||||
|
html.dark {
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
[x-cloak] {
|
[x-cloak] {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
'model',
|
'model',
|
||||||
'options',
|
'options',
|
||||||
'hint' => null,
|
'hint' => null,
|
||||||
'columns' => true,
|
'columns' => true, // true: 2 from sm and 3 from lg; 2: always two; false: one
|
||||||
])
|
])
|
||||||
|
|
||||||
@php
|
@php
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
<p id="{{ $id }}-hint" class="text-sm text-zinc-600 dark:text-zinc-200">{{ $hint }}</p>
|
<p id="{{ $id }}-hint" class="text-sm text-zinc-600 dark:text-zinc-200">{{ $hint }}</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<div @class(['grid gap-2', 'sm:grid-cols-2 lg:grid-cols-3' => $columns])>
|
<div @class(['grid gap-2', 'grid-cols-2' => $columns === 2, 'sm:grid-cols-2 lg:grid-cols-3' => $columns === true])>
|
||||||
@foreach ($options as $option)
|
@foreach ($options as $option)
|
||||||
<label wire:key="{{ $id }}-{{ $option['value'] }}" class="flex min-h-6 cursor-pointer items-start gap-2 text-sm">
|
<label wire:key="{{ $id }}-{{ $option['value'] }}" class="flex min-h-6 cursor-pointer items-start gap-2 text-sm">
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
due date, hours and the job's tasks, which open inside the card and can
|
due date, hours and the job's tasks, which open inside the card and can
|
||||||
be marked done. Compact cards have three rows.
|
be marked done. Compact cards have three rows.
|
||||||
--}}
|
--}}
|
||||||
@props(['card', 'compact' => false, 'canMove' => false, 'canColor' => false, 'canCheck' => false])
|
@props(['card', 'expanded' => false, 'compact' => false, 'canMove' => false, 'canColor' => false, 'canCheck' => false])
|
||||||
|
|
||||||
@use('App\Modules\Jobs\Presentation\Support\BoardFormat')
|
@use('App\Modules\Jobs\Presentation\Support\BoardFormat')
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<article
|
<article
|
||||||
aria-labelledby="card-{{ $card->key() }}-title"
|
aria-labelledby="card-{{ $card->key() }}-title"
|
||||||
x-data="{ expanded: false }"
|
x-data="{ expanded: {{ $expanded ? 'true' : 'false' }} }"
|
||||||
class="overflow-hidden rounded-xl border border-neutral-300 bg-white shadow-sm transition dark:border-[#36393f] dark:bg-[#282a2e]"
|
class="overflow-hidden rounded-xl border border-neutral-300 bg-white shadow-sm transition dark:border-[#36393f] dark:bg-[#282a2e]"
|
||||||
>
|
>
|
||||||
<x-jobs.board.card-header :card="$card" :can-move="$canMove" :can-color="$canColor" />
|
<x-jobs.board.card-header :card="$card" :can-move="$canMove" :can-color="$canColor" />
|
||||||
@@ -40,7 +40,8 @@
|
|||||||
@if ($total > 0)
|
@if ($total > 0)
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
x-on:click="expanded = ! expanded"
|
x-on:click="expanded = ! expanded; $wire.setCardExpanded('{{ $card->key() }}', expanded)"
|
||||||
|
aria-expanded="{{ $expanded ? 'true' : 'false' }}"
|
||||||
x-bind:aria-expanded="expanded.toString()"
|
x-bind:aria-expanded="expanded.toString()"
|
||||||
aria-controls="tasks-{{ $card->key() }}"
|
aria-controls="tasks-{{ $card->key() }}"
|
||||||
aria-label="{{ __('jobs.board.tasks_compact', ['done' => $done, 'total' => $total]) }}"
|
aria-label="{{ __('jobs.board.tasks_compact', ['done' => $done, 'total' => $total]) }}"
|
||||||
@@ -78,7 +79,8 @@
|
|||||||
<div class="border-t border-neutral-200 pt-1 dark:border-[#36393f]">
|
<div class="border-t border-neutral-200 pt-1 dark:border-[#36393f]">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
x-on:click="expanded = ! expanded"
|
x-on:click="expanded = ! expanded; $wire.setCardExpanded('{{ $card->key() }}', expanded)"
|
||||||
|
aria-expanded="{{ $expanded ? 'true' : 'false' }}"
|
||||||
x-bind:aria-expanded="expanded.toString()"
|
x-bind:aria-expanded="expanded.toString()"
|
||||||
aria-controls="tasks-{{ $card->key() }}"
|
aria-controls="tasks-{{ $card->key() }}"
|
||||||
class="flex min-h-6 w-full items-center justify-between rounded px-1.5 text-[11px] font-semibold text-neutral-800 transition hover:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-neutral-100 dark:hover:bg-[#32353b] dark:focus-visible:outline-primary-300"
|
class="flex min-h-6 w-full items-center justify-between rounded px-1.5 text-[11px] font-semibold text-neutral-800 transition hover:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-neutral-100 dark:hover:bg-[#32353b] dark:focus-visible:outline-primary-300"
|
||||||
@@ -91,7 +93,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if ($total > 0)
|
@if ($total > 0)
|
||||||
<div id="tasks-{{ $card->key() }}" x-show="expanded" x-cloak @class(['border-t border-neutral-200 pt-1 dark:border-[#36393f]' => $compact, 'mt-1.5' => ! $compact])>
|
<div id="tasks-{{ $card->key() }}" x-show="expanded" @unless ($expanded) x-cloak @endunless @class(['border-t border-neutral-200 pt-1 dark:border-[#36393f]' => $compact, 'mt-1.5' => ! $compact])>
|
||||||
<x-jobs.board.task-list :card="$card" :can-check="$canCheck" :compact="$compact" />
|
<x-jobs.board.task-list :card="$card" :can-check="$canCheck" :compact="$compact" />
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
role="menuitemradio"
|
role="menuitemradio"
|
||||||
aria-checked="{{ $value === $current ? 'true' : 'false' }}"
|
aria-checked="{{ $value === $current ? 'true' : 'false' }}"
|
||||||
wire:click="{{ $method }}({{ collect([...$args, $value])->map(fn ($arg) => Js::from($arg))->join(', ') }})"
|
wire:click="{{ $method }}({{ collect([...$args, $value])->map(fn ($arg): string => Js::from($arg)->toHtml())->implode(', ') }})"
|
||||||
x-on:click="open = false; $refs.button.focus()"
|
x-on:click="open = false; $refs.button.focus()"
|
||||||
x-on:keydown.arrow-down.prevent="$el.nextElementSibling?.focus()"
|
x-on:keydown.arrow-down.prevent="$el.nextElementSibling?.focus()"
|
||||||
x-on:keydown.arrow-up.prevent="$el.previousElementSibling?.matches('button') && $el.previousElementSibling.focus()"
|
x-on:keydown.arrow-up.prevent="$el.previousElementSibling?.matches('button') && $el.previousElementSibling.focus()"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
open task with a one-click "mark done", lifting tasks into the pipeline
|
open task with a one-click "mark done", lifting tasks into the pipeline
|
||||||
(PIN), and all periods and tasks with a quick add.
|
(PIN), and all periods and tasks with a quick add.
|
||||||
--}}
|
--}}
|
||||||
@props(['card', 'compact' => false, 'canMove' => false, 'canColor' => false, 'canCheck' => false, 'canManage' => false])
|
@props(['card', 'expanded' => false, 'compact' => false, 'canMove' => false, 'canColor' => false, 'canCheck' => false, 'canManage' => false])
|
||||||
|
|
||||||
@php
|
@php
|
||||||
$total = count($card->tasks);
|
$total = count($card->tasks);
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<article
|
<article
|
||||||
aria-labelledby="card-{{ $card->key() }}-title"
|
aria-labelledby="card-{{ $card->key() }}-title"
|
||||||
x-data="{ expanded: false }"
|
x-data="{ expanded: {{ $expanded ? 'true' : 'false' }} }"
|
||||||
class="overflow-hidden rounded-xl border border-neutral-300 bg-white shadow-sm dark:border-[#36393f] dark:bg-[#282a2e]"
|
class="overflow-hidden rounded-xl border border-neutral-300 bg-white shadow-sm dark:border-[#36393f] dark:bg-[#282a2e]"
|
||||||
>
|
>
|
||||||
<x-jobs.board.card-header :card="$card" :can-move="$canMove" :can-color="$canColor" />
|
<x-jobs.board.card-header :card="$card" :can-move="$canMove" :can-color="$canColor" />
|
||||||
@@ -37,8 +37,9 @@
|
|||||||
@if ($compact)
|
@if ($compact)
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
x-on:click="expanded = ! expanded"
|
x-on:click="expanded = ! expanded; $wire.setCardExpanded('{{ $card->key() }}', expanded)"
|
||||||
x-bind:aria-expanded="expanded.toString()"
|
aria-expanded="{{ $expanded ? 'true' : 'false' }}"
|
||||||
|
x-bind:aria-expanded="expanded.toString()"
|
||||||
aria-controls="tasks-{{ $card->key() }}"
|
aria-controls="tasks-{{ $card->key() }}"
|
||||||
aria-label="{{ __('jobs.board.all_periods', ['done' => $done, 'total' => $total]) }}"
|
aria-label="{{ __('jobs.board.all_periods', ['done' => $done, 'total' => $total]) }}"
|
||||||
class="inline-flex min-h-6 shrink-0 items-center gap-0.5 rounded bg-neutral-100 px-1.5 text-[10px] font-bold text-neutral-800 transition hover:bg-neutral-200 focus-visible:outline-2 focus-visible:outline-primary-600 dark:bg-[#1e2023] dark:text-neutral-100 dark:hover:bg-[#32353b] dark:focus-visible:outline-primary-300"
|
class="inline-flex min-h-6 shrink-0 items-center gap-0.5 rounded bg-neutral-100 px-1.5 text-[10px] font-bold text-neutral-800 transition hover:bg-neutral-200 focus-visible:outline-2 focus-visible:outline-primary-600 dark:bg-[#1e2023] dark:text-neutral-100 dark:hover:bg-[#32353b] dark:focus-visible:outline-primary-300"
|
||||||
@@ -87,8 +88,9 @@
|
|||||||
<div class="border-t border-neutral-200 pt-1 dark:border-[#36393f]">
|
<div class="border-t border-neutral-200 pt-1 dark:border-[#36393f]">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
x-on:click="expanded = ! expanded"
|
x-on:click="expanded = ! expanded; $wire.setCardExpanded('{{ $card->key() }}', expanded)"
|
||||||
x-bind:aria-expanded="expanded.toString()"
|
aria-expanded="{{ $expanded ? 'true' : 'false' }}"
|
||||||
|
x-bind:aria-expanded="expanded.toString()"
|
||||||
aria-controls="tasks-{{ $card->key() }}"
|
aria-controls="tasks-{{ $card->key() }}"
|
||||||
class="flex min-h-6 w-full items-center justify-between rounded px-1.5 text-[11px] font-semibold text-neutral-800 transition hover:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-neutral-100 dark:hover:bg-[#32353b] dark:focus-visible:outline-primary-300"
|
class="flex min-h-6 w-full items-center justify-between rounded px-1.5 text-[11px] font-semibold text-neutral-800 transition hover:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-neutral-100 dark:hover:bg-[#32353b] dark:focus-visible:outline-primary-300"
|
||||||
>
|
>
|
||||||
@@ -98,7 +100,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@endunless
|
@endunless
|
||||||
|
|
||||||
<div id="tasks-{{ $card->key() }}" x-show="expanded" x-cloak class="space-y-1.5 border-t border-neutral-200 pt-1 dark:border-[#36393f]">
|
<div id="tasks-{{ $card->key() }}" x-show="expanded" @unless ($expanded) x-cloak @endunless class="space-y-1.5 border-t border-neutral-200 pt-1 dark:border-[#36393f]">
|
||||||
<x-jobs.board.task-list :card="$card" :can-check="$canCheck" :can-manage="$canManage" ongoing :compact="$compact" />
|
<x-jobs.board.task-list :card="$card" :can-check="$canCheck" :can-manage="$canManage" ongoing :compact="$compact" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -254,7 +254,7 @@
|
|||||||
wire:change="saveCell({{ $taskId }}, '{{ $day }}', $event.target.value)"
|
wire:change="saveCell({{ $taskId }}, '{{ $day }}', $event.target.value)"
|
||||||
@error($errorKey) aria-invalid="true" aria-describedby="{{ $fieldId }}-error" @enderror
|
@error($errorKey) aria-invalid="true" aria-describedby="{{ $fieldId }}-error" @enderror
|
||||||
@class([
|
@class([
|
||||||
'h-6 w-11 rounded border text-center font-mono text-[11px] focus-visible:outline-2 focus-visible:outline-primary-600 aria-invalid:border-red-700 dark:focus-visible:outline-primary-300 dark:aria-invalid:border-red-300',
|
'h-6 w-12 rounded border px-0.5 text-center font-mono text-[11px] tabular-nums focus-visible:outline-2 focus-visible:outline-primary-600 aria-invalid:border-red-700 dark:focus-visible:outline-primary-300 dark:aria-invalid:border-red-300',
|
||||||
'border-emerald-600 bg-emerald-50 font-semibold text-emerald-900 dark:border-emerald-500/50 dark:bg-emerald-950/50 dark:text-emerald-100' => $quarters > 0,
|
'border-emerald-600 bg-emerald-50 font-semibold text-emerald-900 dark:border-emerald-500/50 dark:bg-emerald-950/50 dark:text-emerald-100' => $quarters > 0,
|
||||||
'border-slate-400 bg-slate-50 text-slate-700 dark:border-[#5a5e66] dark:bg-[#1b1d20] dark:text-zinc-200' => $quarters === 0,
|
'border-slate-400 bg-slate-50 text-slate-700 dark:border-[#5a5e66] dark:bg-[#1b1d20] dark:text-zinc-200' => $quarters === 0,
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -22,9 +22,10 @@
|
|||||||
wire:ignore.self
|
wire:ignore.self
|
||||||
x-data="{ get isLocked() { return {{ $locked }}; } }"
|
x-data="{ get isLocked() { return {{ $locked }}; } }"
|
||||||
x-on:cancel="if (isLocked) { $event.preventDefault(); }"
|
x-on:cancel="if (isLocked) { $event.preventDefault(); }"
|
||||||
{{ $attributes->class(['m-auto w-[calc(100%-1rem)] rounded-2xl border border-neutral-300 bg-white p-0 text-neutral-900 shadow-2xl backdrop:bg-black/70 dark:border-[#3e4249] dark:bg-[#222427] dark:text-neutral-100', $width]) }}
|
{{ $attributes->class(['m-auto max-h-[calc(100dvh-2rem)] w-[calc(100%-1rem)] overflow-hidden rounded-2xl border border-neutral-300 bg-white p-0 text-neutral-900 shadow-2xl backdrop:bg-black/70 dark:border-[#3e4249] dark:bg-[#222427] dark:text-neutral-100', $width]) }}
|
||||||
>
|
>
|
||||||
<div class="flex max-h-[92vh] flex-col">
|
{{-- Only the body scrolls: the dialog itself never does (one scrollbar), and its border takes 2px. --}}
|
||||||
|
<div class="flex max-h-[calc(100dvh-2rem-2px)] flex-col">
|
||||||
@isset($header)
|
@isset($header)
|
||||||
{{ $header }}
|
{{ $header }}
|
||||||
@else
|
@else
|
||||||
@@ -42,7 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@endisset
|
@endisset
|
||||||
|
|
||||||
<div class="flex-1 overflow-y-auto">
|
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -160,6 +160,9 @@ it('has no accessibility issues in the job editor and the quick intake dialog',
|
|||||||
$visit->click('#card-job-'.$this->job->id.'-open')
|
$visit->click('#card-job-'.$this->job->id.'-open')
|
||||||
->assertScript('document.getElementById("job-editor-dialog").open', true)
|
->assertScript('document.getElementById("job-editor-dialog").open', true)
|
||||||
->assertSee('Kuvauspäivä')
|
->assertSee('Kuvauspäivä')
|
||||||
|
->click('#job-editor-dialog [aria-controls^="editor-checklist-"]')
|
||||||
|
->click('#job-editor-dialog [aria-controls^="editor-extras-"]')
|
||||||
|
->assertSee('Kuvat (0)')
|
||||||
->assertNoJavaScriptErrors()
|
->assertNoJavaScriptErrors()
|
||||||
->assertNoAccessibilityIssues(level: 2)
|
->assertNoAccessibilityIssues(level: 2)
|
||||||
->keys('#job-editor-name', 'Escape')
|
->keys('#job-editor-name', 'Escape')
|
||||||
@@ -173,6 +176,55 @@ it('has no accessibility issues in the job editor and the quick intake dialog',
|
|||||||
'mobile, dark' => ['mobile', 'dark'],
|
'mobile, dark' => ['mobile', 'dark'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
it('scrolls only the body of the job editor when a task has many comments', function () {
|
||||||
|
$task = TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Kuvauspäivä']);
|
||||||
|
|
||||||
|
foreach (range(1, 15) as $number) {
|
||||||
|
TaskCommentModel::query()->create(['task_id' => $task->id, 'user_id' => $this->user->id, 'body' => 'Kommentti numero '.$number.' kuvauspäivän järjestelyistä.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
visit(route('jobs.board'))
|
||||||
|
->on()->desktop()
|
||||||
|
->click('#card-job-'.$this->job->id.'-open')
|
||||||
|
->click('#job-editor-dialog [aria-controls^="editor-extras-"]')
|
||||||
|
->assertSee('Kommentti numero 15')
|
||||||
|
->assertScript('getComputedStyle(document.getElementById("job-editor-dialog")).overflowY', 'hidden')
|
||||||
|
->assertScript('(() => { const d = document.getElementById("job-editor-dialog"); return d.scrollHeight <= d.clientHeight + 1; })()', true)
|
||||||
|
->assertNoAccessibilityIssues(level: 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps the task list of a card open when the board is opened again', function () {
|
||||||
|
$this->job->update(['status' => 'in_production']);
|
||||||
|
TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Leikkaus']);
|
||||||
|
$toggle = '[aria-controls="tasks-job-'.$this->job->id.'"]';
|
||||||
|
$panel = 'document.getElementById("tasks-job-'.$this->job->id.'")';
|
||||||
|
|
||||||
|
visit(route('jobs.board'))
|
||||||
|
->on()->desktop()
|
||||||
|
->click($toggle)
|
||||||
|
->assertScript($panel.'.offsetParent !== null', true)
|
||||||
|
->wait(1);
|
||||||
|
|
||||||
|
visit(route('jobs.board'))
|
||||||
|
->on()->desktop()
|
||||||
|
->assertAttribute($toggle, 'aria-expanded', 'true')
|
||||||
|
->assertScript($panel.'.offsetParent !== null', true)
|
||||||
|
->assertNoAccessibilityIssues(level: 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('changes the order of a column and the urgent threshold from the column menus', function () {
|
||||||
|
visit(route('jobs.board'))
|
||||||
|
->on()->desktop()
|
||||||
|
->click('[aria-controls="sort-menu-order"]')
|
||||||
|
->click('#sort-menu-order [aria-checked="false"]')
|
||||||
|
->assertSee('Listan Jonossa järjestys: Eräpäivän mukaan.')
|
||||||
|
->click('[aria-controls="threshold-menu"]')
|
||||||
|
->click('#threshold-menu button:first-of-type')
|
||||||
|
->assertSee('Kiire-listaan nousevat nyt: Vain Heti.')
|
||||||
|
->assertNoJavaScriptErrors()
|
||||||
|
->assertNoAccessibilityIssues(level: 2);
|
||||||
|
});
|
||||||
|
|
||||||
it('marks a task done from the task panel of a card', function () {
|
it('marks a task done from the task panel of a card', function () {
|
||||||
$this->job->update(['status' => 'in_production']);
|
$this->job->update(['status' => 'in_production']);
|
||||||
$task = TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Leikkaus', 'status' => 'in_progress']);
|
$task = TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Leikkaus', 'status' => 'in_progress']);
|
||||||
|
|||||||
@@ -178,3 +178,15 @@ it('links the job page to its expenses and shows the own expenses by month', fun
|
|||||||
->assertSee('Lokakuu 2026')
|
->assertSee('Lokakuu 2026')
|
||||||
->assertSee('Lokakuun hankinta');
|
->assertSee('Lokakuun hankinta');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('lists an expense of the month\'s last day on the own expenses page', function () {
|
||||||
|
$user = User::factory()->create();
|
||||||
|
ExpenseModel::factory()->create(['customer_job_id' => $this->job->id, 'user_id' => $user->id, 'description' => 'Helmikuun viimeinen hankinta', 'spent_on' => '2026-02-28']);
|
||||||
|
ExpenseModel::factory()->create(['customer_job_id' => $this->job->id, 'user_id' => $user->id, 'description' => 'Maaliskuun hankinta', 'spent_on' => '2026-03-01']);
|
||||||
|
|
||||||
|
$this->actingAs($user)
|
||||||
|
->get(route('expenses.mine', ['kuukausi' => '2026-02']))
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('Helmikuun viimeinen hankinta')
|
||||||
|
->assertDontSee('Maaliskuun hankinta');
|
||||||
|
});
|
||||||
|
|||||||
@@ -266,3 +266,29 @@ it('shows a subcontractor only their cards, without moving or changing colours',
|
|||||||
|
|
||||||
expect($theirs->fresh()->status->value)->toBe('order');
|
expect($theirs->fresh()->status->value)->toBe('order');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('remembers for each user which cards have their tasks open', function () {
|
||||||
|
$job = CustomerJobModel::factory()->create(['status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||||
|
TaskModel::factory()->create(['customer_job_id' => $job->id, 'title' => 'Vedos']);
|
||||||
|
|
||||||
|
Livewire::test('jobs::board')
|
||||||
|
->assertSeeHtml('aria-controls="tasks-job-'.$job->id.'"')
|
||||||
|
->assertDontSeeHtml('aria-expanded="true"')
|
||||||
|
->call('setCardExpanded', 'job-'.$job->id, true)
|
||||||
|
->call('setCardExpanded', 'job-999', true);
|
||||||
|
|
||||||
|
expect(json_decode((string) DB::table('job_board_preferences')->where('user_id', $this->employee->id)->value('expanded_cards')))->toBe(['job-'.$job->id]);
|
||||||
|
|
||||||
|
Livewire::test('jobs::board')->assertSeeHtml('aria-expanded="true"');
|
||||||
|
|
||||||
|
$colleague = User::factory()->create();
|
||||||
|
$job->update(['responsible_user_id' => $colleague->id]);
|
||||||
|
$this->actingAs($colleague);
|
||||||
|
Livewire::test('jobs::board')->assertDontSeeHtml('aria-expanded="true"');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('passes the column and choice to the order and urgent threshold menus', function () {
|
||||||
|
Livewire::test('jobs::board')
|
||||||
|
->assertSeeHtml('wire:click="setColumnSort('order', 'due_date')"')
|
||||||
|
->assertSeeHtml('wire:click="setUrgentThreshold('immediate')"');
|
||||||
|
});
|
||||||
|
|||||||
@@ -126,3 +126,30 @@ it('lets a subcontractor only look at their own job and tick its tasks', functio
|
|||||||
|
|
||||||
expect($task->fresh()->status->value)->toBe('done');
|
expect($task->fresh()->status->value)->toBe('done');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('shows a new customer colour at once when the board saves it', function () {
|
||||||
|
$editor = Livewire::test('jobs::job-editor')
|
||||||
|
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||||
|
->assertSeeHtml('background-color: #23476a');
|
||||||
|
|
||||||
|
Livewire::test('jobs::board')
|
||||||
|
->call('setCustomerColor', $this->job->customer_id, '#991b1b')
|
||||||
|
->assertDispatched('customer-color-changed', customerId: $this->job->customer_id);
|
||||||
|
|
||||||
|
$editor->dispatch('customer-color-changed', customerId: $this->job->customer_id)
|
||||||
|
->assertSeeHtml('background-color: #991b1b');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has comments and images for each task', function () {
|
||||||
|
$task = TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Vedos']);
|
||||||
|
|
||||||
|
Livewire::test('jobs::job-editor')
|
||||||
|
->dispatch('open-job-editor', jobId: $this->job->id)
|
||||||
|
->assertSee('Tarkistuslista')
|
||||||
|
->assertSee('Kommentit ja kuvat (kommentit 0, kuvat 0)')
|
||||||
|
->assertSeeLivewire('jobs::task-checklist')
|
||||||
|
->assertSeeLivewire('jobs::task-comments')
|
||||||
|
->assertSeeLivewire('jobs::task-images')
|
||||||
|
->assertSeeHtml('editor-task-'.$task->id.'-tabs-tab-comments')
|
||||||
|
->assertSeeHtml('editor-task-'.$task->id.'-tabs-tab-images');
|
||||||
|
});
|
||||||
|
|||||||
@@ -166,3 +166,13 @@ it('keeps subcontractors to their own jobs and blocks removing tasks with hours'
|
|||||||
$this->actingAs(User::factory()->subcontractor()->create());
|
$this->actingAs(User::factory()->subcontractor()->create());
|
||||||
$this->get(route('time.task', $this->task->id))->assertForbidden();
|
$this->get(route('time.task', $this->task->id))->assertForbidden();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('counts the hours of Sunday in the week', function () {
|
||||||
|
$sunday = now()->startOfWeek()->addDays(6)->toDateString();
|
||||||
|
TimeEntryModel::factory()->create(['task_id' => $this->task->id, 'user_id' => $this->employee->id, 'worked_on' => $sunday, 'hours' => 2]);
|
||||||
|
|
||||||
|
$sheet = Livewire::test('time::week')->instance()->sheet;
|
||||||
|
|
||||||
|
expect($sheet->totalQuarters)->toBe(8)
|
||||||
|
->and($sheet->dayTotals[$sunday])->toBe(8);
|
||||||
|
});
|
||||||
|
|||||||
@@ -237,3 +237,27 @@ describe('moving cards', function () {
|
|||||||
$this->pin->execute($jobId, $taskId, true);
|
$this->pin->execute($jobId, $taskId, true);
|
||||||
})->throws(TaskCannotBePinned::class);
|
})->throws(TaskCannotBePinned::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('open cards', function () {
|
||||||
|
it('remembers which cards are open', function () {
|
||||||
|
$preferences = BoardPreferences::defaults()
|
||||||
|
->withCardExpanded('job-12', true)
|
||||||
|
->withCardExpanded('task-34', true)
|
||||||
|
->withCardExpanded('job-12', false)
|
||||||
|
->withCardExpanded('nonsense', true);
|
||||||
|
|
||||||
|
expect($preferences->isCardExpanded('task-34'))->toBeTrue()
|
||||||
|
->and($preferences->isCardExpanded('job-12'))->toBeFalse()
|
||||||
|
->and($preferences->expandedCards)->toBe(['task-34']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps only valid keys and the latest cards from stored settings', function () {
|
||||||
|
$stored = array_map(fn (int $id): string => 'job-'.$id, range(1, BoardPreferences::MAX_EXPANDED_CARDS + 10));
|
||||||
|
$preferences = BoardPreferences::fromStored(null, null, [], [], [...$stored, 'drop table', 42, 'job-1']);
|
||||||
|
|
||||||
|
expect($preferences->expandedCards)->toHaveCount(BoardPreferences::MAX_EXPANDED_CARDS)
|
||||||
|
->and($preferences->isCardExpanded('job-1'))->toBeFalse()
|
||||||
|
->and($preferences->isCardExpanded('job-'.(BoardPreferences::MAX_EXPANDED_CARDS + 10)))->toBeTrue()
|
||||||
|
->and($preferences->isCardExpanded('drop table'))->toBeFalse();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user