fix: catalog module semester selection

This commit is contained in:
Rainer Killinger
2023-04-20 11:24:23 +02:00
parent 9e160e8d1e
commit afbd1fc048
2 changed files with 5 additions and 4 deletions

View File

@@ -117,8 +117,9 @@ export class CatalogComponent implements OnInit, OnDestroy {
semester => semester.startDate <= today && semester.endDate > today,
);
const currentSemesterIndex = semesters.findIndex(semester => semester.uid === currentSemester?.uid);
this.availableSemesters = semesters.slice(currentSemesterIndex - 1, currentSemesterIndex + 2).reverse();
this.availableSemesters = semesters
.slice(Math.max(0, currentSemesterIndex - 1), Math.min(currentSemesterIndex + 2, semesters.length))
.reverse();
if (typeof this.activeSemester !== 'undefined') {
return;
}

View File

@@ -121,11 +121,11 @@ export class CatalogProvider {
arguments: {
bounds: {
lowerBound: {
limit: `${new Date().setFullYear(new Date().getFullYear() - 1)}`,
limit: `${new Date(new Date().setFullYear(new Date().getFullYear() - 1)).toISOString}`,
mode: 'inclusive',
},
upperBound: {
limit: `${new Date().setFullYear(new Date().getFullYear() + 1)}`,
limit: `${new Date(new Date().setFullYear(new Date().getFullYear() + 1)).toISOString}`,
mode: 'inclusive',
},
},