aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-08-07 09:43:44 +0000
committerJan-Hendrik Willms <tleilax+github@gmail.com>2024-08-08 10:36:32 +0200
commit84703843efa493db952b119a1fd63a1b37bd3891 (patch)
tree48a18fdefbdc561803e35295be7f90706591ff35
parent86366e92e6cd8585ace1ef0098d3c9baa8f050cd (diff)
actually reset search on courses admin page, fixes #4460
Closes #4460 Merge request studip/studip!3245
-rw-r--r--app/controllers/admin/courses.php1
-rw-r--r--lib/classes/sidebar/SearchWidget.php7
-rw-r--r--templates/sidebar/search-widget.php2
3 files changed, 9 insertions, 1 deletions
diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php
index 4c1e448..91991b6 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 16d577b..c380535 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 c314673..e475f00 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"