Skip to content
Open
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 @@ -58,7 +58,7 @@ <h1>{{ t("formatting_options") }}</h1>
</form>

<div class="actions">
<button mat-button class="back" (click)="close()"><mat-icon>close</mat-icon>{{ t("cancel") }}</button>
<button mat-button class="back" (click)="cancelClicked()"><mat-icon>close</mat-icon>{{ t("cancel") }}</button>
<div class="save-container">
<div class="progress" [class.saving]="saving">
<mat-spinner diameter="24"></mat-spinner>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('DraftUsfmFormatComponent', () => {
const env = new TestEnvironment({ quotationAnalysis: QuotationAnalysis.Successful });
expect(env.component.paragraphFormat.value).toBe(ParagraphBreakFormat.BestGuess);
expect(env.component.quoteFormat.value).toBe(QuoteFormat.Denormalized);
expect(await env.component.confirmLeave()).toBe(true);
expect(await env.component['confirmLeave']()).toBe(true);
expect(env.quoteFormatWarning).toBeNull();
}));

Expand Down Expand Up @@ -158,7 +158,7 @@ describe('DraftUsfmFormatComponent', () => {
tick();
env.fixture.detectChanges();
// user will be prompted that there are unsaved changes
expect(await env.component.confirmLeave()).toBe(true);
expect(await env.component['confirmLeave']()).toBe(true);
verify(mockedProjectService.onlineSetUsfmConfig(env.projectId, anything())).never();
verify(mockedLocation.back()).once();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { TextDocId } from '../../../core/models/text-doc';
import { SFProjectService } from '../../../core/sf-project.service';
import { QuotationAnalysis } from '../../../machine-api/quotation-denormalization';
import { ServalAdministrationService } from '../../../serval-administration/serval-administration.service';
import { ConfirmOnLeave } from '../../../shared/project-router.guard';
import { SharedModule } from '../../../shared/shared.module';
import { TextComponent } from '../../../shared/text/text.component';
import { DraftGenerationService } from '../draft-generation.service';
Expand All @@ -57,7 +56,7 @@ import { DraftHandlingService } from '../draft-handling.service';
templateUrl: './draft-usfm-format.component.html',
styleUrl: './draft-usfm-format.component.scss'
})
export class DraftUsfmFormatComponent extends DataLoadingComponent implements AfterViewInit, ConfirmOnLeave {
export class DraftUsfmFormatComponent extends DataLoadingComponent implements AfterViewInit {
@ViewChild(TextComponent) draftText!: TextComponent;
bookNum: number = 1;
booksWithDrafts: number[] = [];
Expand Down Expand Up @@ -197,6 +196,11 @@ export class DraftUsfmFormatComponent extends DataLoadingComponent implements Af
this.reloadText();
}

async cancelClicked(): Promise<void> {
if (!(await this.confirmLeave())) return;
this.close();
}

close(): void {
this.location.back();
}
Expand Down Expand Up @@ -224,7 +228,7 @@ export class DraftUsfmFormatComponent extends DataLoadingComponent implements Af
}
}

async confirmLeave(): Promise<boolean> {
private async confirmLeave(): Promise<boolean> {
if (
this.lastSavedState?.paragraphFormat === this.currentFormat?.paragraphFormat &&
this.lastSavedState?.quoteFormat === this.currentFormat?.quoteFormat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ const routes: Routes = [
{
path: 'projects/:projectId/draft-generation/format',
component: DraftUsfmFormatComponent,
canActivate: [NmtDraftAuthGuard],
canDeactivate: [DraftNavigationAuthGuard]
canActivate: [NmtDraftAuthGuard]
},
{
path: 'projects/:projectId/draft-generation/format/:bookId',
Expand Down
Loading