Skip to content

Commit d8952e5

Browse files
committed
fix: corrected file element that loses the filename of the uploaded file
1 parent 3cfebdb commit d8952e5

9 files changed

Lines changed: 274 additions & 211 deletions

File tree

packages/studio-web/src/app/studio/studio.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { UploadComponent } from "../upload/upload.component";
4747
import { StepperSelectionEvent } from "@angular/cdk/stepper";
4848
import { HttpErrorResponse } from "@angular/common/http";
4949
import { DownloadService } from "../shared/download/download.service";
50-
import { StudioService } from "./studio.service";
50+
import { InputMethodType, StudioService } from "./studio.service";
5151

5252
@Component({
5353
selector: "studio-component",
@@ -184,7 +184,7 @@ export class StudioComponent implements OnDestroy, OnInit {
184184
this.shepherdService.keyboardNavigation = false;
185185

186186
const cachedTextInputMode = this.studioService.inputMethod.text;
187-
const setTextInputMode = (mode: string) => {
187+
const setTextInputMode = (mode: InputMethodType["text"]) => {
188188
return () => {
189189
if (this.upload) {
190190
this.studioService.inputMethod.text = mode;
@@ -202,7 +202,7 @@ export class StudioComponent implements OnDestroy, OnInit {
202202
};
203203

204204
const cachedAudioInputMode = this.studioService.inputMethod.audio;
205-
const setAudioInputMode = (mode: string) => {
205+
const setAudioInputMode = (mode: InputMethodType["audio"]) => {
206206
return () => {
207207
if (this.upload) {
208208
this.studioService.inputMethod.audio = mode;

packages/studio-web/src/app/studio/studio.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export enum langMode {
88
specific = "specific",
99
}
1010

11+
export interface InputMethodType {
12+
audio: "mic" | "upload";
13+
text: "edit" | "upload";
14+
}
15+
1116
@Injectable({
1217
providedIn: "root",
1318
})
@@ -25,7 +30,7 @@ export class StudioService {
2530
{ value: "und", disabled: this.langMode$.value !== "specific" },
2631
Validators.required,
2732
);
28-
textControl$ = new FormControl<any>(null, Validators.required);
33+
textControl$ = new FormControl<File | Blob | null>(null, Validators.required);
2934
audioControl$ = new FormControl<File | Blob | null>(
3035
null,
3136
Validators.required,
@@ -36,7 +41,7 @@ export class StudioService {
3641
text: this.textControl$,
3742
audio: this.audioControl$,
3843
});
39-
inputMethod = {
44+
inputMethod: InputMethodType = {
4045
audio: "mic",
4146
text: "edit",
4247
};

packages/studio-web/src/app/upload.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import { BehaviorSubject } from "rxjs";
66
})
77
export class UploadService {
88
$currentAudio = new BehaviorSubject<Blob | File | null>(null);
9-
$currentText = new BehaviorSubject<Blob | string | null>(null);
9+
$currentText = new BehaviorSubject<Blob | File | null>(null);
1010
constructor() {}
1111
}

packages/studio-web/src/app/upload/upload.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h1 i18n="Title for text box" class="title">Text</h1>
3535
</mat-button-toggle-group>
3636
</div>
3737
</div>
38-
<div *ngIf="studioService.inputMethod.text === 'upload'">
38+
<div [class.d-none]="studioService.inputMethod.text !== 'upload'">
3939
<div class="row">
4040
<div class="mt-4 mb-3">
4141
<!-- <div class="container"> -->
@@ -47,7 +47,7 @@ <h1 i18n="Title for text box" class="title">Text</h1>
4747
file (.readalong)</label
4848
>
4949
<input
50-
#textInputElement
50+
#textFileUpload
5151
(change)="onTextFileSelected($event)"
5252
class="form-control"
5353
name="text"
@@ -155,7 +155,7 @@ <h1 i18n="Title for audio box" class="title">Audio</h1>
155155
</div>
156156

157157
<div
158-
*ngIf="studioService.inputMethod.audio === 'upload'"
158+
[class.d-none]="studioService.inputMethod.audio !== 'upload'"
159159
class="row mb-3"
160160
>
161161
<h2 i18n="Title for upload box" class="subtitle">
@@ -289,6 +289,7 @@ <h2 i18n="Title for record box" class="subtitle">
289289
mat-button
290290
color="warn"
291291
aria-label="Delete button"
292+
data-test-id="ras-audio-fileselector-delete-btn"
292293
>
293294
<mat-icon class="mat-icon-lg">delete</mat-icon>
294295
Delete

0 commit comments

Comments
 (0)