diff --git a/assets/app.js b/assets/app.js index 8ed6e87..157e085 100644 --- a/assets/app.js +++ b/assets/app.js @@ -13,8 +13,10 @@ import './styles/emoji-footprint.css'; import './javascript/theme.js'; import './javascript/emoji-footprint.js'; import './javascript/modes.js'; +import htmx from 'htmx.org'; import { initNumberInputs } from './javascript/numberInputs.js'; import { initRadioState } from './javascript/radioState.js'; +window.htmx = htmx; // Initialize everything when DOM is ready document.addEventListener('DOMContentLoaded', function() { diff --git a/importmap.php b/importmap.php index 1dea2bd..f880a22 100644 --- a/importmap.php +++ b/importmap.php @@ -37,4 +37,7 @@ return [ 'chart.js/auto' => [ 'version' => '4.5.0', ], + 'htmx.org' => [ + 'version' => '2.0.6', + ], ]; diff --git a/src/Controller/DrinkTypeController.php b/src/Controller/DrinkTypeController.php index 714e92d..54c39a9 100644 --- a/src/Controller/DrinkTypeController.php +++ b/src/Controller/DrinkTypeController.php @@ -110,4 +110,19 @@ final class DrinkTypeController extends AbstractController return $this->redirectToRoute('app_drink_type_index', [], Response::HTTP_SEE_OTHER); } + + #[Route(path: '/{id}/history-chart', name: 'app_drink_type_history_chart', methods: ['GET'])] + public function historyChart( + DrinkType $drinkType, + GetStockHistory $getStockHistory, + GetWantedHistory $getWantedHistory, + ): Response { + return $this->render('components/history_chart_with_dismiss.html.twig', [ + 'stock_history' => $getStockHistory($drinkType), + 'wanted_history' => $getWantedHistory($drinkType), + 'chart_id' => 'stockHistoryChart_' . $drinkType->getId(), + 'title' => $drinkType->getName() . ' History', + 'drink_type_id' => $drinkType->getId(), + ]); + } } diff --git a/templates/components/history_chart_with_dismiss.html.twig b/templates/components/history_chart_with_dismiss.html.twig new file mode 100644 index 0000000..09740f3 --- /dev/null +++ b/templates/components/history_chart_with_dismiss.html.twig @@ -0,0 +1,118 @@ +