From f74ec0146d39a13600235888ba8ad3e84e24dcc5 Mon Sep 17 00:00:00 2001 From: Nils Haagen Date: Mon, 8 Jul 2024 15:02:51 +0200 Subject: [PATCH] UI: add DD JS to Input View Controls (#62) --- .../Component/Input/ViewControl/Renderer.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/components/ILIAS/UI/src/Implementation/Component/Input/ViewControl/Renderer.php b/components/ILIAS/UI/src/Implementation/Component/Input/ViewControl/Renderer.php index e1ff8df6ef55..7b8170c61769 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Input/ViewControl/Renderer.php +++ b/components/ILIAS/UI/src/Implementation/Component/Input/ViewControl/Renderer.php @@ -21,6 +21,7 @@ namespace ILIAS\UI\Implementation\Component\Input\ViewControl; use ILIAS\UI\Implementation\Render\AbstractComponentRenderer; +use ILIAS\UI\Implementation\Render\ResourceRegistry; use ILIAS\UI\Renderer as RendererInterface; use ILIAS\UI\Component; use LogicException; @@ -117,6 +118,10 @@ function(event, signal_data) { fn($id) => "$('#{$id} > .dropdown-menu') .on('click', (event) => event.stopPropagation());" ); + $component = $component->withAdditionalOnLoadCode( + fn($id) => + "il.UI.dropdown.init(document.getElementById(\"$id\"));" + ); $id = $this->bindJavaScript($component); $container_submit_signal = $component->getOnChangeSignal(); @@ -175,6 +180,10 @@ function(event, signal_data) { });" ); } + $component = $component->withAdditionalOnLoadCode( + fn($id) => + "il.UI.dropdown.init(document.getElementById(\"$id\"));" + ); $id = $this->bindJavaScript($component); $tpl->setVariable('ID', $id); @@ -354,6 +363,15 @@ function(event, signal_data) { });" ); } + $component = $component->withAdditionalOnLoadCode( + fn($id) => " + il.UI.dropdown.init( + document.getElementById(\"$id\").querySelector( + '.dropdown.il-viewcontrol-pagination__num-of-items' + ) + ); + " + ); $id = $this->bindJavaScript($component); $tpl->setVariable('ID', $id); @@ -371,4 +389,13 @@ function(event, signal_data) { return $tpl->get(); } + + /** + * @inheritdoc + */ + public function registerResources(ResourceRegistry $registry): void + { + parent::registerResources($registry); + $registry->register('assets/js/dropdown.js'); + } }