diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts index 410c684..0940f87 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts @@ -4,11 +4,13 @@ import { ModalModule } from 'ngx-bootstrap/modal'; import { CommandModalDirective } from './directives/command-modal.directive'; import { CommandModalComponent } from './command-modal/command-modal.component'; import { InputValidatorDirective } from './directives/input-validator.directive'; +import { FormsModule } from '@angular/forms'; @NgModule({ imports: [ CommonModule, - ModalModule.forRoot() + ModalModule.forRoot(), + FormsModule ], declarations: [CommandModalDirective, CommandModalComponent, InputValidatorDirective], exports: [CommandModalDirective] diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.html b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.html index e4f2e07..2c11963 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.html +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.html @@ -7,13 +7,12 @@ - \ No newline at end of file + + diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.scss b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.scss index e69de29..f7e771a 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.scss +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.scss @@ -0,0 +1,3 @@ +.field-error{ + border: 1px solid red; +} \ No newline at end of file diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.ts index 84c892e..4408a68 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.ts @@ -3,6 +3,7 @@ import { IDataSource } from '@poweredsoft/data'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { finalize} from 'rxjs/operators'; import { Subscription } from 'rxjs'; +import { NgForm } from '@angular/forms'; @Component({ selector: 'psbx-command-modal', @@ -20,6 +21,8 @@ export class CommandModalComponent implements OnInit, OnDestroy { loading: boolean; commandText: string; cancelText: string; + form:NgForm; + validationMessage:string ; private _notifyMessage: Subscription; private _validationError: Subscription; @@ -33,16 +36,26 @@ export class CommandModalComponent implements OnInit, OnDestroy { ngOnInit(): void { this._notifyMessage = this.dataSource.notifyMessage$.subscribe(message => { - + if (message.type != 'info') + this.validationMessage = message.message; }); - this._validationError = this.dataSource.validationError$.subscribe(validatorErrors => { - console.log(validatorErrors); + this._validationError = this.dataSource.validationError$.subscribe(validatorErrors => { + let validationSummary = ''; + Object.getOwnPropertyNames(validatorErrors.errors).forEach(property => { + const errors = validatorErrors.errors[property].join('\n'); + validationSummary += errors + '\n'; + }); + this.validationMessage = validationSummary.trim(); }); } - attemptSave() { + onSubmit(){ + + this.loading = true; + this.validationMessage = null; + this.dataSource.executeCommandByName(this.command, this.commandModel) .pipe( finalize(() => { @@ -59,4 +72,8 @@ export class CommandModalComponent implements OnInit, OnDestroy { }); } + attemptSave() { + + } + } diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/form-group-command-modal/form-group-command-modal/form-group-command-modal.component.html b/projects/poweredsoft/ngx-bootstrap/src/lib/form-group-command-modal/form-group-command-modal/form-group-command-modal.component.html index d640079..d7d60bf 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/form-group-command-modal/form-group-command-modal/form-group-command-modal.component.html +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/form-group-command-modal/form-group-command-modal/form-group-command-modal.component.html @@ -11,17 +11,15 @@ -
- {{ errorMessage }} -
+
{{ errorMessage }}