-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from itk-dev/feature/3489-workload-report-per…
…iod-average-etc 3489: workload report period average + etc
- Loading branch information
Showing
32 changed files
with
1,132 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Controller } from "@hotwired/stimulus"; | ||
|
||
/** | ||
* Table highlight controller. | ||
* | ||
* Highlights the `<thead>` and first cell (`<th>` or `<td>`) of the row when | ||
* hovering over a cell. | ||
*/ | ||
export default class extends Controller { | ||
connect() { | ||
this.element.addEventListener( | ||
"mouseenter", | ||
(event) => this.highlight(event), | ||
true, | ||
); | ||
this.element.addEventListener( | ||
"mouseleave", | ||
(event) => this.clearHighlights(event), | ||
true, | ||
); | ||
} | ||
|
||
/** | ||
* Handles the highlighting of the appropriate `<thead>` column and row | ||
* header. | ||
* | ||
* @param {MouseEvent} event | ||
*/ | ||
highlight(event) { | ||
// Only run if hovering a `<td>` (and not child elements like <span> or <a>) | ||
if (event.target.tagName !== "TD") return; | ||
|
||
const cell = event.target; // The actual hovered cell | ||
|
||
// Find the index of the hovered cell (column index) | ||
const cellIndex = Array.from(cell.parentNode.children).indexOf(cell); | ||
|
||
// Highlight the corresponding column header (<th>) in the `<thead>` | ||
const columnHeader = this.element.querySelector( | ||
`thead th:nth-child(${cellIndex + 1})`, | ||
); | ||
if (columnHeader) columnHeader.classList.add("highlight-column"); | ||
|
||
// Highlight the first cell in the row (supports both <td> and <th>) | ||
const rowStartCell = cell.parentNode.querySelector( | ||
"th:first-child, td:first-child", | ||
); | ||
if (rowStartCell) rowStartCell.classList.add("highlight-row"); | ||
} | ||
|
||
/** | ||
* Clears all highlights when leaving a cell. | ||
* | ||
* @param {MouseEvent} event | ||
*/ | ||
clearHighlights(event) { | ||
// Only run if leaving a `<td>` (and not child elements) | ||
if (event.target.tagName !== "TD") return; | ||
|
||
// Remove the highlight class from all highlighted elements | ||
this.element.querySelectorAll(".highlight-column").forEach((header) => { | ||
header.classList.remove("highlight-column"); | ||
}); | ||
|
||
this.element | ||
.querySelectorAll(".highlight-row") | ||
.forEach((rowStartCell) => { | ||
rowStartCell.classList.remove("highlight-row"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20250102120303 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE worker ADD include_in_reports TINYINT(1) DEFAULT 1 NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE worker DROP include_in_reports'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use App\Form\InvoicingRateReportType; | ||
use App\Model\Reports\InvoicingRateReportFormData; | ||
use App\Model\Reports\InvoicingRateReportViewModeEnum; | ||
use App\Model\Reports\WorkloadReportPeriodTypeEnum as PeriodTypeEnum; | ||
use App\Service\InvoicingRateReportService; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Symfony\Component\Security\Http\Attribute\IsGranted; | ||
|
||
#[Route('/admin/reports/invoicing_rate_report')] | ||
#[IsGranted('ROLE_REPORT')] | ||
class InvoicingRateReportController extends AbstractController | ||
{ | ||
public function __construct( | ||
private readonly InvoicingRateReportService $invoicingRateReportService, | ||
) { | ||
} | ||
|
||
/** | ||
* @throws \DateMalformedStringException | ||
*/ | ||
#[Route('/', name: 'app_invoicing_rate_report')] | ||
public function index(Request $request): Response | ||
{ | ||
$reportData = null; | ||
$error = null; | ||
$mode = 'invoicing_rate_report'; | ||
$reportFormData = new InvoicingRateReportFormData(); | ||
|
||
$form = $this->createForm(InvoicingRateReportType::class, $reportFormData, [ | ||
'action' => $this->generateUrl('app_invoicing_rate_report'), | ||
'method' => 'GET', | ||
'attr' => [ | ||
'id' => 'sprint_report', | ||
], | ||
'years' => [ | ||
(new \DateTime())->modify('-1 year')->format('Y'), | ||
(new \DateTime())->format('Y'), | ||
], | ||
'csrf_protection' => false, | ||
]); | ||
|
||
$form->handleRequest($request); | ||
|
||
if ($form->isSubmitted() && $form->isValid()) { | ||
$viewPeriodType = $form->get('viewPeriodType')->getData() ?? PeriodTypeEnum::WEEK; | ||
$viewMode = InvoicingRateReportViewModeEnum::SUMMARY; | ||
$year = $form->get('year')->getData(); | ||
$includeIssues = $form->get('includeIssues')->getData(); | ||
|
||
try { | ||
$reportData = $this->invoicingRateReportService->getInvoicingRateReport($year, $viewPeriodType, $viewMode, $includeIssues); | ||
} catch (\Exception $e) { | ||
$error = $e->getMessage(); | ||
} | ||
} | ||
|
||
return $this->render('reports/reports.html.twig', [ | ||
'controller_name' => 'InvoicingRateReportController', | ||
'form' => $form, | ||
'error' => $error, | ||
'data' => $reportData, | ||
'mode' => $mode, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.