Skip to content

Commit

Permalink
[bugfix] add incident publishing form validation (#2139)
Browse files Browse the repository at this point in the history
Co-authored-by: Logic <[email protected]>
  • Loading branch information
LiuTianyou and zqr10159 authored Jun 26, 2024
1 parent 8c0b39f commit dbac0df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions web-app/src/app/routes/setting/status/status.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
[nzOkLoading]="currentComponentLoading"
>
<div *nzModalContent class="-inner-content">
<form nz-form #tagForm="ngForm">
<form nz-form #componentForm="ngForm">
<nz-form-item>
<nz-form-label [nzSpan]="7" nzFor="component-name" nzRequired="true">{{ 'status.component.name' | i18n }}</nz-form-label>
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
Expand Down Expand Up @@ -364,7 +364,7 @@
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="currentStatusComponent.method == 0">
<nz-form-label [nzSpan]="7" nzFor="tag" [nzTooltipTitle]="'status.component.tag.tip' | i18n">{{
<nz-form-label [nzSpan]="7" nzFor="tag" nzRequired="true" [nzTooltipTitle]="'status.component.tag.tip' | i18n">{{
'status.component.tag' | i18n
}}</nz-form-label>
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
Expand Down
24 changes: 22 additions & 2 deletions web-app/src/app/routes/setting/status/status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 = [];
Expand Down

0 comments on commit dbac0df

Please sign in to comment.