diff --git a/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.component.ts b/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.component.ts index 6d131e5176..aa2087706f 100644 --- a/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.component.ts +++ b/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.component.ts @@ -127,7 +127,7 @@ export class QuestionDialogComponent extends SubscriptionDisposable implements O this.scriptureEnd.setValue(endVerseRef.toString()); } this.updateSelection(); - } else if (this.data.defaultVerse != null) { + } else if (this.data.defaultVerse != null && this.data.defaultVerse.bookNum > 0) { const { startVerseRef, endVerseRef } = toStartAndEndVerseRefs(this.data.defaultVerse); this.scriptureStart.setValue(startVerseRef.toString()); if (endVerseRef != null) { diff --git a/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.service.spec.ts b/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.service.spec.ts index 6674c78cb4..03666e03c8 100644 --- a/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.service.spec.ts +++ b/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.service.spec.ts @@ -7,9 +7,9 @@ import { Question, QUESTIONS_COLLECTION } from 'realtime-server/lib/esm/scriptureforge/models/question'; -import { SFProject } from 'realtime-server/lib/esm/scriptureforge/models/sf-project'; +import { SFProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project'; import { SFProjectRole } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-role'; -import { createTestProject } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data'; +import { createTestProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data'; import { TextInfo } from 'realtime-server/lib/esm/scriptureforge/models/text-info'; import { fromVerseRef } from 'realtime-server/lib/esm/scriptureforge/models/verse-ref-data'; import { of } from 'rxjs'; @@ -24,7 +24,7 @@ import { configureTestingModule, TestTranslocoModule } from 'xforge-common/test- import { UICommonModule } from 'xforge-common/ui-common.module'; import { UserService } from 'xforge-common/user.service'; import { QuestionDoc } from '../../core/models/question-doc'; -import { SFProjectDoc } from '../../core/models/sf-project-doc'; +import { SFProjectProfileDoc } from '../../core/models/sf-project-profile-doc'; import { SF_TYPE_REGISTRY } from '../../core/models/sf-type-registry'; import { TextsByBookId } from '../../core/models/texts-by-book-id'; import { SFProjectService } from '../../core/sf-project.service'; @@ -167,7 +167,7 @@ class TestEnvironment { readonly service: QuestionDialogService; readonly mockedDialogRef = mock>(MatDialogRef); textsByBookId: TextsByBookId; - projectDoc: SFProjectDoc; + projectProfileDoc: SFProjectProfileDoc; matthewText: TextInfo = { bookNum: 40, hasSource: false, @@ -180,14 +180,11 @@ class TestEnvironment { readonly PROJECT01: string = 'project01'; adminUser: UserInfo = { id: 'user01', role: SFProjectRole.ParatextAdministrator }; - private testProject: SFProject = createTestProject({ + private testProjectProfile: SFProjectProfile = createTestProjectProfile({ texts: [this.matthewText], userRoles: { [this.adminUser.id]: this.adminUser.role - }, - paratextUsers: [ - { sfUserId: this.adminUser.id, username: `pt${this.adminUser.id}`, opaqueUserId: `opaque${this.adminUser.id}` } - ] + } }); private readonly realtimeService: TestRealtimeService = TestBed.inject(TestRealtimeService); @@ -195,16 +192,19 @@ class TestEnvironment { this.service = TestBed.inject(QuestionDialogService); this.textsByBookId = { ['MAT']: this.matthewText }; - this.realtimeService.addSnapshot(SFProjectDoc.COLLECTION, { + this.realtimeService.addSnapshot(SFProjectProfileDoc.COLLECTION, { id: this.PROJECT01, - data: this.testProject + data: this.testProjectProfile }); - this.projectDoc = this.realtimeService.get(SFProjectDoc.COLLECTION, this.PROJECT01); + this.projectProfileDoc = this.realtimeService.get( + SFProjectProfileDoc.COLLECTION, + this.PROJECT01 + ); when(mockedDialogService.openMatDialog(anything(), anything())).thenReturn(instance(this.mockedDialogRef)); when(mockedUserService.currentUserId).thenReturn(this.adminUser.id); - when(mockedProjectService.get(anything())).thenCall(id => - this.realtimeService.subscribe(SFProjectDoc.COLLECTION, id) + when(mockedProjectService.getProfile(anything())).thenCall(id => + this.realtimeService.subscribe(SFProjectProfileDoc.COLLECTION, id) ); } @@ -233,14 +233,22 @@ class TestEnvironment { } getQuestionDialogData(questionDoc?: QuestionDoc): QuestionDialogData { - return { questionDoc, projectDoc: this.projectDoc, textsByBookId: this.textsByBookId, projectId: this.PROJECT01 }; + return { + questionDoc, + projectDoc: this.projectProfileDoc, + textsByBookId: this.textsByBookId, + projectId: this.PROJECT01 + }; } updateUserRole(role: string): void { - const projectDoc = this.realtimeService.get(SFProjectDoc.COLLECTION, this.PROJECT01); - const userRole = projectDoc.data!.userRoles; + const projectProfileDoc = this.realtimeService.get( + SFProjectProfileDoc.COLLECTION, + this.PROJECT01 + ); + const userRole = projectProfileDoc.data!.userRoles; userRole[this.adminUser.id] = role; - projectDoc.submitJson0Op(op => { + projectProfileDoc.submitJson0Op(op => { op.set(p => p.userRoles, userRole); }, false); } diff --git a/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.service.ts b/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.service.ts index 15e116e77d..fd2f29a9d4 100644 --- a/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.service.ts +++ b/src/SIL.XForge.Scripture/ClientApp/src/app/checking/question-dialog/question-dialog.service.ts @@ -105,7 +105,7 @@ export class QuestionDialogService { private async canCreateAndEditQuestions(projectId: string): Promise { const userId = this.userService.currentUserId; - const project = (await this.projectService.get(projectId)).data; + const project = (await this.projectService.getProfile(projectId)).data; return ( project != null && SF_PROJECT_RIGHTS.hasRight(project, userId, SFProjectDomain.Questions, Operation.Create) &&