From a2c5cd4a03cfe792a5f7341b33115002c448d3e4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 22 Mar 2022 17:41:39 +0100 Subject: Add reset button for file inputs in studio page --- .../app/shared/shared-forms/preview-upload.component.html | 2 +- .../src/app/shared/shared-forms/preview-upload.component.ts | 4 ++++ .../src/app/shared/shared-forms/reactive-file.component.html | 6 +++++- .../src/app/shared/shared-forms/reactive-file.component.scss | 11 +++++++++++ .../src/app/shared/shared-forms/reactive-file.component.ts | 12 +++++++++++- 5 files changed, 32 insertions(+), 3 deletions(-) (limited to 'client/src/app/shared') 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 */ } -- cgit v1.2.3