Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fixbug] required field check #2022

Merged
merged 10 commits into from
May 25, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
* under the License.
*/

import { Component, Inject, OnInit } from '@angular/core';
import { Component, Inject, OnInit, ViewChild } from '@angular/core';
import { 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 @@ -69,6 +70,10 @@ export class AlertNoticeComponent implements OnInit {
tagsOption: any[] = [];
filterTags: string[] = [];
isLimit: boolean = false;
@ViewChild('receiverForm', { static: false }) receiverForm: NgForm | undefined;
@ViewChild('templateForm', { static: false }) templateForm: NgForm | undefined;
@ViewChild('ruleForm', { static: false }) ruleForm: NgForm | undefined;

dayCheckOptions = [
{ label: this.i18nSvc.fanyi('common.week.7'), value: 7, checked: true },
{ label: this.i18nSvc.fanyi('common.week.1'), value: 1, checked: true },
Expand Down Expand Up @@ -348,6 +353,17 @@ export class AlertNoticeComponent implements OnInit {
}

onManageReceiverModalOk() {
// @ts-ignore
if (this.receiverForm.invalid) {
// @ts-ignore
Object.values(this.receiverForm.controls).forEach(control => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi how about here @ts-ignore and below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to change some parts, I have changed them

if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({ onlySelf: true });
}
});
return;
}
this.isManageReceiverModalOkLoading = true;
if (this.isManageReceiverModalAdd) {
const modalOk$ = this.noticeReceiverSvc
Expand Down Expand Up @@ -691,6 +707,17 @@ export class AlertNoticeComponent implements OnInit {
}

onManageRuleModalOk() {
// @ts-ignore
if (this.ruleForm.invalid) {
// @ts-ignore
Object.values(this.ruleForm.controls).forEach(control => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, no suggest use the @ts-ignore to ignore warning, how about this this.ruleForm?.invalid or others

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, I will optimize it, thanks for the reminder

if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({ onlySelf: true });
}
});
return;
}
this.rule.receiverName = [];
this.receiversOption.forEach(option => {
this.rule.receiverId.forEach(id => {
Expand Down Expand Up @@ -777,6 +804,17 @@ export class AlertNoticeComponent implements OnInit {
}

onManageTemplateModalOk() {
// @ts-ignore
if (this.templateForm.invalid) {
// @ts-ignore
Object.values(this.templateForm.controls).forEach(control => {
if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({ onlySelf: true });
}
});
return;
}
this.isManageTemplateModalOkLoading = true;
if (this.isManageTemplateModalAdd) {
this.template.preset = false;
Expand Down
Loading