Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/Helpers/KanbanScrumHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ trait KanbanScrumHelper
public $includeNotAffectedTickets = false;

public bool $ticket = false;
public Ticket|null $ticketToEdit = null;

protected function formSchema(): array
{
Expand Down Expand Up @@ -186,9 +187,16 @@ public function createTicket(): void
$this->ticket = true;
}

public function editTicket(Ticket $ticket): void
{
$this->ticketToEdit = $ticket;
}

public function closeTicketDialog(bool $refresh): void
{
$this->ticketToEdit = null;
$this->ticket = false;

if ($refresh) {
$this->filter();
}
Expand Down
42 changes: 23 additions & 19 deletions app/Http/Livewire/RoadMap/IssueForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,36 @@ class IssueForm extends Component implements HasForms
use InteractsWithForms;

public Project|null $project = null;
public Ticket|null $ticketToEdit = null;
public array $epics;
public array $sprints;

public function mount()
{
$this->initProject($this->project?->id);
if ($this->project?->status_type === 'custom') {
$defaultStatus = TicketStatus::where('project_id', $this->project->id)
$this->initProject($this->project?->id, $this->ticketToEdit ?: null);

$defaultStatus = ($this->project?->status_type === 'custom')
? TicketStatus::where('project_id', $this->project->id)
->where('is_default', true)
->first()
?->id;
} else {
$defaultStatus = TicketStatus::whereNull('project_id')
?->id
: TicketStatus::whereNull('project_id')
->where('is_default', true)
->first()
?->id;
}

$this->form->fill([
'project_id' => $this->project?->id ?? null,
'owner_id' => auth()->user()->id,
'status_id' => $defaultStatus,
'type_id' => TicketType::where('is_default', true)->first()?->id,
'priority_id' => TicketPriority::where('is_default', true)->first()?->id
'project_id' => $this->ticketToEdit?->project_id ?? $this->project?->id ?? null,
'owner_id' => $this->ticketToEdit?->owner_id ?? auth()->user()->id,
'status_id' => $this->ticketToEdit?->status_id ?? $defaultStatus,
'type_id' => $this->ticketToEdit?->type_id ?? TicketType::where('is_default', true)->first()?->id,
'priority_id' => $this->ticketToEdit?->priority_id ?? TicketPriority::where('is_default', true)->first()?->id,
'sprint_id' => $this->ticketToEdit?->sprint_id,
'epic_id' => $this->ticketToEdit?->epic_id,
'name' => $this->ticketToEdit?->name,
'responsible_id' => $this->ticketToEdit?->responsible_id,
'content' => $this->ticketToEdit?->content,
'estimation' => $this->ticketToEdit?->estimation,
]);
}

Expand All @@ -51,13 +58,10 @@ public function render()
return view('livewire.road-map.issue-form');
}

private function initProject($projectId): void
private function initProject($projectId, Ticket|null $ticketToEdit = null): void
{
if ($projectId) {
$this->project = Project::where('id', $projectId)->first();
} else {
$this->project = null;
}
$projectId = $ticketToEdit?->project_id ?? $projectId ?? null;
$this->project = $projectId ? Project::where('id', $projectId)->first() : null;
$this->epics = $this->project ? $this->project->epics->pluck('name', 'id')->toArray() : [];
$this->sprints = $this->project ? $this->project->sprints->pluck('name', 'id')->toArray() : [];
}
Expand Down Expand Up @@ -174,7 +178,7 @@ protected function getFormSchema(): array
public function submit(): void
{
$data = $this->form->getState();
Ticket::create($data);
$this->ticketToEdit ? $this->ticketToEdit->update($data) : Ticket::create($data);
Filament::notify('success', __('Ticket successfully saved'));
$this->cancel(true);
}
Expand Down
13 changes: 9 additions & 4 deletions resources/views/partials/kanban/record.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div class="kanban-record" data-id="{{ $record['id'] }}">
<div
class="kanban-record cursor-pointer" data-id="{{ $record['id'] }}"
wire:click="editTicket({{ $record['id'] }})"
>
<button type="button" class="handle">
<x-heroicon-o-arrows-expand class="w-5 h-5" />
</button>
Expand All @@ -8,9 +11,11 @@
{{ $record['project']->name }}
</span>
@endif
<a href="{{ route('filament.resources.tickets.view', $record['id']) }}"
target="_blank"
class="record-title">
<a
href="{{ route('filament.resources.tickets.view', $record['id']) }}"
target="_blank"
class="record-title hover:underline"
>
<span class="code">{{ $record['code'] }}</span>
<span class="title">{{ $record['title'] }}</span>
</a>
Expand Down
28 changes: 24 additions & 4 deletions resources/views/partials/kanban/status.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,35 @@
<x-heroicon-o-plus class="w-4 h-4" /> {{ __('Create ticket') }}
</a>

@if($ticket)
@if($ticketToEdit || $ticket)
<!-- Epic modal -->
<div class="dialog-container">
<div class="dialog dialog-xl">
<div class="dialog dialog-xl dark:bg-gray-900">
<div class="dialog-header">
{{ __('Create ticket') }}
<div class="flex justify-between items-center pb-3">
<p class="text-2xl font-bold">
{{ $ticketToEdit ? __('Edit ticket') : __('Create ticket') }}
</p>

@if ($ticketToEdit)
<div class="cursor-pointer z-50">
<a
href="{{ route('filament.resources.tickets.view', $record['id']) }}"
target="_blank"
class="record-title"
title="{{ __('View ticket in a new tab') }}"
>
@svg('heroicon-s-external-link', 'h-5 w-5')
</a>
</div>
@endif
</div>
</div>
<div class="dialog-content">
@livewire('road-map.issue-form', ['project' => null])
@livewire('road-map.issue-form', [
'project' => null,
'ticketToEdit' => $ticketToEdit ?: null,
])
</div>
</div>
</div>
Expand Down