Skip to content
Snippets Groups Projects
Commit 53729c3d authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

actually reset search on courses admin page, fixes #4460

Closes #4460

Merge request studip/studip!3245
parent a73d0ae6
No related branches found
No related tags found
No related merge requests found
......@@ -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');
}
......
......@@ -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);
}
......
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment