Skip to content

Commit

Permalink
Display/sort lastname, firstname on students lists #712 #713
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Dec 16, 2024
1 parent 23ec8f5 commit 6369eb2
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
></bkd-avatar>
<a
class="name"
[title]="name()"
[title]="entry().name"
[routerLink]="link()"
[queryParams]="linkParams()"
>{{ name() }}</a
>{{ entry().name }}</a
>
<div class="study-class">
{{ multipleStudyClasses() ? entry().studyClass : "" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ describe("EventsStudentsCourseEntryComponent", () => {

fixture.componentRef.setInput("entry", {
id: 1,
firstName: "Jane",
lastName: "Doe",
name: "Doe Jane",
email: "jane.doe@example.com",
studyClass: "26a",
company: "Coop Genossenschaft",
Expand All @@ -31,7 +30,7 @@ describe("EventsStudentsCourseEntryComponent", () => {

it("renders firstname/lastname with link to dossier including returnlink", () => {
const link = element.querySelector<HTMLAnchorElement>("a.name");
expect(link?.textContent).toContain("Jane Doe");
expect(link?.textContent).toContain("Doe Jane");
expect(link?.href).toContain(
"student/1/absences?returnparams=returnlink%3D%252Fevents%252Fcurrent",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export class EventsStudentsCourseEntryComponent {
multipleStudyClasses = input(false);
returnLink = input<Option<string>>(null);

name = computed<string>(
() => `${this.entry().firstName} ${this.entry().lastName}`,
);

link = computed<RouterLink["routerLink"]>(() => [
"student",
this.entry().id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,28 @@ describe("EventsStudentsListComponent", () => {
const entries: ReadonlyArray<StudentEntry> = [
{
id: 10,
firstName: "Paul",
lastName: "McCartney",
name: "McCartney Paul",
email: "paul.mccartney@example.com",
studyClass: "26a",
company: "Apple Records – Abbey Road Studios",
},
{
id: 20,
firstName: "John",
lastName: "Lennon",
name: "Lennon John",
email: "john.lennon@example.com",
studyClass: "26a",
company: undefined,
},
{
id: 30,
firstName: "George",
lastName: "Harrison",
name: "Harrison George",
email: "george.harrison@example.com",
studyClass: "26c",
company: undefined,
},
{
id: 40,
firstName: "Ringo",
lastName: "Starr",
name: "Starr Ringo",
email: "ringo.starr@example.com",
studyClass: "26c",
company: undefined,
Expand Down Expand Up @@ -104,10 +100,10 @@ describe("EventsStudentsListComponent", () => {
element.querySelector("bkd-events-students-course-list"),
).not.toBeNull();
expect(element.querySelector("h1")?.textContent).toContain("English-S3");
expect(element.textContent).toContain("Paul McCartney");
expect(element.textContent).toContain("John Lennon");
expect(element.textContent).toContain("George Harrison");
expect(element.textContent).toContain("Ringo Starr");
expect(element.textContent).toContain("McCartney Paul");
expect(element.textContent).toContain("Lennon John");
expect(element.textContent).toContain("Harrison George");
expect(element.textContent).toContain("Starr Ringo");
});

it("renders placeholder if no entries are available", () => {
Expand All @@ -129,10 +125,10 @@ describe("EventsStudentsListComponent", () => {
element.querySelector("bkd-events-students-study-course-list"),
).not.toBeNull();
expect(element.querySelector("h1")?.textContent).toContain("English-S3");
expect(element.textContent).toContain("Paul McCartney");
expect(element.textContent).toContain("John Lennon");
expect(element.textContent).toContain("George Harrison");
expect(element.textContent).toContain("Ringo Starr");
expect(element.textContent).toContain("McCartney Paul");
expect(element.textContent).toContain("Lennon John");
expect(element.textContent).toContain("Harrison George");
expect(element.textContent).toContain("Starr Ringo");
});

it("renders placeholder if no entries are available", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a class="name" [routerLink]="link()" [queryParams]="linkParams()">{{
name()
entry().name
}}</a>
<div class="status">{{ entry().status }}</div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ describe("EventsStudentsStudyCourseEntryComponent", () => {
element = fixture.debugElement.nativeElement;
fixture.componentRef.setInput("entry", {
id: 1,
firstName: "Jane",
lastName: "Doe",
name: "Doe Jane",
email: "jane.doe@example.com",
studyClasses: ["26a", "26c"],
company: "Coop Genossenschaft",
Expand All @@ -33,7 +32,7 @@ describe("EventsStudentsStudyCourseEntryComponent", () => {

it("renders firstname/lastname with link to dossier including returnlink", () => {
const link = element.querySelector<HTMLAnchorElement>("a.name");
expect(link?.textContent).toBe("Jane Doe");
expect(link?.textContent).toBe("Doe Jane");
expect(link?.href).toContain(
"student/1/absences?returnparams=returnlink%3D%252Fevents%252Fcurrent",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ export class EventsStudentsStudyCourseEntryComponent {
entry = input.required<StudentEntry>();
returnLink = input<Option<string>>(null);

name = computed<string>(
() => `${this.entry().firstName} ${this.entry().lastName}`,
);
link = computed<RouterLink["routerLink"]>(() => [
"student",
this.entry().id,
Expand Down
Loading

0 comments on commit 6369eb2

Please sign in to comment.