in web-app/src/app/routes/setting/label/label.component.ts [135:200]
onManageModalOk() {
if (this.labelForm?.invalid) {
Object.values(this.labelForm.controls).forEach(control => {
if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({ onlySelf: true });
}
});
return;
}
this.isManageModalOkLoading = true;
this.label.name = this.label.name.trim();
if (this.label.tagValue != undefined) {
this.label.tagValue = this.label.tagValue.trim();
}
if (this.label.description != undefined) {
this.label.description = this.label.description.trim();
}
if (this.isManageModalAdd) {
const modalOk$ = this.labelService
.newLabel(this.label)
.pipe(
finalize(() => {
modalOk$.unsubscribe();
this.isManageModalOkLoading = false;
})
)
.subscribe(
message => {
if (message.code === 0) {
this.isManageModalVisible = false;
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.new-success'), '');
this.loadLabelTable();
} else {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), message.msg);
}
},
error => {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), error.msg);
}
);
} else {
const modalOk$ = this.labelService
.editLabel(this.label)
.pipe(
finalize(() => {
modalOk$.unsubscribe();
this.isManageModalOkLoading = false;
})
)
.subscribe(
message => {
if (message.code === 0) {
this.isManageModalVisible = false;
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.edit-success'), '');
this.loadLabelTable();
} else {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), message.msg);
}
},
error => {
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), error.msg);
}
);
}
}