Commit 600cfc5b authored by Elias Asikainen's avatar Elias Asikainen
Browse files

filters applied to courses sort of

parent 94c71118
......@@ -8,11 +8,7 @@ export default class DropdownComponent {
return m(
'select',
{ onchange: m.withAttr('value', vnode.selectedId), ...this.defaultProps, ...vnode.attrs },
[
vnode.attrs.data.map(label =>
m('option', { value: label.id, onklick: vnode.attrs.onselect }, label.name)
),
]
[vnode.attrs.data.map(label => m('option', { value: label.id }, label.name))]
);
}
}
......@@ -34,7 +34,7 @@ const subjects = {
'Maschinenelemente',
],
['Innovationsprozess'],
['Dynamics', 'Thermodynamik 1'],
['Dynamics', 'Thermodynamik 1', 'Philosophie'],
['Fluiddynamik1', 'Thermodynamik 2'],
[],
[],
......@@ -50,6 +50,7 @@ export default class studydocList {
static oninit() {
studydocs.load();
this.semester = 1;
this.lecture = 'Fach';
this.search = '';
this.filter = {};
Object.keys(filterNames).forEach(key => {
......@@ -59,16 +60,12 @@ export default class studydocList {
});
this.filter[key] = filterValue;
});
this.filter.semester = {};
for (let i = 0; i < 6; i += 1) {
this.filter.semester[String(i)] = false;
}
}
static selectDocument(doc) {
this.doc = doc;
}
static courseData() {
static lectureData() {
const data = [];
if (this.filter.department.itet || !this.filter.department.mavt) {
for (let i = 0; i < subjects.itet[this.semester - 1].length; i += 1) {
......@@ -85,6 +82,10 @@ export default class studydocList {
static changeFilter(filterKey, filterValue, checked) {
this.filter[filterKey][filterValue] = checked;
this.updateFilter();
}
static updateFilter() {
const query = {};
Object.keys(this.filter).forEach(key => {
let queryValue = '';
......@@ -99,6 +100,8 @@ export default class studydocList {
query[key] = { $regex: `^(?i).*${queryValue}.*` };
}
});
query.semester = { $regex: `^(?i).*${String(this.semester)}.*` };
query.lecture = { $regex: `^(?i).*${this.lecture}.*` };
studydocs.load(query);
}
......@@ -159,15 +162,16 @@ export default class studydocList {
{ id: 6, name: '6. Semester' },
],
onchange: event => {
this.changeFilter('semester', this.semester, false);
this.semester = event.target.value;
this.changeFilter('semester', this.semester, true);
this.updateFilter();
},
}),
m(Dropdown, {
data: this.courseData(),
data: this.lectureData(),
onchange: event => {
this.course = event.target.value;
this.lecture = event.target.value;
this.updateFilter();
console.log(this.lecture);
},
}),
]),
......
Supports Markdown
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