-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract events list entry to separate component #671
- Loading branch information
Showing
14 changed files
with
202 additions
and
140 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/app/events/components/events-list-entry/events-list-entry.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<div class="designation"> | ||
<a [href]="event.detailLink">{{ event.Designation }}</a> | ||
</div> | ||
<div class="date"> | ||
<span *ngIf="event.dateFrom && event.dateTo" | ||
>{{ event.dateFrom | date: "dd.MM.yyyy" }}–<wbr />{{ | ||
event.dateTo | date: "dd.MM.yyyy" | ||
}}</span | ||
> | ||
</div> | ||
<div class="registrations"> | ||
{{ event.studentCount }} | ||
<span class="registrations-label">{{ | ||
(event.studentCount === 1 ? "events.registration" : "events.registrations") | ||
| translate | ||
}}</span> | ||
</div> | ||
<div class="rating" *ngIf="withRatings && event.evaluationText"> | ||
<a | ||
*ngIf="!event.evaluationLink" | ||
class="d-flex" | ||
[routerLink]="[event.id, 'tests']" | ||
> | ||
<i class="material-icons">arrow_right_alt</i> | ||
<span class="ps-1">{{ event.evaluationText }}</span> | ||
</a> | ||
<a *ngIf="event.evaluationLink" class="d-flex" [href]="event.evaluationLink"> | ||
<i class="material-icons">arrow_right_alt</i> | ||
<span class="ps-1">{{ event.evaluationText }} </span> | ||
</a> | ||
</div> |
66 changes: 66 additions & 0 deletions
66
src/app/events/components/events-list-entry/events-list-entry.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@import "../../../../bootstrap-variables"; | ||
@import "node_modules/bootstrap/scss/mixins"; | ||
|
||
:host { | ||
display: grid; | ||
padding: $spacer; | ||
border-bottom: 1px solid $border-color; | ||
grid-template-areas: "designation date registrations rating"; | ||
grid-template-columns: 4fr 2fr 2fr 3fr; | ||
} | ||
|
||
.designation { | ||
grid-area: designation; | ||
padding-right: $spacer; | ||
} | ||
|
||
.date { | ||
grid-area: date; | ||
padding-right: $spacer; | ||
} | ||
|
||
.registrations { | ||
grid-area: registrations; | ||
padding-right: $spacer; | ||
} | ||
|
||
.rating { | ||
grid-area: rating; | ||
|
||
a { | ||
text-decoration: none; | ||
} | ||
|
||
span { | ||
text-decoration: underline; | ||
} | ||
|
||
span:hover { | ||
text-decoration-color: $accent; | ||
} | ||
} | ||
|
||
.registrations-label { | ||
display: none; | ||
} | ||
|
||
@include media-breakpoint-down(sm) { | ||
.registrations-label { | ||
display: inline; | ||
} | ||
|
||
.designation, | ||
.date, | ||
.registrations { | ||
padding-right: 0; | ||
} | ||
|
||
:host { | ||
grid-template-areas: | ||
"designation" | ||
"date" | ||
"registrations" | ||
"rating"; | ||
grid-template-columns: 1fr; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/app/events/components/events-list-entry/events-list-entry.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
import { buildEvent } from "src/spec-builders"; | ||
import { buildTestModuleMetadata } from "src/spec-helpers"; | ||
import { EventsListEntryComponent } from "./events-list-entry.component"; | ||
|
||
describe("EventsListEntryComponent", () => { | ||
let component: EventsListEntryComponent; | ||
let fixture: ComponentFixture<EventsListEntryComponent>; | ||
let element: HTMLElement; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule( | ||
buildTestModuleMetadata({ | ||
imports: [EventsListEntryComponent], | ||
}), | ||
).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(EventsListEntryComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.debugElement.nativeElement; | ||
|
||
component.event = buildEvent(1); | ||
component.event.evaluationText = "Lorem ipsum"; | ||
}); | ||
|
||
it("renders entry without ratings column", () => { | ||
component.withRatings = false; | ||
|
||
fixture.detectChanges(); | ||
expect(element.querySelector(".rating")).toBeNull(); | ||
expect(element.textContent).not.toContain("Lorem ipsum"); | ||
}); | ||
|
||
it("renders entry with ratings column", () => { | ||
component.withRatings = true; | ||
|
||
fixture.detectChanges(); | ||
expect(element.querySelector(".rating")).toBeTruthy(); | ||
expect(element.textContent).toContain("Lorem ipsum"); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
src/app/events/components/events-list-entry/events-list-entry.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { DatePipe, NgIf } from "@angular/common"; | ||
import { Component, Input } from "@angular/core"; | ||
import { RouterLink } from "@angular/router"; | ||
import { TranslateModule } from "@ngx-translate/core"; | ||
import { Event } from "../../services/events-state.service"; | ||
|
||
@Component({ | ||
selector: "bkd-events-list-entry", | ||
standalone: true, | ||
imports: [NgIf, RouterLink, DatePipe, TranslateModule], | ||
templateUrl: "./events-list-entry.component.html", | ||
styleUrl: "./events-list-entry.component.scss", | ||
}) | ||
export class EventsListEntryComponent { | ||
@Input() event: Event; | ||
@Input() withRatings: boolean = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.