diff --git a/app/Filament/Pages/Kanban.php b/app/Filament/Pages/Kanban.php index b6fd9e761..9019e9bfb 100644 --- a/app/Filament/Pages/Kanban.php +++ b/app/Filament/Pages/Kanban.php @@ -9,7 +9,6 @@ use App\Models\TicketType; use App\Models\User; use Filament\Facades\Filament; -use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\Select; @@ -21,7 +20,6 @@ use Illuminate\Contracts\Support\Htmlable; use Illuminate\Support\Collection; use Illuminate\Support\HtmlString; -use Closure; class Kanban extends Page implements HasForms { @@ -44,8 +42,11 @@ class Kanban extends Page implements HasForms public $priorities = []; public $includeNotAffectedTickets = false; + public bool $ticket = false; + protected $listeners = [ - 'recordUpdated' + 'recordUpdated', + 'closeTicketDialog' ]; public function mount() @@ -253,4 +254,17 @@ public function resetFilters(): void $this->filter(); } + public function createTicket(): void + { + $this->ticket = true; + } + + public function closeTicketDialog(bool $refresh): void + { + $this->ticket = false; + if ($refresh) { + $this->filter(); + } + } + } diff --git a/app/Http/Livewire/RoadMap/IssueForm.php b/app/Http/Livewire/RoadMap/IssueForm.php index 007de42f4..178b3b71f 100644 --- a/app/Http/Livewire/RoadMap/IssueForm.php +++ b/app/Http/Livewire/RoadMap/IssueForm.php @@ -18,11 +18,16 @@ class IssueForm extends Component implements HasForms { use InteractsWithForms; - public Project $project; + public Project|null $project = null; + public array $epics; public function mount() { - $project = Project::where('id', $this->project->id)->first(); + if ($this->project) { + $project = Project::where('id', $this->project->id)->first(); + } else { + $project = null; + } if ($project?->status_type === 'custom') { $defaultStatus = TicketStatus::where('project_id', $project->id) ->where('is_default', true) @@ -34,8 +39,9 @@ public function mount() ->first() ?->id; } + $this->epics = $this->project ? $this->project->epics->pluck('name', 'id')->toArray() : []; $this->form->fill([ - 'project_id' => $this->project->id, + 'project_id' => $this->project?->id ?? null, 'owner_id' => auth()->user()->id, 'status_id' => $defaultStatus, 'type_id' => TicketType::where('is_default', true)->first()?->id, @@ -59,8 +65,8 @@ protected function getFormSchema(): array ->label(__('Project')) ->searchable() ->reactive() - ->disabled() - ->columnSpan(1) + ->disabled($this->project != null) + ->columnSpan(fn () => $this->project == null ? 2 : 1) ->options(fn() => Project::where('owner_id', auth()->user()->id) ->orWhereHas('users', function ($query) { return $query->where('users.id', auth()->user()->id); @@ -74,7 +80,8 @@ protected function getFormSchema(): array ->reactive() ->columnSpan(1) ->required() - ->options($this->project->epics->pluck('name', 'id')->toArray()), + ->visible($this->project != null) + ->options($this->epics), Forms\Components\TextInput::make('name') ->label(__('Ticket name')) diff --git a/resources/views/partials/kanban/status.blade.php b/resources/views/partials/kanban/status.blade.php index aafc73d21..a460d1239 100644 --- a/resources/views/partials/kanban/status.blade.php +++ b/resources/views/partials/kanban/status.blade.php @@ -14,12 +14,27 @@ @include('partials.kanban.record') @endforeach + @if($status['add_ticket']) - {{ __('Create ticket') }} + + @if($ticket) + +
+
+
+ {{ __('Create ticket') }} +
+
+ @livewire('road-map.issue-form', ['project' => null]) +
+
+
+ @endif @endif