Skip to content

Commit f715240

Browse files
committed
Add draft USFM format component
1 parent 3086410 commit f715240

28 files changed

+601
-164
lines changed

src/RealtimeServer/scriptureforge/models/translate-config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ export interface ProjectScriptureRange {
4242
scriptureRange: string;
4343
}
4444

45+
export interface DraftUsfmConfig {
46+
preserveParagraphMarkers: boolean;
47+
preserveStyleMarkers: boolean;
48+
preserveEmbedMarkers: boolean;
49+
}
50+
4551
export interface DraftConfig {
4652
additionalTrainingData: boolean;
4753
additionalTrainingSourceEnabled: boolean;
@@ -58,6 +64,7 @@ export interface DraftConfig {
5864
lastSelectedTranslationScriptureRange?: string;
5965
lastSelectedTranslationScriptureRanges?: ProjectScriptureRange[];
6066
servalConfig?: string;
67+
usfmConfig?: DraftUsfmConfig;
6168
}
6269

6370
export interface TranslateConfig {

src/SIL.XForge.Scripture/ClientApp/src/app/core/models/draft-usfm-config.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/SIL.XForge.Scripture/ClientApp/src/app/core/sf-project.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { SF_PROJECT_RIGHTS, SFProjectDomain } from 'realtime-server/lib/esm/scri
1313
import { SFProjectRole } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-role';
1414
import { getSFProjectUserConfigDocId } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-user-config';
1515
import { TextAudio } from 'realtime-server/lib/esm/scriptureforge/models/text-audio';
16+
import { DraftUsfmConfig } from 'realtime-server/lib/esm/scriptureforge/models/translate-config';
1617
import { Subject } from 'rxjs';
1718
import { CommandService } from 'xforge-common/command.service';
1819
import { LocationService } from 'xforge-common/location.service';
@@ -26,7 +27,6 @@ import { EventMetric } from '../event-metrics/event-metric';
2627
import { ShareLinkType } from '../shared/share/share-dialog.component';
2728
import { InviteeStatus } from '../users/collaborators/collaborators.component';
2829
import { BiblicalTermDoc } from './models/biblical-term-doc';
29-
import { DraftUsfmConfig } from './models/draft-usfm-config';
3030
import { NoteThreadDoc } from './models/note-thread-doc';
3131
import { SFProjectCreateSettings } from './models/sf-project-create-settings';
3232
import { SFProjectDoc } from './models/sf-project-doc';

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-format-dialog/draft-format-dialog.component.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-format-dialog/draft-format-dialog.component.scss

Whitespace-only changes.

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-format-dialog/draft-format-dialog.component.spec.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-format-dialog/draft-format-dialog.component.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ <h3>{{ t("draft_finishing_header") }}</h3>
336336
<mat-icon>settings</mat-icon>
337337
{{ t("configure_sources") }}
338338
</button>
339+
<button mat-button [routerLink]="['format']">
340+
<mat-icon>settings</mat-icon>
341+
Format USFM
342+
</button>
339343
}
340344
} @else if (hasConfigureSourcePermission) {
341345
<!-- Show Configure sources button when we don't have permission to the current sources and when there is not a

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-handling.service.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ describe('DraftHandlingService', () => {
7171
when(
7272
mockedDraftGenerationService.getGeneratedDraftDeltaOperations(anything(), anything(), anything())
7373
).thenReturn(of(draftOps));
74-
service.getDraft(textDocId, { isDraftLegacy: false }).subscribe(draftData => expect(draftData).toEqual(draftOps));
74+
service
75+
.getDraft(textDocId, { isDraftLegacy: false, accessSnapshot: true })
76+
.subscribe(draftData => expect(draftData).toEqual(draftOps));
7577
verify(mockedDraftGenerationService.getGeneratedDraftDeltaOperations('project01', 1, 1)).once();
7678
verify(mockedDraftGenerationService.getGeneratedDraft('project01', 1, 1)).never();
7779
});
@@ -87,7 +89,9 @@ describe('DraftHandlingService', () => {
8789
mockedDraftGenerationService.getGeneratedDraftDeltaOperations(anything(), anything(), anything())
8890
).thenReturn(throwError(() => ({ status: 405 })));
8991
when(mockedDraftGenerationService.getGeneratedDraft(anything(), anything(), anything())).thenReturn(of(draft));
90-
service.getDraft(textDocId, { isDraftLegacy: false }).subscribe(draftData => expect(draftData).toEqual(draft));
92+
service
93+
.getDraft(textDocId, { isDraftLegacy: false, accessSnapshot: true })
94+
.subscribe(draftData => expect(draftData).toEqual(draft));
9195
verify(mockedDraftGenerationService.getGeneratedDraftDeltaOperations('project01', 1, 1)).once();
9296
verify(mockedDraftGenerationService.getGeneratedDraft('project01', 1, 1)).once();
9397
});

src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-handling.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ export class DraftHandlingService {
144144
* Gets the generated draft of a chapter for a book. If unable to get the current draft delta format,
145145
* it will automatically fallback to attempt to retrieve the legacy draft format.
146146
* @param textDocId The text document identifier.
147-
* @param param1 Whether to get the draft in the legacy format.
147+
* @param param1 Whether to get the draft in the legacy format and whether to use the snapshot
148+
* stored in the realtime database.
148149
* @returns The draft data in the current delta operation format or the legacy segment map format.
149150
*/
150151
getDraft(

0 commit comments

Comments
 (0)