Skip to content

Commit 6e7fb9f

Browse files
Add ProblemDetails component
1 parent 12b3cab commit 6e7fb9f

8 files changed

Lines changed: 188 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span [class]="judgementClass()">{{ judgementText() }}</span>

frontend/src/app/annotate/annotation-input/problem-details/judgement-badge/judgement-badge.component.scss

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from "@angular/core/testing";
2+
3+
import { JudgementBadgeComponent } from "./judgement-badge.component";
4+
5+
describe("JudgementBadgeComponent", () => {
6+
let component: JudgementBadgeComponent;
7+
let fixture: ComponentFixture<JudgementBadgeComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [JudgementBadgeComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(JudgementBadgeComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it("should create", () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Component, computed, input } from "@angular/core";
2+
import { Judgement } from "../../../../types";
3+
4+
@Component({
5+
selector: "la-judgement-badge",
6+
standalone: true,
7+
imports: [],
8+
templateUrl: "./judgement-badge.component.html",
9+
styleUrl: "./judgement-badge.component.scss",
10+
})
11+
export class JudgementBadgeComponent {
12+
public judgement = input.required<Judgement>();
13+
14+
public judgementText = computed<string>(() => {
15+
const judgement = this.judgement();
16+
switch (judgement) {
17+
case Judgement.ENTAILMENT:
18+
return "Entailment";
19+
case Judgement.CONTRADICTION:
20+
return "Contradiction";
21+
case Judgement.NEUTRAL:
22+
return "Neutral";
23+
case Judgement.UNKNOWN:
24+
default:
25+
return "Unknown";
26+
}
27+
});
28+
29+
public judgementClass = computed<string>(() => {
30+
const judgement = this.judgement();
31+
switch (judgement) {
32+
case Judgement.ENTAILMENT:
33+
return "badge text-bg-success";
34+
case Judgement.CONTRADICTION:
35+
return "badge text-bg-danger";
36+
case Judgement.NEUTRAL:
37+
return "badge text-bg-secondary";
38+
case Judgement.UNKNOWN:
39+
return "badge text-bg-warning";
40+
default:
41+
return "badge text-bg-secondary";
42+
}
43+
});
44+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<div class="problem-details-container">
2+
<div class="judgement-badge-container">
3+
<span>Judgement:</span>
4+
<la-judgement-badge
5+
[judgement]="problemDetails().judgement"
6+
></la-judgement-badge>
7+
</div>
8+
9+
<table class="table table-sm table-borderless">
10+
<tbody>
11+
<tr>
12+
<td class="text-muted" i18n>ID:</td>
13+
<td>{{ problemDetails().problemId }}</td>
14+
</tr>
15+
<tr>
16+
<td class="text-muted" i18n>Dataset:</td>
17+
<td>{{ problemDetails().dataset }}</td>
18+
</tr>
19+
<tr>
20+
<td class="text-muted" i18n>Section:</td>
21+
<td>{{ sectionString() }}</td>
22+
</tr>
23+
@if (problemDetails().comment) {
24+
<tr>
25+
<td class="text-muted">
26+
<span i18n>Comment:</span>
27+
<fa-icon
28+
class="ms-1"
29+
[icon]="faQuestionCircle"
30+
aria-hidden="true"
31+
ngbTooltip="Comments provided by Bill McCartney."
32+
i18n-ngbTooltip
33+
/>
34+
</td>
35+
<td><i>{{ problemDetails().comment }}</i></td>
36+
</tr>
37+
}
38+
</tbody>
39+
</table>
40+
</div>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.problem-detail-container {
2+
position: relative;
3+
}
4+
5+
.judgement-badge-container {
6+
position: absolute;
7+
top: 1em;
8+
right: 1em;
9+
display: flex;
10+
gap: 0.5em;
11+
}
12+
13+
.table {
14+
td:first-child {
15+
width: 8em;
16+
}
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from "@angular/core/testing";
2+
3+
import { ProblemDetailsComponent } from "./problem-details.component";
4+
5+
describe("ProblemDetailsComponent", () => {
6+
let component: ProblemDetailsComponent;
7+
let fixture: ComponentFixture<ProblemDetailsComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [ProblemDetailsComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(ProblemDetailsComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it("should create", () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Component, computed, input } from "@angular/core";
2+
import { Dataset, Judgement } from "../../../types";
3+
import { JudgementBadgeComponent } from "./judgement-badge/judgement-badge.component";
4+
import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";
5+
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
6+
import { NgbTooltipModule } from "@ng-bootstrap/ng-bootstrap";
7+
8+
export interface ProblemDetails {
9+
problemId: string;
10+
dataset: Dataset;
11+
judgement: Judgement;
12+
section: string | null;
13+
subsection: string | null;
14+
comment: string | null;
15+
}
16+
17+
@Component({
18+
selector: "la-problem-details",
19+
standalone: true,
20+
imports: [JudgementBadgeComponent, FontAwesomeModule, NgbTooltipModule],
21+
templateUrl: "./problem-details.component.html",
22+
styleUrl: "./problem-details.component.scss",
23+
})
24+
export class ProblemDetailsComponent {
25+
public problemDetails = input.required<ProblemDetails>();
26+
27+
public faQuestionCircle = faQuestionCircle;
28+
29+
public sectionString = computed<string | null>(() => {
30+
const problemDetails = this.problemDetails();
31+
const section = problemDetails.section;
32+
const subsection = problemDetails.subsection;
33+
if (section && subsection) {
34+
return `${section} | ${subsection}`;
35+
} else if (section) {
36+
return section;
37+
} else if (subsection) {
38+
return subsection;
39+
}
40+
return null;
41+
});
42+
}

0 commit comments

Comments
 (0)