From dbac0dfe63688d92d583644fe9c3fcd671871fa1 Mon Sep 17 00:00:00 2001 From: liutianyou Date: Wed, 26 Jun 2024 18:11:45 +0800 Subject: [PATCH] [bugfix] add incident publishing form validation (#2139) Co-authored-by: Logic --- .../setting/status/status.component.html | 4 ++-- .../routes/setting/status/status.component.ts | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/web-app/src/app/routes/setting/status/status.component.html b/web-app/src/app/routes/setting/status/status.component.html index 71816827a15..215c05c9291 100644 --- a/web-app/src/app/routes/setting/status/status.component.html +++ b/web-app/src/app/routes/setting/status/status.component.html @@ -320,7 +320,7 @@ [nzOkLoading]="currentComponentLoading" >
-
+ {{ 'status.component.name' | i18n }} @@ -364,7 +364,7 @@ - {{ + {{ 'status.component.tag' | i18n }} diff --git a/web-app/src/app/routes/setting/status/status.component.ts b/web-app/src/app/routes/setting/status/status.component.ts index d864dfa48ca..3789d0f49ba 100644 --- a/web-app/src/app/routes/setting/status/status.component.ts +++ b/web-app/src/app/routes/setting/status/status.component.ts @@ -17,8 +17,8 @@ * under the License. */ -import { Component, Inject, OnInit } from '@angular/core'; -import { FormGroup } from '@angular/forms'; +import { Component, Inject, OnInit, ViewChild } from '@angular/core'; +import { FormGroup, NgForm } from '@angular/forms'; import { I18NService } from '@core'; import { ALAIN_I18N_TOKEN } from '@delon/theme'; import { NzModalService } from 'ng-zorro-antd/modal'; @@ -48,6 +48,8 @@ export class StatusComponent implements OnInit { @Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService ) {} + @ViewChild('incidentForm') incidentForm!: NgForm; + @ViewChild('componentForm') componentForm!: NgForm; statusOrg: StatusPageOrg = new StatusPageOrg(); statusComponents!: StatusPageComponent[]; statusIncidences!: StatusPageIncident[]; @@ -310,6 +312,15 @@ export class StatusComponent implements OnInit { } onComponentModalOk() { + if (this.componentForm.invalid) { + Object.values(this.componentForm.controls).forEach(control => { + if (control.invalid) { + control.markAsDirty(); + control.updateValueAndValidity({ onlySelf: true }); + } + }); + return; + } if (this.matchTag != undefined && this.matchTag.trim() != '') { let tmp: string[] = this.matchTag.split(':'); let tagItem = new TagItem(); @@ -364,6 +375,15 @@ export class StatusComponent implements OnInit { this.notifySvc.warning(this.i18nSvc.fanyi('status.component.notify.need-org'), ''); return; } + if (this.incidentForm.invalid) { + Object.values(this.incidentForm.controls).forEach(control => { + if (control.invalid) { + control.markAsDirty(); + control.updateValueAndValidity({ onlySelf: true }); + } + }); + return; + } // incident message content if (this.currentStatusIncident.contents == undefined) { this.currentStatusIncident.contents = [];