From a2c5cd4a03cfe792a5f7341b33115002c448d3e4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 22 Mar 2022 17:41:39 +0100 Subject: [PATCH] Add reset button for file inputs in studio page --- .../edit/video-studio-edit.component.html | 12 ++++++------ .../shared/video-caption-add-modal.component.html | 2 +- .../shared/video-caption-add-modal.component.ts | 4 ++++ .../shared-forms/preview-upload.component.html | 2 +- .../shared/shared-forms/preview-upload.component.ts | 4 ++++ .../shared/shared-forms/reactive-file.component.html | 6 +++++- .../shared/shared-forms/reactive-file.component.scss | 11 +++++++++++ .../shared/shared-forms/reactive-file.component.ts | 12 +++++++++++- 8 files changed, 43 insertions(+), 10 deletions(-) diff --git a/client/src/app/+video-studio/edit/video-studio-edit.component.html b/client/src/app/+video-studio/edit/video-studio-edit.component.html index a9f34811f..acfc1a452 100644 --- a/client/src/app/+video-studio/edit/video-studio-edit.component.html +++ b/client/src/app/+video-studio/edit/video-studio-edit.component.html @@ -28,8 +28,8 @@
@@ -42,8 +42,8 @@
@@ -56,8 +56,8 @@
diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.html b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.html index 092952204..a3f0dbdb5 100644 --- a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.html +++ b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.html @@ -23,7 +23,7 @@ diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts index 6deadfcbe..95d83b131 100644 --- a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts @@ -41,6 +41,10 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni return this.serverConfig.videoCaption.file.size.max } + getReactiveFileButtonTooltip () { + return `(extensions: ${this.videoCaptionExtensions.join(', ')})` + } + ngOnInit () { this.serverService.getVideoLanguages() .subscribe(languages => this.videoCaptionLanguages = languages) diff --git a/client/src/app/shared/shared-forms/preview-upload.component.html b/client/src/app/shared/shared-forms/preview-upload.component.html index 7c3a2b588..11e7bdf7f 100644 --- a/client/src/app/shared/shared-forms/preview-upload.component.html +++ b/client/src/app/shared/shared-forms/preview-upload.component.html @@ -2,7 +2,7 @@
diff --git a/client/src/app/shared/shared-forms/preview-upload.component.ts b/client/src/app/shared/shared-forms/preview-upload.component.ts index a857b0a4f..46920dd27 100644 --- a/client/src/app/shared/shared-forms/preview-upload.component.ts +++ b/client/src/app/shared/shared-forms/preview-upload.component.ts @@ -50,6 +50,10 @@ export class PreviewUploadComponent implements OnInit, ControlValueAccessor { return this.bytesPipe.transform(this.maxVideoImageSize) } + getReactiveFileButtonTooltip () { + return $localize`(extensions: ${this.videoImageExtensions}, ${this.maxSizeText}: ${this.maxVideoImageSizeInBytes})` + } + ngOnInit () { this.serverConfig = this.serverService.getHTMLConfig() diff --git a/client/src/app/shared/shared-forms/reactive-file.component.html b/client/src/app/shared/shared-forms/reactive-file.component.html index f6bf5f9ae..d18a99d46 100644 --- a/client/src/app/shared/shared-forms/reactive-file.component.html +++ b/client/src/app/shared/shared-forms/reactive-file.component.html @@ -1,5 +1,5 @@
-
+
{{ inputLabel }} @@ -12,4 +12,8 @@
{{ filename }}
+ +
diff --git a/client/src/app/shared/shared-forms/reactive-file.component.scss b/client/src/app/shared/shared-forms/reactive-file.component.scss index f8db1aa25..7643f29af 100644 --- a/client/src/app/shared/shared-forms/reactive-file.component.scss +++ b/client/src/app/shared/shared-forms/reactive-file.component.scss @@ -20,4 +20,15 @@ font-weight: $font-semibold; } + + .reset-button { + @include peertube-button; + @include grey-button; + + font-size: 80%; + margin-left: 5px; + line-height: initial; + padding: 2px 5px; + height: auto; + } } diff --git a/client/src/app/shared/shared-forms/reactive-file.component.ts b/client/src/app/shared/shared-forms/reactive-file.component.ts index 9d27ad07a..50b7d4c3e 100644 --- a/client/src/app/shared/shared-forms/reactive-file.component.ts +++ b/client/src/app/shared/shared-forms/reactive-file.component.ts @@ -20,8 +20,12 @@ export class ReactiveFileComponent implements OnInit, ControlValueAccessor { @Input() inputName: string @Input() extensions: string[] = [] @Input() maxFileSize: number + @Input() displayFilename = false + @Input() displayReset = false + @Input() icon: GlobalIconName + @Input() buttonTooltip: string @Output() fileChanged = new EventEmitter() @@ -62,8 +66,14 @@ export class ReactiveFileComponent implements OnInit, ControlValueAccessor { this.file = file this.propagateChange(this.file) - this.fileChanged.emit(this.file) } + this.fileChanged.emit(this.file) + } + + reset () { + this.writeValue(undefined) + this.propagateChange(undefined) + this.fileChanged.emit(undefined) } propagateChange = (_: any) => { /* empty */ } -- 2.41.0