diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php index 984d0ca7a227e61be178e8b92837351d3b5b83dc..5f16d21ef54d1f6c70d36878cf45e8c3aa6d06b8 100644 --- a/app/controllers/admin/courses.php +++ b/app/controllers/admin/courses.php @@ -1751,6 +1751,7 @@ class Admin_CoursesController extends AuthenticatedController $GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT ); $search->setOnSubmitHandler("STUDIP.AdminCourses.App.changeFilter({search: $(this).find('input').val()}); return false;"); + $search->setOnClearHandler("STUDIP.AdminCourses.App.changeFilter({search: ''});"); $sidebar->addWidget($search, 'filter_search'); } diff --git a/lib/classes/sidebar/SearchWidget.php b/lib/classes/sidebar/SearchWidget.php index 5a42e948be4ee21d6fb9a6f006c504a6c1e22d2a..58acacbafc72ddc8cc40a9348dae173cac699588 100644 --- a/lib/classes/sidebar/SearchWidget.php +++ b/lib/classes/sidebar/SearchWidget.php @@ -17,6 +17,7 @@ class SearchWidget extends SidebarWidget protected $method = 'get'; protected $id = null; protected $onsubmit = null; + protected ?string $onclear = null; /** * Constructor for the widget. @@ -108,6 +109,11 @@ class SearchWidget extends SidebarWidget $this->onsubmit = $onsubmit; } + public function setOnClearHandler(string $onclear): void + { + $this->onclear = $onclear; + } + /** * Renders the widget. * @@ -171,6 +177,7 @@ class SearchWidget extends SidebarWidget $this->template_variables['has_data'] = $this->hasData(); $this->template_variables['onsubmit'] = $this->onsubmit; + $this->template_variables['onclear'] = $this->onclear; return parent::render($variables); } diff --git a/templates/sidebar/search-widget.php b/templates/sidebar/search-widget.php index c3146735384fb550723724b60c6947893dff3ea2..e475f00a87db7a2b78a6bd0b96eb6bd256d8fe8d 100644 --- a/templates/sidebar/search-widget.php +++ b/templates/sidebar/search-widget.php @@ -33,7 +33,7 @@ <?= Icon::create('decline')->asInput([ 'title' => _('Suche zurücksetzen'), 'class' => 'reset-search', - 'onclick' => "document.getElementById('needle-".$hash."').value = ''; this.remove();" + 'onclick' => "document.getElementById('needle-".$hash."').value = ''; this.remove();" . ($onclear ?? ''), ]) ?> <? else : ?> <a class="reset-search" href="<?= $reset_link ?>" tabindex="0" role="button"