Skip to content

Commit

Permalink
modified sprint report
Browse files Browse the repository at this point in the history
  • Loading branch information
jeppekroghitk committed Nov 29, 2023
1 parent 3e0bd19 commit d0b9933
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 161 deletions.
23 changes: 12 additions & 11 deletions src/Controller/SprintReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function index(Request $request): Response
$projectChoices = [];

foreach ($projects as $project) {
$projectChoices[$project->name] = $project->key;
$projectChoices[$project->name] = $project->id;
}

// Override projectId with element with choices.
Expand All @@ -67,16 +67,17 @@ public function index(Request $request): Response

if (!empty($requestData['projectId'])) {
$project = $this->apiService->getProject($requestData['projectId']);
$milestones = $this->apiService->getProjectMilestones($requestData['projectId']);

$versionChoices = [];
foreach ($project->versions as $version) {
$versionChoices[$version->name] = $version->id;
$milestoneChoices = [];
foreach ($milestones as $milestone) {
$milestoneChoices[$milestone->headline] = $milestone->id;
}

// Override versionId with element with choices.
$form->add('versionId', ChoiceType::class, [
// Override milestoneId with element with choices.
$form->add('milestoneId', ChoiceType::class, [
'placeholder' => 'sprint_report.select_an_option',
'choices' => $versionChoices,
'choices' => $milestoneChoices,
'required' => true,
'label' => 'sprint_report.select_version',
'label_attr' => ['class' => 'label'],
Expand All @@ -93,12 +94,12 @@ public function index(Request $request): Response
$sprintReportFormData = $form->getData();

$projectId = $form->get('projectId')->getData();
$versionId = $form->get('versionId')->getData();
$milestoneId = $form->get('milestoneId')->getData();

if (!empty($projectId) && !empty($versionId)) {
$reportData = $this->apiService->getSprintReportData($projectId, $versionId);
if (!empty($projectId) && !empty($milestoneId)) {
$reportData = $this->apiService->getSprintReportData($projectId, $milestoneId);

$budget = $this->sprintReportService->getBudget($projectId, $versionId);
$budget = $this->sprintReportService->getBudget($projectId, $milestoneId);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Form/SprintReportType.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'data-action' => 'sprint-report#submitFormProjectId',
],
])
->add('versionId', ChoiceType::class, [
->add('milestoneId', ChoiceType::class, [
'placeholder' => 'sprint_report.select_an_option',
'required' => false,
'label' => 'sprint_report.select_version',
Expand Down
6 changes: 5 additions & 1 deletion src/Service/ApiServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public function getPermissionsList(): array;

public function getProject($key): mixed;

public function getProjectMilestones($key): mixed;

public function getMilestone($key): mixed;

public function createProject(array $data): ?string;

public function createTimeTrackerCustomer(string $name, string $key): mixed;
Expand Down Expand Up @@ -57,7 +61,7 @@ public function getTicketsInSprint(string $sprintId): array;

public function getPlanningData(): PlanningData;

public function getSprintReportData(string $projectId, string $versionId): SprintReportData;
public function getSprintReportData(string $projectId, string $milestoneId): SprintReportData;

/**
* @return array<ClientData>
Expand Down
Loading

0 comments on commit d0b9933

Please sign in to comment.