Darken the dark canvas, add customer colours, the ongoing status and the board model
- Dark theme page background is #5a5e60; text on it is lifted to zinc-200 / primary-100 and TallStackUI's dark labels, hints and checkbox labels are lightened so everything stays at 4.5:1. - Shared HexColor picks white or black text by the higher WCAG contrast; a native-dialog colour picker and a large work dialog component. - Customers get a header colour (customers.header_color), set on the customer page. - New job status Jatkuvat / Kausi (ongoing): open, never late, billed monthly like running jobs. - Kanban model: board columns and views, urgent threshold, per-user board preferences (density, column colours and sort), card positions, tasks of continuing jobs pinned to the board, MoveBoardCard and board queries with logged hours from TimeTracking. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -25,6 +25,14 @@ interface CustomerQueries
|
||||
*/
|
||||
public function namesByIds(array $ids): array;
|
||||
|
||||
/**
|
||||
* Card header colours (#rrggbb, null = default colour) by customer id.
|
||||
*
|
||||
* @param list<int> $ids
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function headerColorsByIds(array $ids): array;
|
||||
|
||||
/**
|
||||
* The company's own internal customer, whose jobs hold internal work
|
||||
* and the yearly quick sale job.
|
||||
|
||||
@@ -22,6 +22,7 @@ final readonly class CustomerSummary
|
||||
public ?string $businessId,
|
||||
public ?string $personalIdentityCodeMasked = null,
|
||||
public bool $isInternal = false,
|
||||
public ?string $headerColor = null,
|
||||
) {}
|
||||
|
||||
public function hasPersonalIdentityCode(): bool
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Customers\Application\UseCases;
|
||||
|
||||
use App\Modules\Customers\Domain\Contracts\CustomerRepository;
|
||||
use App\Modules\Customers\Domain\Exceptions\CustomerNotFound;
|
||||
use App\Modules\Shared\Application\Contracts\TransactionManager;
|
||||
use App\Modules\Shared\Domain\Exceptions\InvalidHexColor;
|
||||
use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
||||
|
||||
/**
|
||||
* Sets the customer's colour, shared by its Kanban cards and its time sheet
|
||||
* rows. Null returns to the default colour.
|
||||
*/
|
||||
final class ChangeCustomerHeaderColor
|
||||
{
|
||||
public function __construct(
|
||||
private CustomerRepository $customers,
|
||||
private TransactionManager $transactions,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @throws CustomerNotFound
|
||||
* @throws InvalidHexColor
|
||||
*/
|
||||
public function execute(int $customerId, ?string $color): void
|
||||
{
|
||||
$headerColor = $color === null || trim($color) === '' ? null : new HexColor($color);
|
||||
|
||||
$this->transactions->run(function () use ($customerId, $headerColor): void {
|
||||
$customer = $this->customers->findById($customerId) ?? throw new CustomerNotFound($customerId);
|
||||
|
||||
$customer->changeHeaderColor($headerColor);
|
||||
|
||||
$this->customers->save($customer);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ use App\Modules\Customers\Domain\Exceptions\InternalCustomerMustBeCompany;
|
||||
use App\Modules\Customers\Domain\ValueObjects\CustomerName;
|
||||
use App\Modules\Customers\Domain\ValueObjects\PersonalIdentityCode;
|
||||
use App\Modules\Shared\Domain\ValueObjects\BusinessId;
|
||||
use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
||||
|
||||
/**
|
||||
* A customer of the company: a business or a private consumer.
|
||||
@@ -27,6 +28,7 @@ final class Customer
|
||||
private ?BusinessId $businessId,
|
||||
private ?PersonalIdentityCode $personalIdentityCode,
|
||||
private bool $internal = false,
|
||||
private ?HexColor $headerColor = null,
|
||||
) {
|
||||
self::ensureIdentifiersFitType($type, $businessId, $personalIdentityCode);
|
||||
self::ensureInternalIsCompany($internal, $type);
|
||||
@@ -54,8 +56,9 @@ final class Customer
|
||||
?BusinessId $businessId,
|
||||
?PersonalIdentityCode $personalIdentityCode = null,
|
||||
bool $internal = false,
|
||||
?HexColor $headerColor = null,
|
||||
): self {
|
||||
return new self($id, $name, $type, $businessId, $personalIdentityCode, $internal);
|
||||
return new self($id, $name, $type, $businessId, $personalIdentityCode, $internal, $headerColor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,6 +84,20 @@ final class Customer
|
||||
$this->personalIdentityCode = $personalIdentityCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* The colour of the customer's card headers on the Kanban board and of
|
||||
* its rows on the time sheet. Null uses the default colour.
|
||||
*/
|
||||
public function changeHeaderColor(?HexColor $color): void
|
||||
{
|
||||
$this->headerColor = $color;
|
||||
}
|
||||
|
||||
public function headerColor(): ?HexColor
|
||||
{
|
||||
return $this->headerColor;
|
||||
}
|
||||
|
||||
public function removePersonalIdentityCode(): void
|
||||
{
|
||||
$this->personalIdentityCode = null;
|
||||
|
||||
@@ -23,9 +23,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property string|null $personal_identity_code Decrypted by the cast; sensitive.
|
||||
* @property string|null $personal_identity_code_hash
|
||||
* @property bool $is_internal
|
||||
* @property string|null $header_color #rrggbb
|
||||
*/
|
||||
#[Table('customers')]
|
||||
#[Fillable(['name', 'type', 'business_id', 'personal_identity_code', 'personal_identity_code_hash'])]
|
||||
#[Fillable(['name', 'type', 'business_id', 'personal_identity_code', 'personal_identity_code_hash', 'header_color'])]
|
||||
#[Hidden(['personal_identity_code', 'personal_identity_code_hash'])]
|
||||
#[UseFactory(CustomerFactory::class)]
|
||||
class CustomerModel extends Model
|
||||
|
||||
+6
-1
@@ -27,6 +27,11 @@ class EloquentCustomerQueries implements CustomerQueries
|
||||
return $ids === [] ? [] : CustomerModel::query()->whereIn('id', $ids)->pluck('name', 'id')->all();
|
||||
}
|
||||
|
||||
public function headerColorsByIds(array $ids): array
|
||||
{
|
||||
return $ids === [] ? [] : CustomerModel::query()->whereIn('id', $ids)->pluck('header_color', 'id')->all();
|
||||
}
|
||||
|
||||
public function internalCustomerId(): ?int
|
||||
{
|
||||
$id = CustomerModel::query()->where('is_internal', true)->orderBy('id')->value('id');
|
||||
@@ -118,7 +123,7 @@ class EloquentCustomerQueries implements CustomerQueries
|
||||
? null
|
||||
: (new PersonalIdentityCode($model->personal_identity_code))->masked();
|
||||
|
||||
return new CustomerSummary($model->id, $model->name, $model->type, $model->business_id, $masked, (bool) $model->is_internal);
|
||||
return new CustomerSummary($model->id, $model->name, $model->type, $model->business_id, $masked, (bool) $model->is_internal, $model->header_color);
|
||||
}
|
||||
|
||||
private function toContactSummary(CustomerContactModel $model): ContactSummary
|
||||
|
||||
+3
@@ -10,6 +10,7 @@ use App\Modules\Customers\Domain\ValueObjects\PersonalIdentityCode;
|
||||
use App\Modules\Customers\Infrastructure\Persistence\Eloquent\CustomerModel;
|
||||
use App\Modules\Customers\Infrastructure\Persistence\PersonalIdentityCodeHasher;
|
||||
use App\Modules\Shared\Domain\ValueObjects\BusinessId;
|
||||
use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class EloquentCustomerRepository implements CustomerRepository
|
||||
@@ -35,6 +36,7 @@ class EloquentCustomerRepository implements CustomerRepository
|
||||
'business_id' => $customer->businessId()?->value,
|
||||
'personal_identity_code' => $customer->personalIdentityCode()?->value,
|
||||
'personal_identity_code_hash' => $customer->personalIdentityCode() === null ? null : $this->hasher->hash($customer->personalIdentityCode()),
|
||||
'header_color' => $customer->headerColor()?->value,
|
||||
])->save();
|
||||
|
||||
return $this->toEntity($model);
|
||||
@@ -83,6 +85,7 @@ class EloquentCustomerRepository implements CustomerRepository
|
||||
$model->business_id === null ? null : new BusinessId($model->business_id),
|
||||
$model->personal_identity_code === null ? null : new PersonalIdentityCode($model->personal_identity_code),
|
||||
(bool) $model->is_internal,
|
||||
$model->header_color === null ? null : new HexColor($model->header_color),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ new class extends Component
|
||||
<div class="mx-auto max-w-2xl space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="building-office-2">{{ $this->heading() }}</x-page-title>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">
|
||||
{{ __('customers.customer_label') }}:
|
||||
<x-link :href="route('customers.show', $customerId)" navigate>{{ $customerName }}</x-link>
|
||||
</p>
|
||||
|
||||
@@ -89,7 +89,7 @@ new class extends Component
|
||||
<div class="mx-auto max-w-2xl space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="user">{{ $this->heading() }}</x-page-title>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">
|
||||
{{ __('customers.customer_label') }}:
|
||||
<x-link :href="route('customers.show', $customerId)" navigate>{{ $customerName }}</x-link>
|
||||
</p>
|
||||
|
||||
@@ -80,7 +80,7 @@ new class extends Component
|
||||
:hint="__('customers.search_description')"
|
||||
/>
|
||||
|
||||
<p role="status" aria-live="polite" aria-atomic="true" class="text-sm text-zinc-600 dark:text-zinc-300">
|
||||
<p role="status" aria-live="polite" aria-atomic="true" class="text-sm text-zinc-600 dark:text-zinc-100">
|
||||
{{ trans_choice('customers.result_count', $this->customers->total(), ['count' => $this->customers->total()]) }}
|
||||
</p>
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use App\Modules\Customers\Application\DTOs\BillingUnitSummary;
|
||||
use App\Modules\Customers\Application\DTOs\ContactSummary;
|
||||
use App\Modules\Customers\Application\DTOs\CustomerSummary;
|
||||
use App\Modules\Customers\Application\Services\CustomerRemoval;
|
||||
use App\Modules\Customers\Application\UseCases\ChangeCustomerHeaderColor;
|
||||
use App\Modules\Customers\Application\UseCases\RemoveBillingUnit;
|
||||
use App\Modules\Customers\Application\UseCases\RemoveContact;
|
||||
use App\Modules\Customers\Application\UseCases\RemoveCustomer;
|
||||
@@ -16,6 +17,7 @@ use App\Modules\Customers\Domain\Exceptions\CustomerInUse;
|
||||
use App\Modules\Customers\Domain\Exceptions\CustomerNotFound;
|
||||
use App\Modules\Customers\Domain\Exceptions\InternalCustomerCannotBeRemoved;
|
||||
use App\Modules\Customers\Domain\Enums\CustomerType;
|
||||
use App\Modules\Shared\Domain\Exceptions\InvalidHexColor;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
@@ -71,6 +73,27 @@ new class extends Component
|
||||
return $this->customerQueries->findSummary($this->customerId) ?? abort(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* The colour picker's "Use colour", or "Restore default colour" with null.
|
||||
*/
|
||||
public function setHeaderColor(?string $color, ChangeCustomerHeaderColor $changeColor): void
|
||||
{
|
||||
$this->authorize('customers.use');
|
||||
|
||||
try {
|
||||
$changeColor->execute($this->customerId, $color);
|
||||
} catch (InvalidHexColor) {
|
||||
$this->statusMessage = __('customers.errors.invalid_header_color');
|
||||
|
||||
return;
|
||||
} catch (CustomerNotFound) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
unset($this->customer);
|
||||
$this->statusMessage = __('customers.header_color_saved');
|
||||
}
|
||||
|
||||
/**
|
||||
* The personal identity code as this user may see it: in full for admins
|
||||
* and management, masked for others. Computed, so the full code is never
|
||||
@@ -211,7 +234,7 @@ new class extends Component
|
||||
|
||||
<div class="mx-auto max-w-5xl space-y-8 p-4 sm:p-6">
|
||||
<div class="space-y-4">
|
||||
<a href="{{ route('customers.index') }}" wire:navigate class="inline-flex min-h-6 items-center gap-1 rounded-md text-sm font-medium text-primary-700 underline-offset-4 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:text-primary-300 dark:focus-visible:outline-primary-300">
|
||||
<a href="{{ route('customers.index') }}" wire:navigate class="inline-flex min-h-6 items-center gap-1 rounded-md text-sm font-medium text-primary-700 underline-offset-4 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:text-primary-100 dark:focus-visible:outline-primary-300">
|
||||
<x-icon name="arrow-left" class="size-4" aria-hidden="true" />{{ __('customers.title') }}
|
||||
</a>
|
||||
<div class="flex flex-wrap items-center justify-between gap-4">
|
||||
@@ -227,6 +250,14 @@ new class extends Component
|
||||
:text="__('customers.edit_details')"
|
||||
/>
|
||||
|
||||
<x-button
|
||||
subtle
|
||||
color="black"
|
||||
icon="swatch"
|
||||
:text="__('customers.fields.header_color')"
|
||||
x-on:click="$dispatch('color-picker:open', {{ Js::from(['id' => 'colour-picker', 'title' => __('customers.header_color_title', ['name' => $this->customer->name]), 'color' => $this->customer->headerColor ?? '#23476a', 'method' => 'setHeaderColor', 'args' => [], 'resettable' => $this->customer->headerColor !== null]) }})"
|
||||
/>
|
||||
|
||||
@if ($this->canBeRemoved)
|
||||
<x-button
|
||||
wire:click="confirmRemoval('customer', {{ $customerId }})"
|
||||
@@ -317,7 +348,7 @@ new class extends Component
|
||||
@endif
|
||||
|
||||
@if ($contact->note !== null)
|
||||
<p class="whitespace-pre-line text-zinc-600 dark:text-zinc-300">{{ $contact->note }}</p>
|
||||
<p class="whitespace-pre-line text-zinc-600 dark:text-zinc-200">{{ $contact->note }}</p>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -430,4 +461,6 @@ new class extends Component
|
||||
<x-button wire:click="remove" color="red" icon="trash" :text="__('customers.remove')" />
|
||||
</x-slot:actions>
|
||||
</x-confirm-dialog>
|
||||
|
||||
<x-color-picker />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user