|
8 | 8 | use App\Models\TicketHour; |
9 | 9 | use App\Models\TicketSubscriber; |
10 | 10 | use Filament\Forms\Components\RichEditor; |
| 11 | +use Filament\Forms\Components\Textarea; |
11 | 12 | use Filament\Forms\Components\TextInput; |
12 | 13 | use Filament\Forms\Components\TimePicker; |
13 | 14 | use Filament\Forms\Concerns\InteractsWithForms; |
@@ -81,35 +82,41 @@ protected function getActions(): array |
81 | 82 | 'url' => route('filament.resources.tickets.share', $this->record->code) |
82 | 83 | ])), |
83 | 84 | Actions\EditAction::make(), |
| 85 | + Actions\Action::make('logHours') |
| 86 | + ->label(__('Log time')) |
| 87 | + ->icon('heroicon-o-clock') |
| 88 | + ->color('warning') |
| 89 | + ->modalWidth('sm') |
| 90 | + ->modalHeading(__('Log worked time')) |
| 91 | + ->modalSubheading(__('Use the following form to add your worked time in this ticket.')) |
| 92 | + ->modalButton(__('Log')) |
| 93 | + ->visible(fn() => in_array( |
| 94 | + auth()->user()->id, |
| 95 | + [$this->record->owner_id, $this->record->responsible_id] |
| 96 | + )) |
| 97 | + ->form([ |
| 98 | + TextInput::make('time') |
| 99 | + ->label(__('Time to log')) |
| 100 | + ->numeric() |
| 101 | + ->required(), |
| 102 | + |
| 103 | + Textarea::make('comment') |
| 104 | + ->label(__('Comment')) |
| 105 | + ->rows(3), |
| 106 | + ]) |
| 107 | + ->action(function (Collection $records, array $data): void { |
| 108 | + $value = $data['time']; |
| 109 | + $comment = $data['comment']; |
| 110 | + TicketHour::create([ |
| 111 | + 'ticket_id' => $this->record->id, |
| 112 | + 'user_id' => auth()->user()->id, |
| 113 | + 'value' => $value, |
| 114 | + 'comment' => $comment |
| 115 | + ]); |
| 116 | + $this->record->refresh(); |
| 117 | + $this->notify('success', __('Time logged into ticket')); |
| 118 | + }), |
84 | 119 | Actions\ActionGroup::make([ |
85 | | - Actions\Action::make('logHours') |
86 | | - ->label(__('Log time')) |
87 | | - ->icon('heroicon-o-clock') |
88 | | - ->color('warning') |
89 | | - ->modalWidth('sm') |
90 | | - ->modalHeading(__('Log worked time')) |
91 | | - ->modalSubheading(__('Use the following form to add your worked time in this ticket.')) |
92 | | - ->modalButton(__('Log')) |
93 | | - ->visible(fn() => in_array( |
94 | | - auth()->user()->id, |
95 | | - [$this->record->owner_id, $this->record->responsible_id] |
96 | | - )) |
97 | | - ->form([ |
98 | | - TextInput::make('time') |
99 | | - ->label(__('Time to log')) |
100 | | - ->numeric() |
101 | | - ->required() |
102 | | - ]) |
103 | | - ->action(function (Collection $records, array $data): void { |
104 | | - $value = $data['time']; |
105 | | - TicketHour::create([ |
106 | | - 'ticket_id' => $this->record->id, |
107 | | - 'user_id' => auth()->user()->id, |
108 | | - 'value' => $value |
109 | | - ]); |
110 | | - $this->record->refresh(); |
111 | | - $this->notify('success', __('Time logged into ticket')); |
112 | | - }), |
113 | 120 | Actions\Action::make('exportLogHours') |
114 | 121 | ->label(__('Export time logged')) |
115 | 122 | ->icon('heroicon-o-document-download') |
|
0 commit comments