Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF-3007 Add audio comments #2815

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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
2 changes: 0 additions & 2 deletions src/RealtimeServer/scriptureforge/models/answer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export interface Answer extends Comment {
scriptureText?: string;
selectionStartClipped?: boolean;
selectionEndClipped?: boolean;
audioUrl?: string;
text?: string;
likes: Like[];
comments: Comment[];
status?: AnswerStatus;
Expand Down
1 change: 1 addition & 0 deletions src/RealtimeServer/scriptureforge/models/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface Comment extends OwnedData {
deleted: boolean;
syncUserRef?: string;
text?: string;
audioUrl?: string;
dateModified: string;
dateCreated: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ANY_INDEX } from '../../common/utils/obj-path';
import { createFetchQuery, docSubmitJson0Op } from '../../common/utils/sharedb-utils';
import { Answer } from '../models/answer';
import { Comment } from '../models/comment';
import { Question, QUESTIONS_COLLECTION, QUESTION_INDEX_PATHS } from '../models/question';
import { QUESTIONS_COLLECTION, QUESTION_INDEX_PATHS, Question } from '../models/question';
import { SFProjectDomain } from '../models/sf-project-rights';
import { SFProjectUserConfig, SF_PROJECT_USER_CONFIGS_COLLECTION } from '../models/sf-project-user-config';
import { QUESTION_MIGRATIONS } from './question-migrations';
Expand Down Expand Up @@ -100,7 +100,10 @@ export class QuestionService extends SFProjectDataService<Question> {
bsonType: 'string'
},
text: {
bsonType: ['null', 'string']
bsonType: 'string'
},
audioUrl: {
bsonType: 'string'
},
dateModified: {
bsonType: 'string'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ChapterAudioDialogComponent } from './chapter-audio-dialog/chapter-audi
import { CheckingOverviewComponent } from './checking-overview/checking-overview.component';
import { CheckingRoutingModule } from './checking-routing.module';
import { CheckingAnswersComponent } from './checking/checking-answers/checking-answers.component';
import { CheckingCommentFormComponent } from './checking/checking-answers/checking-comments/checking-comment-form/checking-comment-form.component';
import { CheckingCommentFormComponent } from './checking/checking-answers/checking-comment-form/checking-comment-form.component';
import { CheckingCommentsComponent } from './checking/checking-answers/checking-comments/checking-comments.component';
import { CheckingAudioPlayerComponent } from './checking/checking-audio-player/checking-audio-player.component';
import { CheckingAudioRecorderComponent } from './checking/checking-audio-recorder/checking-audio-recorder.component';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { VerseRef } from '@sillsdev/scripture';
import { AudioTiming } from 'realtime-server/lib/esm/scriptureforge/models/audio-timing';
import { Question } from 'realtime-server/lib/esm/scriptureforge/models/question';
import { SFProjectUserConfig } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-user-config';
import { VerseRefData } from 'realtime-server/lib/esm/scriptureforge/models/verse-ref-data';
import { VerseRefData, toVerseRef } from 'realtime-server/lib/esm/scriptureforge/models/verse-ref-data';
import { I18nService } from 'xforge-common/i18n.service';

/**
* Detects if a string is in a format that can be used to parse audio timing for a verse of Scripture.
Expand Down Expand Up @@ -112,4 +114,12 @@
let iteration: number = timingData.filter(t => t.to <= currentAudioTiming.to && t.textRef === ref).length;
return { label: match[1], iteration };
}

static scriptureTextVerseRef(verse: VerseRef | VerseRefData | undefined, i18n: I18nService): string {
if (verse == null) {
return '';

Check warning on line 120 in src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking.utils.ts

View check run for this annotation

Codecov / codecov/patch

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking.utils.ts#L120

Added line #L120 was not covered by tests
}
const verseRef = verse instanceof VerseRef ? verse : toVerseRef(verse);
return `${i18n.localizeReference(verseRef)}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,71 +48,16 @@
}
</div>
} @else {
<div>
<form autocomplete="off" id="answer-form" appScrollIntoView>
<app-text-and-audio
#answer
appAutofocus
[input]="activeAnswer"
[textLabel]="t('your_answer')"
></app-text-and-audio>
<div class="bottom-row">
<div class="attachments">
<app-attach-audio [textAndAudio]="answer"></app-attach-audio>
@if (!selectedText) {
<button
mat-icon-button
id="select-scripture"
(click)="selectScripture()"
[matTooltip]="t('tooltip_attach')"
>
<mat-icon class="attach-icon">attach_file</mat-icon>
</button>
} @else {
<div class="answer-scripture">
<span class="answer-scripture-verse">{{ scriptureTextVerseRef(verseRef) }}</span>
<button mat-icon-button (click)="clearSelection()" class="answer-scripture-clear">
<mat-icon>clear</mat-icon>
</button>
</div>
}
</div>
@if (isScreenSmall) {
<div>
<button mat-icon-button type="button" (click)="hideAnswerForm()" id="cancel-answer">
<mat-icon class="material-icons-outlined">cancel</mat-icon>
</button>
<button
mat-icon-button
color="primary"
id="save-answer"
(click)="submit()"
[disabled]="submittingAnswer"
>
<mat-icon>check_circle</mat-icon>
</button>
</div>
}
@if (!isScreenSmall) {
<div class="large-form-action-buttons">
<button mat-button type="button" (click)="hideAnswerForm()" id="cancel-answer">
<mat-icon>close</mat-icon>
{{ t("cancel") }}
</button>
<button
mat-flat-button
color="primary"
id="save-answer"
(click)="submit()"
[disabled]="submittingAnswer"
>
<mat-icon>check</mat-icon>
{{ t("save_answer") }}
</button>
</div>
}
</div>
</form>
<div id="answer-form">
<app-checking-comment-form
[answer]="this.activeAnswer"
[project]="project"
[questionDoc]="questionDoc"
[textsByBookId]="textsByBookId"
[textSelectionEnabled]="true"
(cancel)="hideAnswerForm()"
(save)="submit($event)"
></app-checking-comment-form>
</div>
}
@if (shouldShowAnswers) {
Expand Down Expand Up @@ -159,12 +104,6 @@ <h3 id="totalAnswersMessage">
<app-checking-audio-player [source]="getFileSource(answer.audioUrl)"> </app-checking-audio-player>
}
<div class="answer-footer">
<app-owner
[ownerRef]="answer.ownerRef"
[includeAvatar]="true"
[layoutStacked]="true"
[dateTime]="answer.dateCreated"
></app-owner>
<div class="actions">
@if (canChangeAnswerStatus(answer)) {
<button
Expand All @@ -190,25 +129,42 @@ <h3 id="totalAnswersMessage">
{{ t(isAnswerResolved(answer) ? "resolved" : "resolve") }}
</button>
}
@if (canEditAnswer(answer)) {
<button mat-button type="button" (click)="editAnswer(answer)" class="answer-edit short-button">
{{ t("edit") }}
</button>
}
@if (canDeleteAnswer(answer)) {
<div class="delete-divider">|</div>
<button
mat-button
type="button"
(click)="deleteAnswerClicked(answer)"
class="answer-delete short-button"
>
{{ t("delete") }}
</button>
}
</div>
<div class="bottom-row">
<div>
@if (canEditAnswer(answer)) {
<button
mat-icon-button
type="button"
(click)="editAnswer(answer)"
class="answer-edit short-button"
[matTooltip]="t('edit')"
>
<mat-icon>edit</mat-icon>
</button>
}
@if (canDeleteAnswer(answer)) {
<button
mat-icon-button
type="button"
(click)="deleteAnswerClicked(answer)"
class="answer-delete short-button"
[matTooltip]="t('delete')"
>
<mat-icon>delete</mat-icon>
</button>
}
</div>
<app-owner
[ownerRef]="answer.ownerRef"
[includeAvatar]="true"
[layoutStacked]="true"
[dateTime]="answer.dateCreated"
></app-owner>
</div>
</div>
<app-checking-comments
id="answer-comments"
[project]="project"
[projectUserConfigDoc]="projectUserConfigDoc"
[questionDoc]="questionDoc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,6 @@
}
}

#answer-form {
display: flex;
flex-direction: column;
row-gap: 2px;
.attach-icon {
rotate: 45deg;
}
.bottom-row {
display: flex;
justify-content: space-between;
}
.attachments {
display: flex;
flex-direction: row;
.clear,
.answer-scripture-clear {
padding: 6px;
}
}
.large-form-action-buttons {
display: flex;
align-items: center;
column-gap: 8px;
}
}

.answers-container {
.answer {
display: flex;
Expand Down Expand Up @@ -102,12 +76,6 @@
flex: 1;
align-items: flex-end;

@include breakpoints.media-breakpoint-down(sm) {
align-items: flex-start;
flex-direction: column;
row-gap: 5px;
}

button {
&.answer-status {
&.status-exportable {
Expand Down Expand Up @@ -154,8 +122,14 @@
row-gap: 10px;
border-bottom: 1px solid checking-vars.$borderColor;
padding: 10px 0;
app-owner {
align-self: flex-end;

.bottom-row {
display: flex;
justify-content: space-between;

button {
height: 40px;
}
}
}
}
Expand All @@ -175,7 +149,6 @@
padding-block: 6px;
}

.answer-scripture-clear,
.clear {
width: 36px;
height: 36px;
Expand Down
Loading
Loading