Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8be732ada8 | ||
|
|
9eac4c4d4e | ||
|
|
e274a8d2b1 |
@@ -12,20 +12,26 @@ use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
||||
|
||||
/**
|
||||
* One user's Kanban board settings: card density, the urgent threshold,
|
||||
* and their own colour and order for each column. A column without a
|
||||
* colour of its own uses the design's default colour.
|
||||
* their own colour and order for each column, and which cards they keep
|
||||
* open (task list shown). A column without a colour of its own uses the
|
||||
* design's default colour.
|
||||
*/
|
||||
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, ColumnSort> $columnSorts by BoardColumn value
|
||||
* @param list<string> $expandedCards card keys ("job-12", "task-34"), oldest first
|
||||
*/
|
||||
public function __construct(
|
||||
public BoardDensity $density = BoardDensity::Normal,
|
||||
public UrgentThreshold $urgentThreshold = UrgentThreshold::Urgent,
|
||||
public array $columnColors = [],
|
||||
public array $columnSorts = [],
|
||||
public array $expandedCards = [],
|
||||
) {}
|
||||
|
||||
public static function defaults(): self
|
||||
@@ -33,14 +39,20 @@ final readonly class BoardPreferences
|
||||
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
|
||||
* so a bad stored value never breaks the board.
|
||||
*
|
||||
* @param array<array-key, mixed> $colors
|
||||
* @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 = [];
|
||||
|
||||
@@ -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(
|
||||
BoardDensity::tryFrom((string) $density) ?? BoardDensity::Normal,
|
||||
UrgentThreshold::tryFrom((string) $threshold) ?? UrgentThreshold::Urgent,
|
||||
$columnColors,
|
||||
$columnSorts,
|
||||
array_slice($expandedCards, -self::MAX_EXPANDED_CARDS),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -83,14 +98,19 @@ final readonly class BoardPreferences
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
@@ -114,7 +134,26 @@ final readonly class BoardPreferences
|
||||
$sorts = $this->columnSorts;
|
||||
$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 array<string, string>|null $column_colors
|
||||
* @property array<string, string>|null $column_sorts
|
||||
* @property list<string>|null $expanded_cards
|
||||
*/
|
||||
#[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
|
||||
{
|
||||
/**
|
||||
@@ -29,6 +30,7 @@ class JobBoardPreferenceModel extends Model
|
||||
'user_id' => 'integer',
|
||||
'column_colors' => 'array',
|
||||
'column_sorts' => 'array',
|
||||
'expanded_cards' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -38,7 +38,7 @@ class EloquentBoardRepository implements BoardRepository
|
||||
|
||||
return $model === null
|
||||
? 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
|
||||
@@ -48,6 +48,7 @@ class EloquentBoardRepository implements BoardRepository
|
||||
'urgent_threshold' => $preferences->urgentThreshold->value,
|
||||
'column_colors' => $preferences->colorValues(),
|
||||
'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 Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Attributes\Renderless;
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -391,6 +392,20 @@ new class extends Component
|
||||
$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
|
||||
{
|
||||
$column = BoardColumn::tryFrom($columnValue);
|
||||
@@ -772,6 +787,7 @@ new class extends Component
|
||||
@elseif ($card->isOngoing())
|
||||
<x-jobs.board.ongoing-card
|
||||
:card="$card"
|
||||
:expanded="$this->preferences->isCardExpanded($card->key())"
|
||||
:compact="$compact"
|
||||
:can-move="$canMove"
|
||||
:can-color="$canColor"
|
||||
@@ -781,6 +797,7 @@ new class extends Component
|
||||
@else
|
||||
<x-jobs.board.job-card
|
||||
:card="$card"
|
||||
:expanded="$this->preferences->isCardExpanded($card->key())"
|
||||
:compact="$compact"
|
||||
:can-move="$canMove"
|
||||
:can-color="$canColor"
|
||||
|
||||
+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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -4,7 +4,7 @@
|
||||
due date, hours and the job's tasks, which open inside the card and can
|
||||
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')
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<article
|
||||
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]"
|
||||
>
|
||||
<x-jobs.board.card-header :card="$card" :can-move="$canMove" :can-color="$canColor" />
|
||||
@@ -40,7 +40,8 @@
|
||||
@if ($total > 0)
|
||||
<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()"
|
||||
aria-controls="tasks-{{ $card->key() }}"
|
||||
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]">
|
||||
<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()"
|
||||
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"
|
||||
@@ -91,7 +93,7 @@
|
||||
@endif
|
||||
|
||||
@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" />
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
type="button"
|
||||
role="menuitemradio"
|
||||
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:keydown.arrow-down.prevent="$el.nextElementSibling?.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
|
||||
(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
|
||||
$total = count($card->tasks);
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<article
|
||||
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]"
|
||||
>
|
||||
<x-jobs.board.card-header :card="$card" :can-move="$canMove" :can-color="$canColor" />
|
||||
@@ -37,8 +37,9 @@
|
||||
@if ($compact)
|
||||
<button
|
||||
type="button"
|
||||
x-on:click="expanded = ! expanded"
|
||||
x-bind:aria-expanded="expanded.toString()"
|
||||
x-on:click="expanded = ! expanded; $wire.setCardExpanded('{{ $card->key() }}', expanded)"
|
||||
aria-expanded="{{ $expanded ? 'true' : 'false' }}"
|
||||
x-bind:aria-expanded="expanded.toString()"
|
||||
aria-controls="tasks-{{ $card->key() }}"
|
||||
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"
|
||||
@@ -87,8 +88,9 @@
|
||||
<div class="border-t border-neutral-200 pt-1 dark:border-[#36393f]">
|
||||
<button
|
||||
type="button"
|
||||
x-on:click="expanded = ! expanded"
|
||||
x-bind:aria-expanded="expanded.toString()"
|
||||
x-on:click="expanded = ! expanded; $wire.setCardExpanded('{{ $card->key() }}', expanded)"
|
||||
aria-expanded="{{ $expanded ? 'true' : 'false' }}"
|
||||
x-bind:aria-expanded="expanded.toString()"
|
||||
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"
|
||||
>
|
||||
@@ -98,7 +100,7 @@
|
||||
</div>
|
||||
@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" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,9 +22,10 @@
|
||||
wire:ignore.self
|
||||
x-data="{ get isLocked() { return {{ $locked }}; } }"
|
||||
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)
|
||||
{{ $header }}
|
||||
@else
|
||||
@@ -42,7 +43,7 @@
|
||||
</div>
|
||||
@endisset
|
||||
|
||||
<div class="flex-1 overflow-y-auto">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||
{{ $slot }}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -176,6 +176,55 @@ it('has no accessibility issues in the job editor and the quick intake dialog',
|
||||
'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 () {
|
||||
$this->job->update(['status' => 'in_production']);
|
||||
$task = TaskModel::factory()->create(['customer_job_id' => $this->job->id, 'title' => 'Leikkaus', 'status' => 'in_progress']);
|
||||
|
||||
@@ -266,3 +266,29 @@ it('shows a subcontractor only their cards, without moving or changing colours',
|
||||
|
||||
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')"');
|
||||
});
|
||||
|
||||
@@ -237,3 +237,27 @@ describe('moving cards', function () {
|
||||
$this->pin->execute($jobId, $taskId, true);
|
||||
})->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