mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 07:50:08 +08:00
Display warning message in record save validation
- Display warning messages for record save validations failures
This commit is contained in:
parent
33c9d0553a
commit
3368a63948
2 changed files with 11 additions and 8 deletions
|
@ -6,6 +6,7 @@ import {NavigationExtras, Router} from '@angular/router';
|
|||
import {RecordActionManager} from '@views/record/actions/record-action-manager.service';
|
||||
import {moduleNameMapperMock} from '@services/navigation/module-name-mapper/module-name-mapper.service.spec.mock';
|
||||
import {RecordSaveAction} from '@views/record/actions/save/record-save.action';
|
||||
import {messageServiceMock} from '@services/message/message.service.spec.mock';
|
||||
|
||||
const mockRouter = {
|
||||
navigate: (
|
||||
|
@ -21,5 +22,5 @@ export const recordActionsManagerMock = new RecordActionManager(
|
|||
new RecordCreateAction(moduleNameMapperMock, mockRouter),
|
||||
new RecordToggleWidgetsAction(),
|
||||
new RecordCancelAction(),
|
||||
new RecordSaveAction()
|
||||
new RecordSaveAction(messageServiceMock)
|
||||
);
|
||||
|
|
|
@ -2,6 +2,7 @@ import {Injectable} from '@angular/core';
|
|||
import {RecordActionData, RecordActionHandler} from '@views/record/actions/record.action';
|
||||
import {ViewMode} from '@app-common/views/view.model';
|
||||
import {take} from 'rxjs/operators';
|
||||
import {MessageService} from '@services/message/message.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@ -11,18 +12,19 @@ export class RecordSaveAction extends RecordActionHandler {
|
|||
key = 'save';
|
||||
modes = ['edit' as ViewMode];
|
||||
|
||||
constructor() {
|
||||
constructor(protected message: MessageService) {
|
||||
super();
|
||||
}
|
||||
|
||||
run(data: RecordActionData): void {
|
||||
data.store.recordManager.validate().pipe(take(1)).subscribe(
|
||||
valid => {
|
||||
if (valid) {
|
||||
data.store.save().pipe(take(1)).subscribe();
|
||||
}
|
||||
data.store.recordManager.validate().pipe(take(1)).subscribe(valid => {
|
||||
if (valid) {
|
||||
data.store.save().pipe(take(1)).subscribe();
|
||||
return;
|
||||
}
|
||||
);
|
||||
|
||||
this.message.addWarningMessageByKey('LBL_VALIDATION_ERRORS');
|
||||
});
|
||||
}
|
||||
|
||||
shouldDisplay(): boolean {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue