From bf3911af76696fd4d3afb6ae70a072c8890e544d Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 2 Mar 2022 20:21:07 +0000 Subject: [PATCH] refactor: validators --- .../authentication.component.html | 37 +------------------ .../authentication.component.ts | 12 +++++- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/settings/authentication/authentication.component.html b/src/Ombi/ClientApp/src/app/settings/authentication/authentication.component.html index bde67e1c7..5960c79f7 100644 --- a/src/Ombi/ClientApp/src/app/settings/authentication/authentication.component.html +++ b/src/Ombi/ClientApp/src/app/settings/authentication/authentication.component.html @@ -25,48 +25,13 @@ -
+
-
diff --git a/src/Ombi/ClientApp/src/app/settings/authentication/authentication.component.ts b/src/Ombi/ClientApp/src/app/settings/authentication/authentication.component.ts index 386711c4f..100a502b3 100644 --- a/src/Ombi/ClientApp/src/app/settings/authentication/authentication.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/authentication/authentication.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from "@angular/core"; -import { FormBuilder, FormGroup } from "@angular/forms"; +import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { NotificationService } from "../../services"; import { SettingsService } from "../../services"; @@ -29,7 +29,17 @@ export class AuthenticationComponent implements OnInit { enableHeaderAuth: [x.enableHeaderAuth], headerAuthVariable: [x.headerAuthVariable], }); + this.form.controls.enableHeaderAuth.valueChanges.subscribe(x => { + if (x) { + this.form.get("headerAuthVariable").setValidators(Validators.required); + } else { + this.form.get("headerAuthVariable").clearValidators(); + } + this.form.get("headerAuthVariable").updateValueAndValidity(); + }); }); + + } public onSubmit(form: FormGroup) {