Core UI updates for helpdesk
This commit is contained in:
@@ -13,6 +13,7 @@ use Livewire\Component;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Livewire\WithFileUploads;
|
||||
use Modules\Helpdesk\Models\Category;
|
||||
use Modules\Helpdesk\Models\KanbanBoard;
|
||||
use Modules\Helpdesk\Models\Priority;
|
||||
use Modules\Helpdesk\Models\Product;
|
||||
use Modules\Helpdesk\Models\Project;
|
||||
@@ -33,6 +34,9 @@ final class TicketCreate extends Component
|
||||
#[Validate('required|string|min:10')]
|
||||
public string $body = '';
|
||||
|
||||
#[Validate('nullable|integer|exists:helpdesk_kanban_boards,id')]
|
||||
public ?int $board_id = null;
|
||||
|
||||
#[Validate('required|integer|exists:helpdesk_priorities,id')]
|
||||
public ?int $priority_id = null;
|
||||
|
||||
@@ -84,6 +88,7 @@ final class TicketCreate extends Component
|
||||
'company_id' => $this->company_id,
|
||||
'subject' => $this->subject,
|
||||
'body' => $this->body,
|
||||
'board_id' => $this->board_id,
|
||||
'priority_id' => $this->priority_id,
|
||||
'category_id' => $this->category_id,
|
||||
'project_id' => $this->project_id,
|
||||
@@ -101,6 +106,7 @@ final class TicketCreate extends Component
|
||||
public function render(): View
|
||||
{
|
||||
return view('helpdesk::livewire.ticket-create', [
|
||||
'boards' => $this->boardOptions(),
|
||||
'priorities' => $this->priorityOptions(),
|
||||
'categories' => $this->categoryOptions(),
|
||||
'companies' => $this->companyOptions(),
|
||||
@@ -123,6 +129,14 @@ final class TicketCreate extends Component
|
||||
->value('id');
|
||||
}
|
||||
|
||||
|
||||
if (blank($this->board_id) && Schema::hasTable('helpdesk_kanban_boards')) {
|
||||
$this->board_id = KanbanBoard::query()
|
||||
->where('is_default', true)
|
||||
->orderBy('sort_order')
|
||||
->value('id') ?: KanbanBoard::query()->orderBy('sort_order')->value('id');
|
||||
}
|
||||
|
||||
if (blank($this->priority_id) && $this->hasDefaultColumn('helpdesk_priorities')) {
|
||||
$this->priority_id = Priority::query()
|
||||
->where('is_default', true)
|
||||
@@ -175,6 +189,20 @@ final class TicketCreate extends Component
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return Kanban board options with the default board listed first.
|
||||
*/
|
||||
private function boardOptions(): mixed
|
||||
{
|
||||
return KanbanBoard::query()
|
||||
->with('owner:id,name,email')
|
||||
->orderByDesc('is_default')
|
||||
->orderBy('sort_order')
|
||||
->orderBy('name')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return priority options with default records listed first.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user