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

fix oer search difficulty level filter, fixes #2429

Closes #2429

Merge request studip/studip!3514
parent 0feb5a50
No related branches found
No related tags found
No related merge requests found
...@@ -20,28 +20,28 @@ ...@@ -20,28 +20,28 @@
- -
<span>{{ difficulty[1] }}</span> <span>{{ difficulty[1] }}</span>
<a href="#" <a href="#"
@click.prevent="clearDifficulty" @click.prevent="clearDifficulty()"
class="erasefilter" class="erasefilter"
title="<?= _('Filter des Niveaus entfernen') ?>"> title="<?= _('Filter des Niveaus entfernen') ?>">
<studip-icon shape="decline" role="clickable" :size="16" class="text-bottom"></studip-icon> <studip-icon shape="decline" class="text-bottom"></studip-icon>
</a> </a>
</span> </span>
<input type="text" <input type="text"
name="search" name="search"
@focus="showFilterPanel" @focus="showFilterPanel()"
@keyup="sync_search_text" @keyup="sync_search_text()"
@keydown.enter.prevent="search"> @keydown.enter.prevent="search()">
<button v-if="difficulty[0] != 1 || difficulty[1] != 12 || (category != null) || (searchtext.length > 0)" <button v-if="difficulty[0] != 1 || difficulty[1] != 12 || (category != null) || (searchtext.length > 0)"
class="erase" class="erase"
type="button" type="button"
title="<?= _('Suchformular zurücksetzen') ?>" title="<?= _('Suchformular zurücksetzen') ?>"
@click="clearAllFilters"> @click="clearAllFilters()">
<studip-icon shape="decline" role="clickable"></studip-icon> <studip-icon shape="decline" role="clickable"></studip-icon>
</button> </button>
<button @click="triggerFilterPanel" <button @click="triggerFilterPanel()"
type="button" type="button"
title="<?= _('Suchfilter einstellen') ?>" title="<?= _('Suchfilter einstellen') ?>"
:class="activeFilterPanel ? 'active' : ''"> :class="activeFilterPanel ? 'active' : ''">
......
...@@ -66,7 +66,7 @@ const OER = { ...@@ -66,7 +66,7 @@ const OER = {
clearAllFilters: function (keep_results) { clearAllFilters: function (keep_results) {
this.clearCategory(); this.clearCategory();
this.clearDifficulty(); this.clearDifficulty();
if (this.searchtext != '') { if (this.searchtext.length !== 0) {
this.searchtext = ''; this.searchtext = '';
} }
$(".oer_search input[name=search]").val(''); $(".oer_search input[name=search]").val('');
...@@ -75,10 +75,9 @@ const OER = { ...@@ -75,10 +75,9 @@ const OER = {
} }
}, },
clearDifficulty: function () { clearDifficulty: function () {
if ((this.difficulty[0] != 1) && (this.difficulty[1] != 12)) { this.difficulty[0] = 1;
this.difficulty = [1, 12]; this.difficulty[1] = 12;
} jQuery('#difficulty_slider').slider('values', this.difficulty);
jQuery("#difficulty_slider").slider("values", this.difficulty);
}, },
clearCategory: function () { clearCategory: function () {
if (this.category != null) { if (this.category != null) {
...@@ -201,7 +200,7 @@ const OER = { ...@@ -201,7 +200,7 @@ const OER = {
} }
} }
}, },
mounted: function () { mounted() {
this.results = $(this.$el).data('searchresults'); this.results = $(this.$el).data('searchresults');
if (this.results !== false) { if (this.results !== false) {
$("#new_ones").hide(); $("#new_ones").hide();
...@@ -209,8 +208,14 @@ const OER = { ...@@ -209,8 +208,14 @@ const OER = {
if ($(this.$el).data('filteredcategory')) { if ($(this.$el).data('filteredcategory')) {
this.category = $(this.$el).data('filteredcategory'); this.category = $(this.$el).data('filteredcategory');
} }
document.addEventListener('click', (event) => {
if (event.closest('.searchform') === null) {
this.hideFilterPanel();
}
})
}, },
updated: function () { updated() {
this.$nextTick(function () { this.$nextTick(function () {
if (!jQuery("#difficulty_slider.ui-slider").length) { //to prevent an endless loop if (!jQuery("#difficulty_slider.ui-slider").length) { //to prevent an endless loop
let v = this; let v = this;
...@@ -228,14 +233,6 @@ const OER = { ...@@ -228,14 +233,6 @@ const OER = {
} }
}); });
}); });
jQuery(document).on("click", function (evnt) {
if (!jQuery(evnt.target).is(".searchform *") && STUDIP.OER.Search) {
STUDIP.OER.Search.hideFilterPanel();
}
});
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment