]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-forms/input-text.component.ts
Merge branch 'release/5.0.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-forms / input-text.component.ts
index d9722e6c6417b86b021c0185f160f96340638ffb..aa4a1cba8347cddf1ead4174a258854c96863928 100644 (file)
@@ -1,7 +1,6 @@
-import { Component, forwardRef, Input } from '@angular/core'
+import { Component, ElementRef, forwardRef, Input, ViewChild } from '@angular/core'
 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
 import { Notifier } from '@app/core'
-import { GlobalIconName } from '../shared-icons'
 
 @Component({
   selector: 'my-input-text',
@@ -16,6 +15,8 @@ import { GlobalIconName } from '../shared-icons'
   ]
 })
 export class InputTextComponent implements ControlValueAccessor {
+  @ViewChild('input') inputElement: ElementRef
+
   @Input() inputId = Math.random().toString(11).slice(2, 8) // id cannot be left empty or undefined
   @Input() value = ''
   @Input() autocomplete = 'off'
@@ -25,6 +26,7 @@ export class InputTextComponent implements ControlValueAccessor {
   @Input() withCopy = false
   @Input() readonly = false
   @Input() show = false
+  @Input() formError: string
 
   constructor (private notifier: Notifier) { }
 
@@ -48,12 +50,6 @@ export class InputTextComponent implements ControlValueAccessor {
     this.notifier.success($localize`Copied`)
   }
 
-  getEyeIcon (): GlobalIconName {
-    if (this.show) return 'sensitive'
-
-    return 'unsensitive'
-  }
-
   propagateChange = (_: any) => { /* empty */ }
 
   writeValue (value: string) {
@@ -71,4 +67,10 @@ export class InputTextComponent implements ControlValueAccessor {
   update () {
     this.propagateChange(this.value)
   }
+
+  focus () {
+    const el: HTMLElement = this.inputElement.nativeElement
+
+    el.focus({ preventScroll: true })
+  }
 }