diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php index 4c1e44863832354b6a5846522f3ae302038ca106..91991b66a9796f5f60fdfdadf366afd86ad9fdc1 100644 --- a/app/controllers/admin/courses.php +++ b/app/controllers/admin/courses.php @@ -1750,6 +1750,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 16d577b62d8a15bc614f89de1bedf0eec6ad0f38..c3805355b882aa2fddbe956e1d51627280feee92 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. @@ -111,6 +112,11 @@ class SearchWidget extends SidebarWidget $this->onsubmit = $onsubmit; } + public function setOnClearHandler(string $onclear): void + { + $this->onclear = $onclear; + } + /** * Renders the widget. * @@ -174,6 +180,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"