Skip to content
Snippets Groups Projects
Commit f824a94f authored by Thomas Hackl's avatar Thomas Hackl Committed by Jan-Hendrik Willms
Browse files

Resolve "Vorlesungsverzeichnis: Umstellen der Filter setzt die Suche zurück"

Closes #3043

Merge request studip/studip!2171
parent 152cc2ab
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@ class Search_CoursesController extends AuthenticatedController
$this->type = Request::option('type', 'semtree');
$this->semester = Request::option('semester', Semester::findCurrent()->id);
$this->semClass = Request::int('semclass', 0);
$this->search = Request::get('search', '');
}
public function index_action()
......@@ -69,17 +70,30 @@ class Search_CoursesController extends AuthenticatedController
{
$sidebar = Sidebar::Get();
$semWidget = new SemesterSelectorWidget($this->url_for(''), 'semester');
$semWidget = new SemesterSelectorWidget(URLHelper::getURL('', ['type' => $this->type, 'semclass' => $this->semClass]), 'semester');
$semWidget->includeAll(false);
$semWidget->setId('semester-selector');
$semWidget->setSelection($this->semester);
$sidebar->addWidget($semWidget);
$params = [
'type' => $this->type
];
if ($this->semClass !== 0) {
$params['semclass'] = $this->semClass;
}
if ($this->semester !== '') {
$params['semester'] = $this->semester;
}
if ($this->search !== '') {
$params['search'] = $this->search;
}
$classWidget = $sidebar->addWidget(new SelectWidget(
_('Veranstaltungskategorie'),
URLHelper::getURL('', ['type' => $this->type, 'semester' => $this->semester]),
URLHelper::getURL('', $params),
'semclass'
));
$classWidget->setId('semclass-selector');
$classWidget->addElement(new SelectElement(0, _('Alle')));
foreach (SemClass::getClasses() as $class) {
if (!$class['studygroup_mode']) {
......
......@@ -71,6 +71,13 @@ export default {
this.searchterm = '';
STUDIP.eventBus.emit('cancel-search');
}
},
mounted() {
const url = new URL(window.location.href);
if (url.searchParams.has('search')) {
this.searchterm = url.searchParams.get('search');
this.doSearch();
}
}
}
</script>
......@@ -31,7 +31,7 @@
<tree-search-result :search-config="searchConfig"></tree-search-result>
</div>
<MountingPortal v-if="withSearch" mountTo="#search-widget" name="sidebar-search">
<search-widget :min-length="3"></search-widget>
<search-widget v-if="currentNode" :min-length="3" ref="searchWidget"></search-widget>
</MountingPortal>
</div>
</template>
......@@ -175,6 +175,18 @@ export default {
},
exportUrl() {
return STUDIP.URLHelper.getURL('dispatch.php/tree/export_csv');
},
injectSearchterm(targetId, searchterm) {
const form = document.getElementById(targetId).querySelector('form');
let input = form.querySelector('input[type="hidden"][name="search"]');
if (!input) {
input = document.createElement('input');
input.setAttribute('id', `${targetId}-searchterm`);
input.setAttribute('type', 'hidden');
input.setAttribute('name', 'search');
form.appendChild(input);
}
input.setAttribute('value', searchterm);
}
},
mounted() {
......@@ -202,14 +214,20 @@ export default {
this.searchConfig = {
searchterm,
semester: this.semester,
semclass: this.semClass,
classname: this.startNode.attributes.classname,
startId: this.currentNode.id,
};
this.injectSearchterm('semester-selector', searchterm);
this.injectSearchterm('semclass-selector', searchterm);
this.isSearching = true;
});
this.globalOn('cancel-search', () => {
this.searchConfig = {};
this.searchterm = '';
document.getElementById('semester-selector-searchterm')?.remove();
document.getElementById('semclass-selector-searchterm')?.remove();
this.isSearching = false;
});
}
......
......@@ -101,7 +101,13 @@ export default {
);
this.getNode(this.searchConfig.startId).then(response => {
return this.getNodeCourses(response.data.data, this.searchConfig.semester, 0, this.searchConfig.searchterm, true);
return this.getNodeCourses(
response.data.data,
this.searchConfig.semester,
this.searchConfig.semclass,
this.searchConfig.searchterm,
true
);
}).then(courses => {
this.courses = courses.data.data;
......
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