ticket story poitns rework

This commit is contained in:
2026-04-13 00:10:09 +02:00
parent 041e79efda
commit b3f2cc3afd
17 changed files with 208 additions and 73 deletions
@@ -5,6 +5,7 @@ namespace App\Actions\Tickets;
use App\Models\Project;
use App\Models\Ticket;
use App\Models\User;
use Arr;
use Illuminate\Support\Facades\DB;
class CreateProjectTicket
@@ -39,6 +40,7 @@ class CreateProjectTicket
'ticket_priority_id' => $attributes['ticket_priority_id'],
'ticket_type_id' => $attributes['ticket_type_id'],
'title' => $attributes['title'],
'story_points' => Arr::get($attributes, 'story_points'),
]);
if ($actor !== null) {
@@ -47,7 +47,7 @@ class ProjectTicketController extends Controller
'parentTicketOptions' => Ticket::query()
->where('project_id', $project->id)
->whereNotIn('id', $excludedParentIds)
->whereHas('ticketType', fn ($query) => $query->where('system_key', 'parent'))
->whereHas('ticketType', fn ($query) => $query->where('is_parent', true))
->orderByDesc('sequence_number')
->get()
->map(fn (Ticket $parentTicket): array => [
@@ -119,6 +119,7 @@ class ProjectTicketController extends Controller
'ticket_priority_id' => Arr::get($validated, 'ticket_priority_id'),
'ticket_type_id' => Arr::get($validated, 'ticket_type_id'),
'title' => Arr::get($validated, 'title'),
'story_points' => Arr::get($validated, 'story_points'),
];
$wasUpdated = $this->updateProjectTicket->handle(
@@ -8,6 +8,7 @@ use App\Http\Requests\StoreProjectNamedSettingRequest;
use App\Http\Requests\StoreProjectTicketTypeRequest;
use App\Http\Requests\StoreTicketFieldDefinitionRequest;
use App\Http\Requests\UpdateProjectNamedSettingRequest;
use App\Http\Requests\UpdateProjectTicketMetadataSettings;
use App\Http\Requests\UpdateTicketFieldDefinitionRequest;
use App\Models\Project;
use App\Models\TicketFieldDefinition;
@@ -50,6 +51,16 @@ class ProjectTicketMetadataSettingsController extends Controller
]);
}
public function update(UpdateProjectTicketMetadataSettings $request, Project $project): RedirectResponse
{
$validated = $request->validated();
$project->update(['show_story_points' => Arr::get($validated, 'show_story_points', false)]);
return to_route('projects.settings.metadata', $project)
->with('status', 'Settings have been updated.');
}
public function storeType(StoreProjectTicketTypeRequest $request, Project $project): RedirectResponse
{
$this->abortUnlessCanManage($request, $project);
@@ -40,6 +40,7 @@ class StoreProjectTicketRequest extends FormRequest
'integer',
Rule::exists('ticket_types', 'id')->where('project_id', $project->id),
],
'story_points' => ['nullable', 'integer', 'min:0'],
'title' => ['required', 'string', 'max:255'],
];
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class UpdateProjectTicketMetadataSettings extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return $this->user() !== null;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'show_story_points' => 'nullable|boolean',
];
}
}
@@ -61,6 +61,7 @@ class UpdateProjectTicketRequest extends FormRequest
Rule::exists('ticket_types', 'id')->where('project_id', $project->id),
],
'title' => ['required', 'string', 'max:255'],
'story_points' => ['nullable', 'integer', 'gt:0'],
];
}
+8 -1
View File
@@ -11,12 +11,19 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Support\Str;
#[Fillable(['name', 'key'])]
#[Fillable(['name', 'key', 'show_story_points'])]
class Project extends Model
{
/** @use HasFactory<ProjectFactory> */
use HasFactory;
protected function casts(): array
{
return [
'show_story_points' => 'boolean',
];
}
protected static function booted(): void
{
static::deleting(function (self $project): void {
+1
View File
@@ -22,6 +22,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
'ticket_priority_id',
'ticket_type_id',
'title',
'story_points',
])]
class Ticket extends Model
{