Skip to content

Commit 05b66ef

Browse files
authored
SF-3492 Show what source a draft was translated from (#3356)
1 parent 611cfd2 commit 05b66ef

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
<mat-expansion-panel-header [collapsedHeight]="'auto'" [expandedHeight]="'auto'">
99
<mat-panel-title>
1010
<span class="title">{{ scriptureRange }}</span>
11-
<span class="subtitle">{{
12-
t("finished_at", { finishedAtTime: formatDate(entry.additionalInfo?.dateFinished) })
13-
}}</span>
11+
<span class="subtitle">
12+
{{ translationSource }}
13+
{{ t("finished_at", { finishedAtTime: formatDate(entry.additionalInfo?.dateFinished) }) }}
14+
</span>
1415
</mat-panel-title>
1516
<mat-panel-description>
1617
<span class="status" [ngClass]="getStatus(entry.state).color">

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ describe('DraftHistoryEntryComponent', () => {
6767
});
6868

6969
it('should handle builds with additional info', fakeAsync(() => {
70+
when(mockedI18nService.enumerateList(anything())).thenReturn('src');
7071
const user = 'user-display-name';
7172
const date = 'formatted-date';
7273
const trainingBooks = ['EXO'];
@@ -79,6 +80,7 @@ describe('DraftHistoryEntryComponent', () => {
7980
fixture.detectChanges();
8081

8182
expect(component.scriptureRange).toEqual('Genesis');
83+
expect(component.translationSource).toEqual('src \u2022');
8284
expect(component.buildRequestedByUserName).toBe(user);
8385
expect(component.buildRequestedAtDate).toBe(date);
8486
expect(component.canDownloadBuild).toBe(true);
@@ -134,7 +136,7 @@ describe('DraftHistoryEntryComponent', () => {
134136
},
135137
additionalInfo: {
136138
trainingScriptureRanges: [{ projectId: 'project02', scriptureRange: 'EXO' }],
137-
translationScriptureRanges: [{ projectId: 'project01', scriptureRange: 'GEN' }]
139+
translationScriptureRanges: [{ projectId: 'project02', scriptureRange: 'GEN' }]
138140
}
139141
} as BuildDto;
140142

@@ -145,6 +147,7 @@ describe('DraftHistoryEntryComponent', () => {
145147
fixture.detectChanges();
146148

147149
expect(component.scriptureRange).toEqual('Genesis');
150+
expect(component.translationSource).toEqual('');
148151
expect(component.buildRequestedByUserName).toBeUndefined();
149152
expect(component.buildRequestedAtDate).toBe('');
150153
expect(component.canDownloadBuild).toBe(false);
@@ -319,7 +322,7 @@ describe('DraftHistoryEntryComponent', () => {
319322
dateRequested: new Date().toISOString(),
320323
requestedByUserId: 'sf-user-id',
321324
trainingScriptureRanges: [{ projectId: 'project02', scriptureRange: trainingBooks.join(';') }],
322-
translationScriptureRanges: [{ projectId: 'project01', scriptureRange: translateBooks.join(';') }]
325+
translationScriptureRanges: [{ projectId: 'project02', scriptureRange: translateBooks.join(';') }]
323326
}
324327
} as BuildDto;
325328

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ export class DraftHistoryEntryComponent {
116116
}
117117
});
118118

119+
// Get the translation scripture range and project (usually one, but in the future will be multiple)
120+
const translationScriptureRanges = this._entry?.additionalInfo?.translationScriptureRanges ?? [];
121+
this._scriptureRange = this.i18n.formatAndLocalizeScriptureRange(
122+
translationScriptureRanges.map(item => item.scriptureRange).join(';')
123+
);
124+
this._translationSources = [];
125+
Promise.all(
126+
translationScriptureRanges.map(async r => {
127+
const source =
128+
r.projectId === '' || r.projectId === value?.engine?.id
129+
? undefined
130+
: await this.projectService.getProfile(r.projectId);
131+
const sourceShortName = source?.data?.shortName;
132+
if (sourceShortName != null) this._translationSources.push(sourceShortName);
133+
})
134+
);
135+
119136
// Populate the exception details, if possible
120137
if (this._entry?.state === BuildStates.Faulted && this._entry.message != null) {
121138
this._buildFaulted = true;
@@ -213,6 +230,17 @@ export class DraftHistoryEntryComponent {
213230
return this._canDownloadBuild ?? false;
214231
}
215232

233+
private _scriptureRange?: string = undefined;
234+
get scriptureRange(): string {
235+
return this._scriptureRange ?? '';
236+
}
237+
238+
private _translationSources: string[] = [];
239+
get translationSource(): string {
240+
if (this._translationSources.length === 0) return '';
241+
return this.i18n.enumerateList(this._translationSources) + ' \u2022'; // &bull; •
242+
}
243+
216244
@Input() isLatestBuild = false;
217245

218246
trainingConfigurationOpen = false;
@@ -226,13 +254,6 @@ export class DraftHistoryEntryComponent {
226254
readonly featureFlags: FeatureFlagService
227255
) {}
228256

229-
get scriptureRange(): string {
230-
if (this.entry?.additionalInfo?.translationScriptureRanges == null) return '';
231-
return this.i18n.formatAndLocalizeScriptureRange(
232-
this.entry.additionalInfo.translationScriptureRanges.map(item => item.scriptureRange).join(';')
233-
);
234-
}
235-
236257
formatDate(date?: string): string {
237258
const formattedDate = date == null ? '' : this.i18n.formatDate(new Date(date));
238259
return formattedDate.indexOf(RIGHT_TO_LEFT_MARK) !== -1 ? RIGHT_TO_LEFT_MARK + formattedDate : formattedDate;

0 commit comments

Comments
 (0)