Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ <h1>{{ t("select_project") }}</h1>
<h1>{{ t("connect_to_project") }}</h1>

@if (selectedParatextProject != null) {
<p
[innerHtml]="
i18n.translateAndInsertTags('draft_import_wizard.connect_project_description', {
projectShortName: selectedParatextProject.shortName,
projectName: selectedParatextProject.name
})
"
></p>
<transloco
key="draft_import_wizard.connect_project_description"
[params]="{
projectShortName: selectedParatextProject.shortName,
projectName: selectedParatextProject.name
}"
></transloco>
}

@if (connectionError != null && connectionError.length > 0) {
Expand Down Expand Up @@ -233,32 +232,50 @@ <h1>{{ t("confirm_books_to_import") }}</h1>
@if (booksWithExistingText.length === 1) {
<!-- Single book variant -->
<h1>{{ t("overwrite_book_question", { bookName: singleBookName }) }}</h1>
<p
[innerHTML]="
i18n.translateAndInsertTags('draft_import_wizard.overwrite_book_description', {
bookName: singleBookName,
numChapters: booksWithExistingText[0].chaptersWithText.length,
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
})
"
></p>
<transloco
key="draft_import_wizard.overwrite_book_description"
[params]="{
bookName: singleBookName,
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
}"
></transloco>
<p class="chapter-list">
@for (chapterNum of booksWithExistingText[0].chapterNumbersWithText; track chapterNum) {
<transloco
key="draft_import_wizard.overwrite_chapter_link"
[params]="{
chapterNum: chapterNum,
chapterLink: bookChapterLink(booksWithExistingText[0].bookNum, chapterNum)
}"
></transloco>
}
</p>
} @else {
<!-- Multiple books variant -->
<h1>{{ t("overwrite_books_question") }}</h1>
<p
[innerHTML]="
i18n.translateAndInsertTags('draft_import_wizard.overwrite_books_description', {
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
})
"
></p>
<transloco
key="draft_import_wizard.overwrite_books_description"
[params]="{
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
}"
></transloco>
<ul>
@for (book of booksWithExistingText; track book.bookNum) {
<li>
{{ book.bookName }}: {{ book.chaptersWithText.length }}
{{ book.chaptersWithText.length === 1 ? t("chapter") : t("chapters") }}
{{ book.bookName }}:
<span class="chapter-list">
@for (chapterNum of book.chapterNumbersWithText; track chapterNum) {
<transloco
key="draft_import_wizard.overwrite_chapter_link"
[params]="{
chapterNum: chapterNum,
chapterLink: bookChapterLink(book.bookNum, chapterNum)
}"
></transloco>
}
</span>
</li>
}
</ul>
Expand Down Expand Up @@ -353,14 +370,13 @@ <h1>{{ t("importing_draft") }}</h1>

@if (!isSyncing && !syncComplete && !skipSync && syncError == null) {
<h1>{{ t("sync_project_question") }}</h1>
<p
[innerHtml]="
i18n.translateAndInsertTags('draft_import_wizard.sync_project_description', {
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
})
"
></p>
<transloco
key="draft_import_wizard.sync_project_description"
[params]="{
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
}"
></transloco>

<div class="button-strip">
<button
Expand Down Expand Up @@ -408,23 +424,21 @@ <h1>{{ t("sync_failed") }}</h1>
@if (syncComplete || skipSync) {
<h1>{{ t("complete") }}</h1>
@if (skipSync) {
<p
[innerHtml]="
i18n.translateAndInsertTags('draft_import_wizard.import_complete_no_sync', {
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
})
"
></p>
<transloco
key="draft_import_wizard.import_complete_no_sync"
[params]="{
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
}"
></transloco>
} @else {
<p
[innerHtml]="
i18n.translateAndInsertTags('draft_import_wizard.import_and_sync_complete', {
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
})
"
></p>
<transloco
key="draft_import_wizard.import_and_sync_complete"
[params]="{
projectShortName: selectedParatextProject?.shortName,
projectName: selectedParatextProject?.name
}"
></transloco>
<p>
<b>{{ t("import_and_sync_complete_reminder") }}</b>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
}
}

.chapter-list {
display: flex;
column-gap: 0.4rem;
flex-wrap: wrap;
}

h1 {
margin-bottom: 1rem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ describe('DraftImportWizardComponent', () => {

// Step 5
env.clickOverwriteCheckbox();
expect(env.component.booksWithExistingText.length).toEqual(4);
// 3 books have one chapter with text, book 4 has 2 chapters with text
expect(env.component.booksWithExistingText.flatMap(b => b.chapterNumbersWithText)).toEqual([1, 1, 1, 1, 2]);
env.clickNextButton(5);

// Step 6
Expand Down Expand Up @@ -295,7 +298,7 @@ class TestEnvironment {
{ bookNum: 1, chapters: [{ number: 1 }] },
{ bookNum: 2, chapters: [{ number: 1 }] },
{ bookNum: 3, chapters: [{ number: 1 }] },
{ bookNum: 4, chapters: [{ number: 1 }] }
{ bookNum: 4, chapters: [{ number: 1 }, { number: 2 }] }
]
},
4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import {
} from '@angular/material/stepper';
import { TranslocoModule } from '@ngneat/transloco';
import { Canon } from '@sillsdev/scripture';
import { TranslocoMarkupComponent } from 'ngx-transloco-markup';
import { BehaviorSubject, filter } from 'rxjs';
import { ActivatedProjectService } from 'xforge-common/activated-project.service';
import { AuthService } from 'xforge-common/auth.service';
import { CommandError, CommandErrorCode } from 'xforge-common/command.service';
import { I18nService } from 'xforge-common/i18n.service';
import { LocationService } from 'xforge-common/location.service';
import { OnlineStatusService } from 'xforge-common/online-status.service';
import { UserService } from 'xforge-common/user.service';
import { quietTakeUntilDestroyed } from 'xforge-common/util/rxjs-util';
Expand Down Expand Up @@ -59,7 +61,7 @@ export interface BookForImport {
export interface BookWithExistingText {
bookNum: number;
bookName: string;
chaptersWithText: number[];
chapterNumbersWithText: number[];
}

/**
Expand Down Expand Up @@ -113,6 +115,7 @@ export enum DraftApplyStatus {
MatStepperNext,
MatStepperPrevious,
TranslocoModule,
TranslocoMarkupComponent,
NoticeComponent,
ProjectSelectComponent,
BookMultiSelectComponent,
Expand Down Expand Up @@ -304,6 +307,7 @@ export class DraftImportWizardComponent implements OnInit {
private readonly projectService: SFProjectService,
private readonly textDocService: TextDocService,
readonly i18n: I18nService,
private readonly locationService: LocationService,
private readonly onlineStatusService: OnlineStatusService,
private readonly activatedProjectService: ActivatedProjectService,
private readonly authService: AuthService,
Expand Down Expand Up @@ -366,6 +370,10 @@ export class DraftImportWizardComponent implements OnInit {
});
}

bookChapterLink(bookNum: number, chapterNum: number): string {
return `${this.locationService.origin}/projects/${this.targetProjectId}/translate/${Canon.bookNumberToId(bookNum)}/${chapterNum}`;
}

private async loadProjects(): Promise<void> {
try {
const allProjects = await this.paratextService.getProjects();
Expand Down Expand Up @@ -555,15 +563,15 @@ export class DraftImportWizardComponent implements OnInit {
if (this.targetProjectId == null) return;

this.booksWithExistingText = [];
const booksToCheck = this.booksToImport;
const booksToCheck: BookForImport[] = this.booksToImport;

for (const book of booksToCheck) {
const chaptersWithText = await this.getChaptersWithText(book.bookNum);
if (chaptersWithText.length > 0) {
const chapterNumbersWithText: number[] = await this.getChaptersWithText(book.bookNum);
if (chapterNumbersWithText.length > 0) {
this.booksWithExistingText.push({
bookNum: book.bookNum,
bookName: book.bookName,
chaptersWithText
chapterNumbersWithText
});
}
}
Expand All @@ -583,7 +591,7 @@ export class DraftImportWizardComponent implements OnInit {
const chaptersWithText: number[] = [];
for (const chapter of targetBook.chapters) {
const textDocId = new TextDocId(this.targetProjectId, bookNum, chapter.number);
const hasText = await this.hasTextInChapter(textDocId);
const hasText: boolean = await this.hasTextInChapter(textDocId);
if (hasText) {
chaptersWithText.push(chapter.number);
}
Expand Down Expand Up @@ -621,7 +629,8 @@ export class DraftImportWizardComponent implements OnInit {
bookNum: book.bookNum,
bookId: book.bookId,
bookName: book.bookName,
totalChapters: this.booksWithExistingText.find(b => b.bookNum === book.bookNum)?.chaptersWithText.length ?? 0,
totalChapters:
this.booksWithExistingText.find(b => b.bookNum === book.bookNum)?.chapterNumbersWithText.length ?? 0,
completedChapters: [],
failedChapters: []
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function getBookWithExistingText(bookNum: number, numberOfChaptersWithText: numb
return {
bookNum: bookNum,
bookName: Canon.bookNumberToEnglishName(bookNum),
chaptersWithText: new Array(numberOfChaptersWithText).fill(null).map((_, i) => i + 1)
chapterNumbersWithText: new Array(numberOfChaptersWithText).fill(null).map((_, i) => i + 1)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
"confirm_books_to_import": "Confirm books to import",
"confirm_books_to_import_description": "The following books will be imported. You may click a book to deselect and not import it.",
"confirm_overwrite": "Confirm overwrite",
"connect_project_description": "The selected project {{ boldStart }}{{ projectShortName }} - {{ projectName }}{{ boldEnd }} has not yet been connected in Scripture Forge. Do you want to connect it so you can import the draft to it?",
"connect_project_description": "The selected project [b]{{ projectShortName }} - {{ projectName }}[/b] has not yet been connected in Scripture Forge. Do you want to connect it so you can import the draft to it?",
"connect_project": "Connect project",
"connect_to_project": "Connect to project",
"connect_to_the_internet": "Connect to the internet to import drafts",
Expand All @@ -341,19 +341,20 @@
"i_understand_overwrite_content": "I understand that existing content will be overwritten",
"import": "Import",
"import_all_chapters_failed": "Failed to import {{ failed }} chapter(s). See details above.",
"import_and_sync_complete": "The draft has been imported into {{ boldStart }}{{ projectShortName }} - {{ projectName }}{{ boldEnd }} and synced with Paratext.",
"import_and_sync_complete": "The draft has been imported into [b]{{ projectShortName }} - {{ projectName }}[/b] and synced with Paratext.",
"import_and_sync_complete_reminder": "Please remember to do a Send/Receive in Paratext to see the draft.",
"import_complete_no_sync": "Make sure to sync {{ boldStart }}{{ projectShortName }} - {{ projectName }}{{ boldEnd }} in Scripture Forge, then do a Send/Receive in Paratext to make the draft available in Paratext.",
"import_complete_no_sync": "Make sure to sync [b]{{ projectShortName }} - {{ projectName }}[/b] in Scripture Forge, then do a Send/Receive in Paratext to make the draft available in Paratext.",
"import_complete": "Import complete",
"import_some_chapters_failed": "Imported {{ successful }} chapter(s) successfully. Failed to import {{ failed }} chapter(s). See details above.",
"importing_draft": "Importing draft",
"importing": "Importing",
"next": "Next",
"no_books_ready_for_import": "No draft chapters are ready for import. Generate a draft and try again.",
"overwrite_book_description": "{{ bookName }} in {{ boldStart }}{{ projectShortName }} - {{ projectName }}{{ boldEnd }} has {{ numChapters }} chapters with existing text that will be overwritten.",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that we've lost a significant amount of clarity by going from specifically stating that there are chapters with existing text that will be overwritten to just saying "Overwrite ?" I know technically we're overwriting the entire book, but from a user's perspective they're doing an import, probably not expecting to overwrite anything. We should be extremely clear in why we are stopping to ask an additional question.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the user's perspective they are importing a book and this message should appear if there is content that will get overwritten. I have updated the message to be clear that the reason they see the message is because one or more chapters have existing content that will be overwritten. Let me know if this needs further refinement.

"overwrite_book_description": "One or more chapters have existing content that will be overwritten in {{ bookName }} in [b]{{ projectShortName }} - {{ projectName }}[/b]. Chapters with existing content are listed below. Click each chapter to view the content.",
"overwrite_book_question": "Overwrite {{ bookName }}?",
"overwrite_books_description": "The following books in {{ boldStart }}{{ projectShortName }} - {{ projectName }}{{ boldEnd }} have chapters with existing text that will be overwritten:",
"overwrite_books_description": "One or more chapters have existing content that will be overwritten in [b]{{ projectShortName }} - {{ projectName }}[/b]. Chapters with existing content are listed below. Click each chapter to view the content.",
"overwrite_books_question": "Overwrite books?",
"overwrite_chapter_link": "[link:chapterLink]Chapter\u00A0{{ chapterNum }}[/link]",
"please_select_valid_project": "Please select a valid project",
"project_context_unavailable": "Project context unavailable. Please close the dialog and try again.",
"project_deleted": "This project has been deleted. Please contact your project administrator.",
Expand All @@ -364,7 +365,7 @@
"select_project": "Select project",
"select_project_description": "Please select the project you want to add the draft to.",
"skip_sync": "Skip sync",
"sync_project_description": "It is recommended to sync {{ boldStart }}{{ projectShortName }} - {{ projectName }}{{ boldEnd }} to save your changes to Paratext.",
"sync_project_description": "It is recommended to sync [b]{{ projectShortName }} - {{ projectName }}[/b] to save your changes to Paratext.",
"sync_project_question": "Sync project now?",
"sync": "Sync",
"sync_failed": "Sync failed",
Expand Down
Loading