Skip to content

Commit 413b58d

Browse files
authored
SF-3558 Update draft generation UI on language change (#3474)
1 parent e7a5145 commit 413b58d

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-history-list/draft-history-entry/draft-history-entry.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
>
88
<mat-expansion-panel-header [collapsedHeight]="'auto'" [expandedHeight]="'auto'">
99
<mat-panel-title>
10-
<span class="title">{{ scriptureRange }}</span>
10+
<span class="title">{{ i18n.formatAndLocalizeScriptureRange(scriptureRange) }}</span>
1111
<span class="subtitle">
1212
{{ translationSource }}
1313
{{ t("finished_at", { finishedAtTime: formatDate(entry.additionalInfo?.dateFinished) }) }}
@@ -110,7 +110,9 @@
110110
<table mat-table [dataSource]="trainingConfiguration">
111111
<ng-container matColumnDef="scriptureRange">
112112
<th mat-header-cell *matHeaderCellDef>{{ t("training_books") }}</th>
113-
<td mat-cell *matCellDef="let element">{{ element.scriptureRange }}</td>
113+
<td mat-cell *matCellDef="let element" class="scriptureRange">
114+
{{ i18n.formatAndLocalizeScriptureRange(element.scriptureRange) }}
115+
</td>
114116
</ng-container>
115117
<ng-container matColumnDef="source">
116118
<th mat-header-cell *matHeaderCellDef>

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-history-list/draft-history-entry/draft-history-entry.component.spec.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ describe('DraftHistoryEntryComponent', () => {
116116
tick();
117117
fixture.detectChanges();
118118

119-
expect(component.scriptureRange).toEqual('Genesis');
119+
expect(component.scriptureRange).toEqual('GEN');
120+
expect(fixture.nativeElement.querySelector('.title').innerText).toBe('Genesis');
120121
expect(component.translationSource).toEqual('src \u2022');
121122
expect(component.buildRequestedByUserName).toBe(user);
122123
expect(component.buildRequestedAtDate).toBe(date);
@@ -129,13 +130,14 @@ describe('DraftHistoryEntryComponent', () => {
129130
expect(component.targetLanguage).toBe('en');
130131
expect(component.trainingConfiguration).toEqual([
131132
{
132-
scriptureRange: 'Exodus',
133+
scriptureRange: 'EXO',
133134
source: 'src',
134135
target: 'tar'
135136
}
136137
]);
137138
expect(component.trainingDataFiles).toEqual(Array.from(trainingDataFiles.values()));
138139
expect(component.trainingConfigurationOpen).toBe(false);
140+
expect(fixture.nativeElement.querySelector('.scriptureRange')).toBeNull();
139141
expect(fixture.nativeElement.querySelector('.requested-label')).not.toBeNull();
140142
}));
141143

@@ -171,7 +173,8 @@ describe('DraftHistoryEntryComponent', () => {
171173
tick();
172174
fixture.detectChanges();
173175

174-
expect(component.scriptureRange).toEqual('Genesis');
176+
expect(component.scriptureRange).toEqual('GEN');
177+
expect(fixture.nativeElement.querySelector('.title').innerText).toBe('Genesis');
175178
expect(component.draftIsAvailable).toBe(true);
176179
expect(fixture.nativeElement.querySelector('.format-usfm')).not.toBeNull();
177180
}));
@@ -204,7 +207,8 @@ describe('DraftHistoryEntryComponent', () => {
204207
tick();
205208
fixture.detectChanges();
206209

207-
expect(component.scriptureRange).toEqual('Genesis');
210+
expect(component.scriptureRange).toEqual('GEN');
211+
expect(fixture.nativeElement.querySelector('.title').innerText).toBe('Genesis');
208212
expect(component.translationSource).toEqual('');
209213
expect(component.buildRequestedByUserName).toBeUndefined();
210214
expect(component.buildRequestedAtDate).toBe('');
@@ -217,12 +221,13 @@ describe('DraftHistoryEntryComponent', () => {
217221
expect(component.targetLanguage).toBe('');
218222
expect(component.trainingConfiguration).toEqual([
219223
{
220-
scriptureRange: 'Exodus',
224+
scriptureRange: 'EXO',
221225
source: 'Unknown',
222226
target: 'Unknown'
223227
}
224228
]);
225229
expect(component.trainingConfigurationOpen).toBe(true);
230+
expect(fixture.nativeElement.querySelector('.scriptureRange').innerText).toBe('Exodus');
226231
}));
227232

228233
it('should handle builds with additional info referencing a deleted user', fakeAsync(() => {
@@ -252,7 +257,8 @@ describe('DraftHistoryEntryComponent', () => {
252257
tick();
253258
fixture.detectChanges();
254259

255-
expect(component.scriptureRange).toEqual('Genesis');
260+
expect(component.scriptureRange).toEqual('GEN');
261+
expect(fixture.nativeElement.querySelector('.title').innerText).toBe('Genesis');
256262
expect(component.buildRequestedByUserName).toBeUndefined();
257263
expect(component.buildRequestedAtDate).toBe('formatted-date');
258264
expect(component.draftIsAvailable).toBe(true);

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-history-list/draft-history-entry/draft-history-entry.component.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class DraftHistoryEntryComponent {
7171
// Get the user who requested the build
7272
this._buildRequestedByUserName = undefined;
7373
if (this._entry?.additionalInfo?.requestedByUserId != null) {
74-
this.userService.getProfile(this._entry.additionalInfo.requestedByUserId).then(user => {
74+
void this.userService.getProfile(this._entry.additionalInfo.requestedByUserId).then(user => {
7575
if (user.data != null) {
7676
this._buildRequestedByUserName = user.data.displayName;
7777
}
@@ -85,7 +85,7 @@ export class DraftHistoryEntryComponent {
8585

8686
// Get the books used in the training configuration
8787
const trainingScriptureRanges = this._entry?.additionalInfo?.trainingScriptureRanges ?? [];
88-
Promise.all(
88+
void Promise.all(
8989
trainingScriptureRanges.map(async r => {
9090
// The engine ID is the target project ID
9191
let target: SFProjectProfileDoc | undefined = undefined;
@@ -104,7 +104,7 @@ export class DraftHistoryEntryComponent {
104104

105105
// Return the data for this training range
106106
return {
107-
scriptureRange: this.i18n.formatAndLocalizeScriptureRange(r.scriptureRange),
107+
scriptureRange: r.scriptureRange,
108108
source: source?.data?.shortName ?? this.i18n.translateStatic('draft_history_entry.draft_unknown'),
109109
target: target?.data?.shortName ?? this.i18n.translateStatic('draft_history_entry.draft_unknown')
110110
} as TrainingConfigurationRow;
@@ -121,11 +121,9 @@ export class DraftHistoryEntryComponent {
121121

122122
// Get the translation scripture range and project (usually one, but in the future will be multiple)
123123
const translationScriptureRanges = this._entry?.additionalInfo?.translationScriptureRanges ?? [];
124-
this._scriptureRange = this.i18n.formatAndLocalizeScriptureRange(
125-
translationScriptureRanges.map(item => item.scriptureRange).join(';')
126-
);
124+
this._scriptureRange = translationScriptureRanges.map(item => item.scriptureRange).join(';');
127125
this._translationSources = [];
128-
Promise.all(
126+
void Promise.all(
129127
translationScriptureRanges.map(async r => {
130128
const source =
131129
r.projectId === '' || r.projectId === value?.engine?.id
@@ -139,7 +137,7 @@ export class DraftHistoryEntryComponent {
139137
const trainingDataFiles: string[] = this._entry?.additionalInfo?.trainingDataFileIds ?? [];
140138
if (this.activatedProjectService.projectId != null && trainingDataFiles.length > 0) {
141139
this.dataFileQuery?.dispose();
142-
this.trainingDataService
140+
void this.trainingDataService
143141
.queryTrainingDataAsync(this.activatedProjectService.projectId, this.destroyRef)
144142
.then(query => {
145143
this.dataFileQuery = query;

0 commit comments

Comments
 (0)