Skip to content

Commit 046edff

Browse files
committed
Revert "SF-3566 Guide user to formatting options on draft tab (#3447)"
This reverts commit 0e369e2.
1 parent 47a39b3 commit 046edff

File tree

5 files changed

+39
-125
lines changed

5 files changed

+39
-125
lines changed

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

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,15 @@
4444
}
4545
<div class="apply-draft-button-container">
4646
@if (featureFlags.usfmFormat.enabled) {
47-
@if (mustChooseFormattingOptions) {
48-
<button mat-flat-button (click)="navigateToFormatting()">
47+
<span
48+
[matTooltip]="t(doesLatestHaveDraft ? 'format_draft_can' : 'format_draft_cannot')"
49+
[style.cursor]="doesLatestHaveDraft ? 'pointer' : 'not-allowed'"
50+
>
51+
<button mat-button (click)="navigateToFormatting()" [disabled]="!doesLatestHaveDraft">
4952
<mat-icon>build</mat-icon>
50-
<transloco class="hide-lt-md" key="editor_draft_tab.format_draft"></transloco>
51-
<transloco class="hide-gt-md" key="editor_draft_tab.formatting"></transloco>
53+
<transloco key="editor_draft_tab.format_draft"></transloco>
5254
</button>
53-
} @else {
54-
<span
55-
[matTooltip]="t(doesLatestHaveDraft ? 'format_draft_can' : 'format_draft_cannot')"
56-
[style.cursor]="doesLatestHaveDraft ? 'pointer' : 'not-allowed'"
57-
>
58-
<button mat-button (click)="navigateToFormatting()" [disabled]="!doesLatestHaveDraft">
59-
<mat-icon>build</mat-icon>
60-
<transloco class="hide-lt-md" key="editor_draft_tab.format_draft"></transloco>
61-
<transloco class="hide-gt-md" key="editor_draft_tab.formatting"></transloco>
62-
</button>
63-
</span>
64-
}
55+
</span>
6556
}
6657
@if (userAppliedDraft) {
6758
<span class="draft-indicator">
@@ -70,26 +61,21 @@
7061
</span>
7162
}
7263
@if (canApplyDraft) {
73-
<span
74-
[matTooltip]="t(mustChooseFormattingOptions ? 'format_draft_before' : 'add_chapter_to_project')"
75-
[style.cursor]="mustChooseFormattingOptions ? 'not-allowed' : 'pointer'"
76-
>
77-
<button mat-flat-button color="primary" (click)="applyDraft()" [disabled]="mustChooseFormattingOptions">
78-
<mat-icon>auto_awesome</mat-icon>
79-
@if (isDraftApplied) {
80-
<transloco key="editor_draft_tab.reapply_to_project"></transloco>
81-
} @else {
82-
<transloco key="editor_draft_tab.apply_to_project"></transloco>
83-
}
84-
</button>
85-
</span>
64+
<button mat-flat-button color="primary" (click)="applyDraft()">
65+
<mat-icon>auto_awesome</mat-icon>
66+
@if (isDraftApplied) {
67+
<transloco key="editor_draft_tab.reapply_to_project"></transloco>
68+
} @else {
69+
<transloco key="editor_draft_tab.apply_to_project"></transloco>
70+
}
71+
</button>
72+
}
73+
@if (!canApplyDraft) {
74+
<app-notice icon="warning" type="warning" mode="fill-dark">
75+
{{ "editor_draft_tab.cannot_import" | transloco }}
76+
</app-notice>
8677
}
8778
</div>
88-
@if (!canApplyDraft) {
89-
<app-notice icon="warning" type="warning" mode="fill-dark">
90-
{{ "editor_draft_tab.cannot_import" | transloco }}
91-
</app-notice>
92-
}
9379
</div>
9480
}
9581
} @else {

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor-draft/editor-draft.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ app-notice {
3131
flex-grow: 1;
3232
display: flex;
3333
justify-content: flex-end;
34-
gap: 4px;
34+
column-gap: 4px;
3535
align-items: center;
3636
flex-wrap: wrap;
3737
}

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor-draft/editor-draft.component.spec.ts

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
77
import { cloneDeep } from 'lodash-es';
88
import { TranslocoMarkupModule } from 'ngx-transloco-markup';
99
import { Delta } from 'quill';
10-
import { SFProjectRole } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-role';
1110
import { createTestProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data';
12-
import { ParagraphBreakFormat, QuoteFormat } from 'realtime-server/lib/esm/scriptureforge/models/translate-config';
1311
import { BehaviorSubject, of } from 'rxjs';
1412
import { anything, mock, verify, when } from 'ts-mockito';
1513
import { ActivatedProjectService } from 'xforge-common/activated-project.service';
@@ -393,67 +391,6 @@ describe('EditorDraftComponent', () => {
393391
}));
394392

395393
describe('applyDraft', () => {
396-
it('should allow user to apply draft when formatting selected', fakeAsync(() => {
397-
const testProjectDoc: SFProjectProfileDoc = {
398-
data: createTestProjectProfile({
399-
texts: [
400-
{
401-
bookNum: 1,
402-
chapters: [{ number: 1, permissions: { user01: SFProjectRole.ParatextAdministrator }, hasDraft: true }]
403-
}
404-
],
405-
translateConfig: {
406-
draftConfig: {
407-
usfmConfig: { paragraphFormat: ParagraphBreakFormat.BestGuess, quoteFormat: QuoteFormat.Denormalized }
408-
}
409-
}
410-
})
411-
} as SFProjectProfileDoc;
412-
when(mockDraftGenerationService.draftExists(anything(), anything(), anything())).thenReturn(of(true));
413-
when(mockDraftGenerationService.getGeneratedDraftHistory(anything(), anything(), anything())).thenReturn(
414-
of(draftHistory)
415-
);
416-
when(mockActivatedProjectService.changes$).thenReturn(of(testProjectDoc));
417-
when(mockDialogService.confirm(anything(), anything())).thenResolve(true);
418-
spyOn<any>(component, 'getTargetOps').and.returnValue(of(targetDelta.ops));
419-
when(mockDraftHandlingService.getDraft(anything(), anything())).thenReturn(of(draftDelta.ops!));
420-
when(mockDraftHandlingService.draftDataToOps(anything(), anything())).thenReturn(draftDelta.ops!);
421-
422-
fixture.detectChanges();
423-
tick(EDITOR_READY_TIMEOUT);
424-
425-
expect(component.mustChooseFormattingOptions).toBe(false);
426-
flush();
427-
}));
428-
429-
it('should guide user to select formatting options when formatting not selected', fakeAsync(() => {
430-
const testProjectDoc: SFProjectProfileDoc = {
431-
data: createTestProjectProfile({
432-
texts: [
433-
{
434-
bookNum: 1,
435-
chapters: [{ number: 1, permissions: { user01: SFProjectRole.ParatextAdministrator }, hasDraft: true }]
436-
}
437-
]
438-
})
439-
} as SFProjectProfileDoc;
440-
when(mockDraftGenerationService.draftExists(anything(), anything(), anything())).thenReturn(of(true));
441-
when(mockDraftGenerationService.getGeneratedDraftHistory(anything(), anything(), anything())).thenReturn(
442-
of(draftHistory)
443-
);
444-
when(mockActivatedProjectService.changes$).thenReturn(of(testProjectDoc));
445-
when(mockDialogService.confirm(anything(), anything())).thenResolve(true);
446-
spyOn<any>(component, 'getTargetOps').and.returnValue(of(targetDelta.ops));
447-
when(mockDraftHandlingService.getDraft(anything(), anything())).thenReturn(of(draftDelta.ops!));
448-
when(mockDraftHandlingService.draftDataToOps(anything(), anything())).thenReturn(draftDelta.ops!);
449-
450-
fixture.detectChanges();
451-
tick(EDITOR_READY_TIMEOUT);
452-
453-
expect(component.mustChooseFormattingOptions).toBe(true);
454-
flush();
455-
}));
456-
457394
it('should show a prompt when applying if the target has content', fakeAsync(() => {
458395
const testProjectDoc: SFProjectProfileDoc = {
459396
data: createTestProjectProfile()

src/SIL.XForge.Scripture/ClientApp/src/app/translate/editor/editor-draft/editor-draft.component.ts

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
6868
isDraftReady = false;
6969
isDraftApplied = false;
7070
userAppliedDraft = false;
71-
hasFormattingSelected = true;
7271

7372
private selectedRevisionSubject = new BehaviorSubject<Revision | undefined>(undefined);
7473
private selectedRevision$ = this.selectedRevisionSubject.asObservable();
@@ -101,28 +100,6 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
101100
private readonly router: Router
102101
) {}
103102

104-
get bookId(): string {
105-
return this.bookNum !== undefined ? Canon.bookNumberToId(this.bookNum) : '';
106-
}
107-
108-
get canApplyDraft(): boolean {
109-
if (this.targetProject == null || this.bookNum == null || this.chapter == null || this.draftDelta?.ops == null) {
110-
return false;
111-
}
112-
return this.draftHandlingService.canApplyDraft(this.targetProject, this.bookNum, this.chapter, this.draftDelta.ops);
113-
}
114-
115-
get doesLatestHaveDraft(): boolean {
116-
return (
117-
this.targetProject?.texts.find(t => t.bookNum === this.bookNum)?.chapters.find(c => c.number === this.chapter)
118-
?.hasDraft ?? false
119-
);
120-
}
121-
122-
get mustChooseFormattingOptions(): boolean {
123-
return this.featureFlags.usfmFormat.enabled && !this.hasFormattingSelected && this.doesLatestHaveDraft;
124-
}
125-
126103
ngOnChanges(): void {
127104
if (this.projectId == null || this.bookNum == null || this.chapter == null) {
128105
throw new Error('projectId, bookNum, or chapter is null');
@@ -142,6 +119,10 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
142119
this.selectedRevisionSubject.next(this.selectedRevision);
143120
}
144121

122+
get bookId(): string {
123+
return this.bookNum !== undefined ? Canon.bookNumberToId(this.bookNum) : '';
124+
}
125+
145126
populateDraftTextInit(): void {
146127
combineLatest([
147128
this.onlineStatusService.onlineStatus$,
@@ -199,7 +180,6 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
199180
filterNullish(),
200181
tap(projectDoc => {
201182
this.targetProject = projectDoc.data;
202-
this.hasFormattingSelected = projectDoc.data?.translateConfig.draftConfig.usfmConfig != null;
203183
}),
204184
distinctUntilChanged(),
205185
map(() => initialTimestamp)
@@ -260,6 +240,20 @@ export class EditorDraftComponent implements AfterViewInit, OnChanges {
260240
});
261241
}
262242

243+
get canApplyDraft(): boolean {
244+
if (this.targetProject == null || this.bookNum == null || this.chapter == null || this.draftDelta?.ops == null) {
245+
return false;
246+
}
247+
return this.draftHandlingService.canApplyDraft(this.targetProject, this.bookNum, this.chapter, this.draftDelta.ops);
248+
}
249+
250+
get doesLatestHaveDraft(): boolean {
251+
return (
252+
this.targetProject?.texts.find(t => t.bookNum === this.bookNum)?.chapters.find(c => c.number === this.chapter)
253+
?.hasDraft ?? false
254+
);
255+
}
256+
263257
navigateToFormatting(): void {
264258
this.router.navigateByUrl(`/projects/${this.projectId}/draft-generation/format/${this.bookId}/${this.chapter}`);
265259
}

src/SIL.XForge.Scripture/ClientApp/src/assets/i18n/non_checking_en.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,13 @@
403403
"your_comment": "Your comment"
404404
},
405405
"editor_draft_tab": {
406-
"add_chapter_to_project": "Add this chapter to the project",
407406
"apply_to_project": "Add to project",
408407
"cannot_import": "You cannot import this draft because you do not have permission to edit this chapter. Permissions can be updated in Paratext.",
409408
"click_book_to_preview": "Click a book below to preview the draft and add it to your project.",
410409
"draft_indicator_applied": "Added",
411410
"draft_legacy_warning": "We have updated our drafting functionality. You can take advantage of this by [link:generateDraftUrl]generating a new draft[/link].",
412411
"error_applying_draft": "Failed to add the draft to the project. Try again later.",
413-
"formatting": "Formatting",
414412
"format_draft": "Formatting options",
415-
"format_draft_before": "Select formatting options before adding it to your project.",
416413
"format_draft_can": "Customize formatting options for the draft",
417414
"format_draft_cannot": "You can only change formatting for books from the latest draft",
418415
"no_draft_notice": "{{ bookChapterName }} has no draft.",

0 commit comments

Comments
 (0)