Skip to content

Commit

Permalink
Move student list under /events/current #712 #713
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Dec 17, 2024
1 parent ea3225b commit e356872
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
<td class="subject">
@if (isTeacher$ | async) {
@let link = buildLink(entry.eventId);
<a
[routerLink]="link.link"
[queryParams]="link.params"
target="_parent"
>
<a [routerLink]="link.link" [queryParams]="link.params">
{{ entry.subject
}}<span class="subject-study-class"
>, {{ entry.studyClass }}</span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe("DashboardTimetableComponent", () => {
let link = rows[0].querySelector("td.subject a");
expect(link?.textContent?.trim()).toBe("Mathematik, 9a");
expect(link?.getAttribute("href")).toBe(
"/events/students/10?returnlink=%252Fdashboard",
"/events/current/10?returnlink=%252Fdashboard",
);

expect(rows[0].querySelector("td.study-class")?.textContent).toContain(
Expand All @@ -192,7 +192,7 @@ describe("DashboardTimetableComponent", () => {
link = rows[1].querySelector("td.subject a");
expect(link?.textContent?.trim()).toBe("Zeichnen, 8c");
expect(link?.getAttribute("href")).toBe(
"/events/students/20?returnlink=%252Fdashboard",
"/events/current/20?returnlink=%252Fdashboard",
);

expect(rows[1].querySelector("td.study-class")?.textContent).toContain(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { StorageService } from "src/app/shared/services/storage.service";
import { buildTestModuleMetadata } from "src/spec-helpers";
import { EventsCurrentListComponent } from "./events-current-list.component";

describe("EventsCurrentListComponent", () => {
let component: EventsCurrentListComponent;
let fixture: ComponentFixture<EventsCurrentListComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule(
buildTestModuleMetadata({
imports: [EventsCurrentListComponent],
providers: [
{
provide: StorageService,
useValue: {
getPayload() {
return {
culture_info: "",
fullname: "",
id_person: "123",
holder_id: "",
instance_id: "",
roles: "",
};
},
},
},
],
}),
).compileComponents();

fixture = TestBed.createComponent(EventsCurrentListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it("should create", () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ChangeDetectionStrategy, Component } from "@angular/core";
import { TranslateModule } from "@ngx-translate/core";
import { EventsListComponent } from "../events-list/events-list.component";

@Component({
selector: "bkd-events-current-list",
standalone: true,
imports: [EventsListComponent, TranslateModule],
templateUrl: "./events-current-list.component.html",
styleUrl: "./events-current-list.component.scss",
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class EventsCurrentListComponent {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { StorageService } from "src/app/shared/services/storage.service";
import { buildTestModuleMetadata } from "../../../../spec-helpers";
import { EventsCurrentComponent } from "./events-current.component";

Expand All @@ -11,23 +10,6 @@ describe("EventsCurrentComponent", () => {
await TestBed.configureTestingModule(
buildTestModuleMetadata({
imports: [EventsCurrentComponent],
providers: [
{
provide: StorageService,
useValue: {
getPayload() {
return {
culture_info: "",
fullname: "",
id_person: "123",
holder_id: "",
instance_id: "",
roles: "",
};
},
},
},
],
}),
).compileComponents();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Component } from "@angular/core";
import { TranslateModule } from "@ngx-translate/core";
import { EventsListComponent } from "../events-list/events-list.component";
import { RouterOutlet } from "@angular/router";

@Component({
selector: "bkd-events-current",
templateUrl: "./events-current.component.html",
styleUrls: ["./events-current.component.scss"],
template: `<router-outlet></router-outlet>`,
standalone: true,
imports: [EventsListComponent, TranslateModule],
imports: [RouterOutlet],
})
export class EventsCurrentComponent {
constructor() {}
Expand Down
16 changes: 10 additions & 6 deletions src/app/events/events.routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Routes } from "@angular/router";
import { dossierRoute } from "../shared/components/student-dossier/dossier-route";
import { EventsCurrentListComponent } from "./components/events-current-list/events-current-list.component";
import { EventsCurrentComponent } from "./components/events-current/events-current.component";
import { EventsStudentsListComponent } from "./components/events-students-list/events-students-list.component";
import { EventsStudentsComponent } from "./components/events-students/events-students.component";
Expand All @@ -22,13 +23,16 @@ export const EVENTS_ROUTES: Routes = [
{
path: "current",
component: EventsCurrentComponent,
},
{
path: "students/:id",
component: EventsStudentsComponent,
children: [
{ path: "", component: EventsStudentsListComponent },
dossierRoute,
{ path: "", component: EventsCurrentListComponent },
{
path: ":id",
component: EventsStudentsComponent,
children: [
{ path: "", component: EventsStudentsListComponent },
dossierRoute,
],
},
],
},
{
Expand Down
14 changes: 7 additions & 7 deletions src/app/events/services/events-state.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe("EventsStateService", () => {
{
id: 5,
designation: "22a",
detailLink: "/events/students/5?returnlink=%2F",
detailLink: "/events/current/5?returnlink=%2F",
studentCount: 0,
state: null,
},
Expand All @@ -92,7 +92,7 @@ describe("EventsStateService", () => {
{
id: 6,
designation: "22b",
detailLink: "/events/students/6?returnlink=%2F",
detailLink: "/events/current/6?returnlink=%2F",
studentCount: 0,
state: EventState.Rating,
evaluationText: "events.state.rating",
Expand Down Expand Up @@ -156,7 +156,7 @@ describe("EventsStateService", () => {
const courseEvent: EventEntry = {
id: 1,
designation: "Physik, 22a, 22b",
detailLink: "/events/students/1?returnlink=%2F",
detailLink: "/events/current/1?returnlink=%2F",
dateFrom: new Date("2022-02-09T00:00:00"),
dateTo: new Date("2022-06-30T00:00:00"),
studentCount: 20,
Expand All @@ -170,7 +170,7 @@ describe("EventsStateService", () => {
...courseEvent,
id: 2,
designation: "Bio, 22a",
detailLink: "/events/students/2?returnlink=%2F",
detailLink: "/events/current/2?returnlink=%2F",
state: EventState.RatingUntil,
evaluationText: "events.state.rating-until 03.06.2022",
evaluationLink: "link-to-evaluation-module/2",
Expand All @@ -179,7 +179,7 @@ describe("EventsStateService", () => {
...courseEvent,
id: 4,
designation: "Franz, 22a, 22b",
detailLink: "/events/students/4?returnlink=%2F",
detailLink: "/events/current/4?returnlink=%2F",
state: EventState.Tests,
evaluationText: "events.state.add-tests",
},
Expand All @@ -188,7 +188,7 @@ describe("EventsStateService", () => {
...courseEvent,
id: 3,
designation: "Zeichnen, 22b",
detailLink: "/events/students/3?returnlink=%2F",
detailLink: "/events/current/3?returnlink=%2F",
state: EventState.IntermediateRating,
evaluationText: "events.state.intermediate-rating",
evaluationLink: "link-to-evaluation-module/3",
Expand All @@ -214,7 +214,7 @@ describe("EventsStateService", () => {
id: 10,
designation: "Zentraler Gymnasialer Bildungsgang",
studentCount: 3,
detailLink: "/events/students/10?returnlink=%2F",
detailLink: "/events/current/10?returnlink=%2F",
state: null,
},
];
Expand Down
2 changes: 1 addition & 1 deletion src/app/events/utils/events-students.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getEventsStudentsLink(
const query = new URLSearchParams(
returnLink ? { returnlink: returnLink } : {},
);
return `/events/students/${eventId}?${query}`;
return `/events/current/${eventId}?${query}`;
}

export function convertCourseToStudentEntries(course: Course): StudentEntries {
Expand Down

0 comments on commit e356872

Please sign in to comment.