import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { HtmlInputTypes } from '../../models'; @Component({ selector: 'fss-form-input-password', templateUrl: './form-input-password.component.html', styleUrls: ['./form-input-password.component.scss'] }) export class FormInputPasswordComponent implements OnInit { @Input() form: FormGroup | undefined;; @Input() control: FormControl | undefined;; @Input() hasPermission = true; @Input() label!: string; @Input() toolTipText = 'fss.universal.tooltip.missingPermission'; @Input() value: any; @Input() patternError = 'fss.general.errors.pattern'; @Input() autoCompleteHint = 'new-password'; @Input() showMaxLength = true; @Input() showMinLength = true; @Input() showPatternError = true; @Input() showLabel = true; @Input() allowShowPassword = true; @Input() isReadOnly = false; inputFieldType: HtmlInputTypes = HtmlInputTypes.password; _HtmlInputTypes = HtmlInputTypes; constructor() { } ngOnInit(): void { } onToggleShowPasword() { if (this.control?.disabled || !this.hasPermission) { return; } switch (this.inputFieldType) { case HtmlInputTypes.text: this.inputFieldType = HtmlInputTypes.password; break; case HtmlInputTypes.password: this.inputFieldType = HtmlInputTypes.text; break; default: this.inputFieldType = HtmlInputTypes.password; } } }