Phase 1, item 4. New Jobs module: - Customer jobs with the spec's fields except money (phase 2): yearly running numbers (2026-0001) from a locked counter row, service units, schedule, kind, status, priority, payment basis, estimated hours, PO reference, instructions, members (responsible, contact person, customer contact, biller, billing unit, other members), tags shared across jobs, and links. - Every change is recorded field by field and shown on the job page with names and Finnish dates. - References to other modules are checked through their query contracts: contact and billing unit must be the customer's own; service units and users must be in use unless already on the job. - Job list with search, filters and "my jobs" on by default; job form with an accessible customer search and quick add; job page. - Access: subcontractors see only jobs they are members of, read only; billing statuses for management and the job's biller; archiving for management. Related changes: - Customers: one internal customer (created by a migration) for internal work; contacts and billing units used by a job cannot be removed. - Users and Catalog: batch name lookups and active user options with roles for other modules. - <x-checkbox-group> component; spec and CLAUDE.md updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
648 lines
26 KiB
PHP
648 lines
26 KiB
PHP
<?php
|
|
|
|
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
|
|
use App\Modules\Customers\Application\Contracts\CustomerQueries;
|
|
use App\Modules\Customers\Application\DTOs\BillingUnitSummary;
|
|
use App\Modules\Customers\Application\DTOs\ContactSummary;
|
|
use App\Modules\Customers\Application\DTOs\CustomerDetailsData;
|
|
use App\Modules\Customers\Application\DTOs\CustomerSummary;
|
|
use App\Modules\Customers\Application\UseCases\RegisterCustomer;
|
|
use App\Modules\Customers\Domain\Enums\CustomerType;
|
|
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
|
|
use App\Modules\Jobs\Application\DTOs\CustomerJobDetails;
|
|
use App\Modules\Jobs\Application\UseCases\CreateCustomerJob;
|
|
use App\Modules\Jobs\Application\UseCases\UpdateCustomerJob;
|
|
use App\Modules\Jobs\Domain\Enums\JobKind;
|
|
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
|
use App\Modules\Jobs\Domain\Enums\PaymentBasis;
|
|
use App\Modules\Jobs\Domain\Enums\Priority;
|
|
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
|
|
use App\Modules\Jobs\Presentation\Livewire\Forms\JobForm;
|
|
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
|
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
|
use App\Modules\Users\Application\DTOs\UserOption;
|
|
use App\Modules\Users\Domain\Enums\Role;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Attributes\Locked;
|
|
use Livewire\Component;
|
|
|
|
/**
|
|
* Create page (no {job}) and edit page (with {job}) of a customer job.
|
|
*/
|
|
new class extends Component
|
|
{
|
|
#[Locked]
|
|
public ?int $jobId = null;
|
|
|
|
#[Locked]
|
|
public string $jobNumber = '';
|
|
|
|
#[Locked]
|
|
public string $customerName = '';
|
|
|
|
/**
|
|
* The status stored before this edit: always offered, even when the
|
|
* user could not set it themselves.
|
|
*/
|
|
#[Locked]
|
|
public ?string $storedStatus = null;
|
|
|
|
public JobForm $form;
|
|
|
|
public string $customerSearch = '';
|
|
|
|
public string $newTag = '';
|
|
|
|
public string $statusMessage = '';
|
|
|
|
public function mount(CustomerJobQueries $jobQueries, ?int $job = null): void
|
|
{
|
|
$this->authorize('jobs.manage');
|
|
|
|
if ($job === null) {
|
|
$this->form->responsible_user_id = (string) auth()->id();
|
|
|
|
return;
|
|
}
|
|
|
|
$details = $jobQueries->findDetails($job);
|
|
|
|
abort_if($details === null, 404);
|
|
|
|
$this->jobId = $details->id;
|
|
$this->jobNumber = $details->number;
|
|
$this->customerName = $details->customer->name;
|
|
$this->storedStatus = $details->status->value;
|
|
$this->form->fillFromDetails($details);
|
|
}
|
|
|
|
/**
|
|
* @return list<CustomerSummary>
|
|
*/
|
|
#[Computed]
|
|
public function customerResults(): array
|
|
{
|
|
$term = trim($this->customerSearch);
|
|
|
|
return mb_strlen($term) < 2 ? [] : app(CustomerQueries::class)->search($term, 8);
|
|
}
|
|
|
|
/**
|
|
* @return list<array{value: int, label: string}>
|
|
*/
|
|
#[Computed]
|
|
public function serviceUnitOptions(): array
|
|
{
|
|
$catalog = app(CatalogQueries::class);
|
|
$options = [];
|
|
|
|
foreach ($catalog->activeServiceUnits() as $unit) {
|
|
$options[$unit->id] = ['value' => $unit->id, 'label' => $unit->name];
|
|
}
|
|
|
|
// Units already on the job stay visible after being taken out of use.
|
|
foreach ($this->form->service_unit_ids as $id) {
|
|
if (! isset($options[(int) $id]) && ($unit = $catalog->findServiceUnit((int) $id)) !== null) {
|
|
$options[$unit->id] = ['value' => $unit->id, 'label' => $unit->name, 'note' => __('catalog.inactive')];
|
|
}
|
|
}
|
|
|
|
return array_values($options);
|
|
}
|
|
|
|
/**
|
|
* @return list<UserOption>
|
|
*/
|
|
#[Computed]
|
|
public function users(): array
|
|
{
|
|
return app(UserAccountQueries::class)->activeUserOptions();
|
|
}
|
|
|
|
/**
|
|
* @return list<ContactSummary>
|
|
*/
|
|
#[Computed]
|
|
public function contacts(): array
|
|
{
|
|
return $this->form->customer_id === '' ? [] : app(CustomerQueries::class)->contactsOf((int) $this->form->customer_id);
|
|
}
|
|
|
|
/**
|
|
* @return list<BillingUnitSummary>
|
|
*/
|
|
#[Computed]
|
|
public function billingUnits(): array
|
|
{
|
|
return $this->form->customer_id === '' ? [] : app(CustomerQueries::class)->billingUnitsOf((int) $this->form->customer_id);
|
|
}
|
|
|
|
/**
|
|
* Statuses this user may choose: billing statuses for management and the
|
|
* job's biller, archived for management, and always the stored one.
|
|
*
|
|
* @return list<JobStatus>
|
|
*/
|
|
#[Computed]
|
|
public function statusOptions(): array
|
|
{
|
|
return array_values(array_filter(
|
|
JobStatus::cases(),
|
|
fn (JobStatus $status): bool => $status->value === $this->storedStatus || $this->maySetStatus($status),
|
|
));
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
#[Computed]
|
|
public function tagSuggestions(): array
|
|
{
|
|
return array_values(array_diff(app(CustomerJobQueries::class)->tagSuggestions($this->newTag), $this->form->tags));
|
|
}
|
|
|
|
public function selectCustomer(int $customerId): void
|
|
{
|
|
$this->authorize('jobs.manage');
|
|
|
|
$customer = app(CustomerQueries::class)->findSummary($customerId);
|
|
|
|
if ($customer === null) {
|
|
return;
|
|
}
|
|
|
|
$this->useCustomer($customer->id, $customer->name);
|
|
}
|
|
|
|
public function createCustomer(RegisterCustomer $registerCustomer): void
|
|
{
|
|
$this->authorize('jobs.manage');
|
|
$this->authorize('customers.use');
|
|
|
|
$name = trim($this->customerSearch);
|
|
|
|
try {
|
|
$customerId = $registerCustomer->execute(new CustomerDetailsData($name, CustomerType::Company));
|
|
} catch (DomainException) {
|
|
$this->addError('customerSearch', __('customers.errors.invalid_name'));
|
|
|
|
return;
|
|
}
|
|
|
|
$this->useCustomer($customerId, $name);
|
|
$this->statusMessage = __('jobs.customer_picker.created', ['name' => $name]);
|
|
}
|
|
|
|
public function clearCustomer(): void
|
|
{
|
|
$this->form->customer_id = '';
|
|
$this->form->customer_contact_id = '';
|
|
$this->form->billing_unit_id = '';
|
|
$this->customerName = '';
|
|
$this->statusMessage = '';
|
|
|
|
$this->js("document.getElementById('customer-search')?.focus()");
|
|
}
|
|
|
|
public function addTag(): void
|
|
{
|
|
$tag = trim(preg_replace('/\s+/u', ' ', $this->newTag) ?? '');
|
|
|
|
if ($tag === '' || mb_strlen($tag) > 50) {
|
|
$this->addError('newTag', __('jobs.errors.invalid_tag'));
|
|
|
|
return;
|
|
}
|
|
|
|
$taken = array_map('mb_strtolower', $this->form->tags);
|
|
|
|
if (! in_array(mb_strtolower($tag), $taken, true)) {
|
|
$this->form->tags[] = $tag;
|
|
}
|
|
|
|
$this->newTag = '';
|
|
$this->resetErrorBag('newTag');
|
|
$this->statusMessage = __('jobs.tags.added', ['tag' => $tag]);
|
|
}
|
|
|
|
public function removeTag(int $index): void
|
|
{
|
|
$tag = $this->form->tags[$index] ?? null;
|
|
|
|
if ($tag === null) {
|
|
return;
|
|
}
|
|
|
|
unset($this->form->tags[$index]);
|
|
$this->form->tags = array_values($this->form->tags);
|
|
$this->statusMessage = __('jobs.tags.removed', ['tag' => $tag]);
|
|
|
|
$this->js("document.getElementById('new-tag')?.focus()");
|
|
}
|
|
|
|
public function addLink(): void
|
|
{
|
|
$this->form->links[] = ['title' => '', 'url' => ''];
|
|
$index = count($this->form->links) - 1;
|
|
|
|
$this->js("document.getElementById('link-title-{$index}')?.focus()");
|
|
}
|
|
|
|
public function removeLink(int $index): void
|
|
{
|
|
unset($this->form->links[$index]);
|
|
$this->form->links = array_values($this->form->links);
|
|
|
|
$this->js("document.getElementById('add-link')?.focus()");
|
|
}
|
|
|
|
public function save(CreateCustomerJob $createJob, UpdateCustomerJob $updateJob, CustomerJobQueries $jobQueries): void
|
|
{
|
|
$this->authorize('jobs.manage');
|
|
|
|
$status = JobStatus::tryFrom($this->form->status);
|
|
|
|
if ($status !== null && $status->value !== $this->storedStatus && ! $this->maySetStatus($status)) {
|
|
$this->addError('form.status', __('jobs.errors.status_not_allowed'));
|
|
|
|
return;
|
|
}
|
|
|
|
$data = $this->form->toData();
|
|
|
|
try {
|
|
if ($this->jobId === null) {
|
|
$jobId = $createJob->execute($data, (int) auth()->id());
|
|
$number = $jobQueries->findDetails($jobId)->number ?? '';
|
|
session()->flash('status', __('jobs.created', ['number' => $number, 'name' => trim($data->name)]));
|
|
} else {
|
|
$updateJob->execute($this->jobId, $data, (int) auth()->id());
|
|
$jobId = $this->jobId;
|
|
session()->flash('status', __('jobs.updated', ['number' => $this->jobNumber]));
|
|
}
|
|
} catch (CustomerJobNotFound) {
|
|
abort(404);
|
|
} catch (DomainException $exception) {
|
|
$this->form->showDomainError($exception);
|
|
|
|
return;
|
|
}
|
|
|
|
$this->redirectRoute('jobs.show', $jobId, navigate: true);
|
|
}
|
|
|
|
public function heading(): string
|
|
{
|
|
return $this->jobId === null ? __('jobs.create_title') : __('jobs.edit_title').' '.$this->jobNumber;
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
return $this->view()->title($this->heading());
|
|
}
|
|
|
|
private function maySetStatus(JobStatus $status): bool
|
|
{
|
|
if ($status === JobStatus::Archived) {
|
|
return Gate::allows('jobs.archive');
|
|
}
|
|
|
|
if ($status->isBillingStatus()) {
|
|
$details = $this->jobId === null ? null : app(CustomerJobQueries::class)->findDetails($this->jobId);
|
|
|
|
return Gate::allows('jobs.set-billing-status', [$details]);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private function useCustomer(int $customerId, string $name): void
|
|
{
|
|
if ((string) $customerId !== $this->form->customer_id) {
|
|
$this->form->customer_contact_id = '';
|
|
$this->form->billing_unit_id = '';
|
|
}
|
|
|
|
$this->form->customer_id = (string) $customerId;
|
|
$this->customerName = $name;
|
|
$this->customerSearch = '';
|
|
$this->resetErrorBag(['customerSearch', 'form.customer_id']);
|
|
|
|
$this->js("document.getElementById('change-customer')?.focus()");
|
|
}
|
|
};
|
|
?>
|
|
|
|
@php
|
|
$userOptions = collect($this->users)->map(fn ($user) => [
|
|
'value' => $user->id,
|
|
'label' => $user->name,
|
|
'note' => $user->role === Role::Subcontractor ? __('users.roles.subcontractor') : null,
|
|
])->all();
|
|
$staffOptions = collect($this->users)->reject(fn ($user) => $user->role === Role::Subcontractor);
|
|
@endphp
|
|
|
|
<div class="mx-auto max-w-3xl space-y-6 p-4 sm:p-6">
|
|
<h1 class="text-2xl font-semibold">{{ $this->heading() }}</h1>
|
|
|
|
<p role="status" aria-live="polite" class="text-sm">{{ $statusMessage }}</p>
|
|
|
|
<form wire:submit="save" class="space-y-8" novalidate>
|
|
<fieldset class="space-y-6">
|
|
<legend class="text-lg font-semibold">{{ __('jobs.sections.basics') }}</legend>
|
|
|
|
<x-input wire:model="form.name" :label="__('jobs.fields.name')" autocomplete="off" required />
|
|
|
|
{{-- Customer: search field and results as buttons, or the chosen customer. --}}
|
|
<div class="space-y-2">
|
|
@if ($form->customer_id !== '')
|
|
<p class="text-sm font-semibold text-gray-700 dark:text-dark-300">{{ __('jobs.fields.customer') }}</p>
|
|
<div class="flex flex-wrap items-center gap-3">
|
|
<span class="font-medium">{{ $customerName }}</span>
|
|
<x-button
|
|
id="change-customer"
|
|
wire:click="clearCustomer"
|
|
subtle
|
|
color="black"
|
|
sm
|
|
:text="__('jobs.customer_picker.change')"
|
|
:aria-label="__('jobs.customer_picker.change').': '.$customerName"
|
|
/>
|
|
</div>
|
|
@else
|
|
<x-input
|
|
id="customer-search"
|
|
wire:model.live.debounce.300ms="customerSearch"
|
|
type="search"
|
|
icon="magnifying-glass"
|
|
:label="__('jobs.customer_picker.search')"
|
|
:hint="__('jobs.customer_picker.search_description')"
|
|
autocomplete="off"
|
|
required
|
|
/>
|
|
|
|
@error('form.customer_id')
|
|
<p class="text-sm text-red-700 dark:text-red-400">{{ $message }}</p>
|
|
@enderror
|
|
|
|
@if (mb_strlen(trim($customerSearch)) >= 2)
|
|
<p role="status" aria-live="polite" class="text-sm text-zinc-600 dark:text-zinc-300">
|
|
{{ trans_choice('jobs.customer_picker.results', count($this->customerResults), ['count' => count($this->customerResults)]) }}
|
|
</p>
|
|
|
|
<ul class="space-y-1">
|
|
@foreach ($this->customerResults as $customer)
|
|
<li wire:key="customer-result-{{ $customer->id }}">
|
|
<button
|
|
type="button"
|
|
wire:click="selectCustomer({{ $customer->id }})"
|
|
class="w-full rounded-md px-3 py-2 text-left text-sm hover:bg-zinc-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:hover:bg-zinc-700"
|
|
aria-label="{{ __('jobs.customer_picker.choose', ['name' => $customer->name]) }}"
|
|
>
|
|
<span class="font-medium">{{ $customer->name }}</span>
|
|
@if ($customer->businessId !== null)
|
|
<span class="text-zinc-600 dark:text-zinc-300">{{ $customer->businessId }}</span>
|
|
@endif
|
|
</button>
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
|
|
@can('customers.use')
|
|
<x-button
|
|
wire:click="createCustomer"
|
|
subtle
|
|
color="black"
|
|
sm
|
|
icon="plus"
|
|
:text="__('jobs.customer_picker.create', ['name' => trim($customerSearch)])"
|
|
/>
|
|
@endcan
|
|
@endif
|
|
@endif
|
|
</div>
|
|
|
|
<x-textarea wire:model="form.description" :label="__('jobs.fields.description')" resize-auto />
|
|
|
|
<x-checkbox-group
|
|
:legend="__('jobs.fields.service_units')"
|
|
model="form.service_unit_ids"
|
|
:options="$this->serviceUnitOptions"
|
|
/>
|
|
</fieldset>
|
|
|
|
<fieldset class="space-y-6">
|
|
<legend class="text-lg font-semibold">{{ __('jobs.sections.schedule') }}</legend>
|
|
|
|
<div class="grid gap-6 sm:grid-cols-2">
|
|
<x-input wire:model="form.starts_on" type="date" :label="__('jobs.fields.starts_on')" />
|
|
<x-input wire:model="form.due_on" type="date" :label="__('jobs.fields.due_on')" />
|
|
<x-input wire:model="form.planned_from" type="date" :label="__('jobs.fields.planned_from')" />
|
|
<x-input wire:model="form.planned_to" type="date" :label="__('jobs.fields.planned_to')" />
|
|
</div>
|
|
</fieldset>
|
|
|
|
<fieldset class="space-y-6">
|
|
<legend class="text-lg font-semibold">{{ __('jobs.sections.classification') }}</legend>
|
|
|
|
<div class="grid gap-6 sm:grid-cols-2">
|
|
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}}
|
|
<x-select.native wire:model="form.status" :label="__('jobs.fields.status')" :aria-label="__('jobs.fields.status')">
|
|
@foreach ($this->statusOptions as $status)
|
|
<option value="{{ $status->value }}">{{ __('jobs.statuses.'.$status->value) }}</option>
|
|
@endforeach
|
|
</x-select.native>
|
|
|
|
<x-select.native wire:model="form.priority" :label="__('jobs.fields.priority')" :aria-label="__('jobs.fields.priority')">
|
|
@foreach (Priority::cases() as $priority)
|
|
<option value="{{ $priority->value }}">{{ __('jobs.priorities.'.$priority->value) }}</option>
|
|
@endforeach
|
|
</x-select.native>
|
|
|
|
<x-select.native wire:model="form.kind" :label="__('jobs.fields.kind')" :aria-label="__('jobs.fields.kind')">
|
|
@foreach (JobKind::cases() as $kind)
|
|
<option value="{{ $kind->value }}">{{ __('jobs.kinds.'.$kind->value) }}</option>
|
|
@endforeach
|
|
</x-select.native>
|
|
|
|
<x-select.native wire:model="form.payment_basis" :label="__('jobs.fields.payment_basis')" :aria-label="__('jobs.fields.payment_basis')">
|
|
<option value="">{{ __('jobs.fields.no_payment_basis') }}</option>
|
|
@foreach (PaymentBasis::cases() as $basis)
|
|
<option value="{{ $basis->value }}">{{ __('jobs.payment_bases.'.$basis->value) }}</option>
|
|
@endforeach
|
|
</x-select.native>
|
|
|
|
<x-input
|
|
wire:model="form.estimated_hours"
|
|
type="number"
|
|
step="0.25"
|
|
min="0"
|
|
inputmode="decimal"
|
|
:label="__('jobs.fields.estimated_hours')"
|
|
:hint="__('jobs.fields.estimated_hours_description')"
|
|
/>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<fieldset class="space-y-6">
|
|
<legend class="text-lg font-semibold">{{ __('jobs.sections.members') }}</legend>
|
|
|
|
<div class="grid gap-6 sm:grid-cols-2">
|
|
<x-select.native wire:model="form.responsible_user_id" :label="__('jobs.fields.responsible_user')" :aria-label="__('jobs.fields.responsible_user')" required>
|
|
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
|
@foreach ($staffOptions as $user)
|
|
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
|
@endforeach
|
|
</x-select.native>
|
|
|
|
<x-select.native wire:model="form.contact_user_id" :label="__('jobs.fields.contact_user')" :aria-label="__('jobs.fields.contact_user')" :hint="__('jobs.fields.contact_user_description')">
|
|
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
|
@foreach ($staffOptions as $user)
|
|
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
|
@endforeach
|
|
</x-select.native>
|
|
|
|
<x-select.native wire:model="form.biller_user_id" :label="__('jobs.fields.biller_user')" :aria-label="__('jobs.fields.biller_user')" :hint="__('jobs.fields.biller_user_description')">
|
|
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
|
@foreach ($staffOptions as $user)
|
|
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
|
@endforeach
|
|
</x-select.native>
|
|
|
|
<x-select.native
|
|
wire:model="form.customer_contact_id"
|
|
:label="__('jobs.fields.customer_contact')"
|
|
:aria-label="__('jobs.fields.customer_contact')"
|
|
:hint="$form->customer_id === '' ? __('jobs.customer_picker.choose_customer_first') : null"
|
|
:disabled="$form->customer_id === ''"
|
|
>
|
|
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
|
@foreach ($this->contacts as $contact)
|
|
<option wire:key="contact-{{ $contact->id }}" value="{{ $contact->id }}">{{ $contact->name }}</option>
|
|
@endforeach
|
|
</x-select.native>
|
|
|
|
<x-select.native
|
|
wire:model="form.billing_unit_id"
|
|
:label="__('jobs.fields.billing_unit')"
|
|
:aria-label="__('jobs.fields.billing_unit')"
|
|
:hint="$form->customer_id === '' ? __('jobs.customer_picker.choose_customer_first') : null"
|
|
:disabled="$form->customer_id === ''"
|
|
>
|
|
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
|
@foreach ($this->billingUnits as $billingUnit)
|
|
<option wire:key="billing-unit-{{ $billingUnit->id }}" value="{{ $billingUnit->id }}">{{ $billingUnit->name }}</option>
|
|
@endforeach
|
|
</x-select.native>
|
|
</div>
|
|
|
|
<x-checkbox-group
|
|
:legend="__('jobs.fields.members')"
|
|
:hint="__('jobs.fields.members_description')"
|
|
model="form.member_user_ids"
|
|
:options="$userOptions"
|
|
/>
|
|
</fieldset>
|
|
|
|
<fieldset class="space-y-6">
|
|
<legend class="text-lg font-semibold">{{ __('jobs.sections.extra') }}</legend>
|
|
|
|
<x-input wire:model="form.customer_reference" :label="__('jobs.fields.customer_reference')" autocomplete="off" />
|
|
|
|
{{-- Tags: free text with suggestions from earlier tags, added one at a time. --}}
|
|
<div class="space-y-3">
|
|
<div class="flex flex-wrap items-end gap-3">
|
|
<div class="min-w-0 flex-1">
|
|
<x-input
|
|
id="new-tag"
|
|
wire:model.live.debounce.300ms="newTag"
|
|
wire:keydown.enter.prevent="addTag"
|
|
list="tag-suggestions"
|
|
:label="__('jobs.tags.new')"
|
|
:hint="__('jobs.tags.new_description')"
|
|
autocomplete="off"
|
|
/>
|
|
<datalist id="tag-suggestions">
|
|
@foreach ($this->tagSuggestions as $suggestion)
|
|
<option value="{{ $suggestion }}"></option>
|
|
@endforeach
|
|
</datalist>
|
|
</div>
|
|
<x-button wire:click="addTag" subtle color="black" icon="plus" :text="__('jobs.tags.add')" />
|
|
</div>
|
|
|
|
<p id="tags-label" class="text-sm font-semibold text-gray-700 dark:text-dark-300">{{ __('jobs.fields.tags') }}</p>
|
|
@if ($form->tags === [])
|
|
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tags.none') }}</p>
|
|
@else
|
|
<ul aria-labelledby="tags-label" class="flex flex-wrap gap-2">
|
|
@foreach ($form->tags as $index => $tag)
|
|
<li wire:key="tag-{{ $tag }}" class="inline-flex items-center gap-1 rounded-full border border-zinc-300 py-1 pr-1 pl-3 text-sm dark:border-zinc-600">
|
|
{{ $tag }}
|
|
<x-button.circle
|
|
wire:click="removeTag({{ $index }})"
|
|
subtle
|
|
color="black"
|
|
xs
|
|
icon="x-mark"
|
|
:aria-label="__('jobs.tags.remove', ['tag' => $tag])"
|
|
/>
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
@endif
|
|
@error('form.tags')
|
|
<p class="text-sm text-red-700 dark:text-red-400">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|
|
|
|
{{-- Links: title and address per row. --}}
|
|
<div class="space-y-3">
|
|
<p class="text-sm font-semibold text-gray-700 dark:text-dark-300">{{ __('jobs.fields.links') }}</p>
|
|
|
|
@if ($form->links === [])
|
|
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.links.none') }}</p>
|
|
@endif
|
|
|
|
@foreach ($form->links as $index => $link)
|
|
<fieldset wire:key="link-{{ $index }}" class="space-y-3 rounded-lg border border-zinc-200 p-3 dark:border-zinc-700">
|
|
<legend class="px-1 text-sm font-medium">{{ __('jobs.links.link_number', ['number' => $index + 1]) }}</legend>
|
|
<div class="grid gap-3 sm:grid-cols-2">
|
|
<x-input id="link-title-{{ $index }}" wire:model="form.links.{{ $index }}.title" :label="__('jobs.links.title')" autocomplete="off" />
|
|
<x-input id="link-url-{{ $index }}" wire:model="form.links.{{ $index }}.url" type="url" :label="__('jobs.links.url')" :hint="__('jobs.links.url_description')" autocomplete="off" />
|
|
</div>
|
|
<x-button
|
|
wire:click="removeLink({{ $index }})"
|
|
subtle
|
|
color="black"
|
|
sm
|
|
icon="trash"
|
|
:text="__('jobs.links.remove', ['number' => $index + 1])"
|
|
/>
|
|
</fieldset>
|
|
@endforeach
|
|
|
|
<x-button id="add-link" wire:click="addLink" subtle color="black" sm icon="plus" :text="__('jobs.links.add')" />
|
|
|
|
@error('form.links')
|
|
<p class="text-sm text-red-700 dark:text-red-400">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|
|
|
|
<x-textarea wire:model="form.instructions" :label="__('jobs.fields.instructions')" :hint="__('jobs.fields.instructions_description')" resize-auto />
|
|
</fieldset>
|
|
|
|
<div class="flex flex-wrap gap-3">
|
|
<x-button submit :text="__('jobs.save')" />
|
|
<x-button
|
|
:href="$jobId === null ? route('jobs.index') : route('jobs.show', $jobId)"
|
|
wire:navigate
|
|
subtle
|
|
color="black"
|
|
:text="__('jobs.cancel')"
|
|
/>
|
|
</div>
|
|
</form>
|
|
</div>
|