Commit e249888f authored by Curtis Adam's avatar Curtis Adam

Restrict search according to actual route chosen

parent b9f76045
......@@ -275,8 +275,12 @@
"myprofile": "Konto",
"billing": "Abrechnung",
"membership": "Mitgliedschaft",
"searchMobile": "Suche…",
"search": "Suche nach Karteien oder Repetitorien…",
"search": {
"all": "Suche nach Karteien oder Repetitorien…",
"cardset": "Suche nach Karteien…",
"repetitorium": "Suche nach Repetitorien…",
"mobile": "Suche…"
},
"frontend": "Frontend",
"backend": "Backend",
"none": "Ohne",
......
......@@ -276,8 +276,12 @@
"myprofile": "Konto",
"billing": "Abrechnung",
"membership": "Mitgliedschaft",
"searchMobile": "Suche…",
"search": "Suche nach Karteien oder Repetitorien…",
"search": {
"all": "Suche nach Karteien oder Repetitorien…",
"cardset": "Suche nach Karteien…",
"repetitorium": "Suche nach Repetitorien…",
"mobile": "Suche…"
},
"frontend": "Frontend",
"backend": "Backend",
"none": "Ohne",
......
......@@ -266,7 +266,7 @@ const CardsetsSchema = new SimpleSchema({
Cardsets.attachSchema(CardsetsSchema);
Meteor.methods({
getSearchCategoriesResult: function (searchValue) {
getSearchCategoriesResult: function (searchValue, filterType) {
if (!Meteor.userId() || !UserPermissions.isNotBlockedOrFirstLogin()) {
throw new Meteor.Error("not-authorized");
} else if (searchValue !== undefined && searchValue !== null && searchValue.length > 2) {
......@@ -284,6 +284,13 @@ Meteor.methods({
]
};
}
if (filterType > 0) {
if (filterType === 1) {
query.shuffled = false;
} else {
query.shuffled = true;
}
}
let results = Cardsets.find(query, {fields: {_id: 1}}).fetch();
let filter = [];
if (results !== undefined) {
......
......@@ -2,6 +2,7 @@ import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {Search} from "../../../../../api/search.js";
import {MainNavigation} from "../../../../../api/mainNavigation.js";
import {Route} from "../../../../../api/route";
import "./search.html";
/*
......@@ -14,7 +15,13 @@ Template.mainNavigationTopItemSearchInput.events({
'keyup .input-search': function (event) {
event.preventDefault();
Session.set("searchValue", $(event.currentTarget).val());
Meteor.call('getSearchCategoriesResult', Session.get("searchValue"), function (error, result) {
let filterType = 0;
if (Route.isPool()) {
filterType = 1;
} else if (Route.isRepetitorium()) {
filterType = 2;
}
Meteor.call('getSearchCategoriesResult', Session.get("searchValue"), filterType, function (error, result) {
if (result) {
Session.set('searchCategoriesResult', result);
}
......@@ -42,9 +49,15 @@ Template.mainNavigationTopItemSearchInput.helpers({
},
getPlaceholder: function () {
if (this.longPlaceholder) {
return TAPi18n.__('navbar-collapse.search');
if (Route.isPool()) {
return TAPi18n.__('navbar-collapse.search.cardset');
} else if (Route.isRepetitorium()) {
return TAPi18n.__('navbar-collapse.search.repetitorium');
} else {
return TAPi18n.__('navbar-collapse.search.all');
}
} else {
return TAPi18n.__('navbar-collapse.searchMobile');
return TAPi18n.__('navbar-collapse.search.mobile');
}
}
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment