Skip to content
Merged

Dev #10

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
2 changes: 1 addition & 1 deletion app/Console/Commands/TranslateMissing.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function handle()
$newLocaleTranslations[$kbt] = $localeTranslations[$kbt];
}
}
File::put($filePath, json_encode($newLocaleTranslations, JSON_UNESCAPED_UNICODE));
File::put($filePath, json_encode($newLocaleTranslations, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));
}
}
$bar->advance();
Expand Down
2 changes: 2 additions & 0 deletions app/Exports/TicketHoursExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function headings(): array
'Time',
'Hours',
'Date',
'Comment',
];
}

Expand All @@ -41,6 +42,7 @@ public function collection()
'time' => $item->forHumans,
'hours' => number_format($item->value, 2, ',', ' '),
'date' => $item->created_at->format(__('Y-m-d g:i A')),
'comment' => $item->comment
]);
}
}
63 changes: 35 additions & 28 deletions app/Filament/Resources/TicketResource/Pages/ViewTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\TicketHour;
use App\Models\TicketSubscriber;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\TimePicker;
use Filament\Forms\Concerns\InteractsWithForms;
Expand Down Expand Up @@ -81,35 +82,41 @@ protected function getActions(): array
'url' => route('filament.resources.tickets.share', $this->record->code)
])),
Actions\EditAction::make(),
Actions\Action::make('logHours')
->label(__('Log time'))
->icon('heroicon-o-clock')
->color('warning')
->modalWidth('sm')
->modalHeading(__('Log worked time'))
->modalSubheading(__('Use the following form to add your worked time in this ticket.'))
->modalButton(__('Log'))
->visible(fn() => in_array(
auth()->user()->id,
[$this->record->owner_id, $this->record->responsible_id]
))
->form([
TextInput::make('time')
->label(__('Time to log'))
->numeric()
->required(),

Textarea::make('comment')
->label(__('Comment'))
->rows(3),
])
->action(function (Collection $records, array $data): void {
$value = $data['time'];
$comment = $data['comment'];
TicketHour::create([
'ticket_id' => $this->record->id,
'user_id' => auth()->user()->id,
'value' => $value,
'comment' => $comment
]);
$this->record->refresh();
$this->notify('success', __('Time logged into ticket'));
}),
Actions\ActionGroup::make([
Actions\Action::make('logHours')
->label(__('Log time'))
->icon('heroicon-o-clock')
->color('warning')
->modalWidth('sm')
->modalHeading(__('Log worked time'))
->modalSubheading(__('Use the following form to add your worked time in this ticket.'))
->modalButton(__('Log'))
->visible(fn() => in_array(
auth()->user()->id,
[$this->record->owner_id, $this->record->responsible_id]
))
->form([
TextInput::make('time')
->label(__('Time to log'))
->numeric()
->required()
])
->action(function (Collection $records, array $data): void {
$value = $data['time'];
TicketHour::create([
'ticket_id' => $this->record->id,
'user_id' => auth()->user()->id,
'value' => $value
]);
$this->record->refresh();
$this->notify('success', __('Time logged into ticket'));
}),
Actions\Action::make('exportLogHours')
->label(__('Export time logged'))
->icon('heroicon-o-document-download')
Expand Down
2 changes: 1 addition & 1 deletion app/Models/TicketHour.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TicketHour extends Model
use HasFactory;

protected $fillable = [
'user_id', 'ticket_id', 'value'
'user_id', 'ticket_id', 'value', 'comment'
];

public function user(): BelongsTo
Expand Down
Loading