fixed error message on command modal shows everytime

This commit is contained in:
Yubing325
2020-11-02 09:56:19 -06:00
parent 565d41c329
commit fbcd9fa568
3 changed files with 20 additions and 32 deletions
@@ -7,7 +7,7 @@
<div class="modal-body">
<ng-container [ngTemplateOutlet]="template"
[ngTemplateOutletContext]="{ $implicit: commandModel, loading: loading }"></ng-container>
<div *ngIf="validationMessage" class="alert alert-danger mt-2" style="white-space: pre-wrap">{{validationMessage}}</div>
<div *ngIf="hasError" class="alert alert-danger mt-2" style="white-space: pre-wrap">{{validationMessage}}</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" (click)="modalRef.hide()"
@@ -25,6 +25,7 @@ export class CommandModalComponent implements OnInit, OnDestroy {
validationMessage:string ;
btnClass:string;
successEmitter: EventEmitter<any>;
hasError: boolean;
private _notifyMessage: Subscription;
private _validationError: Subscription;
@@ -53,8 +54,6 @@ export class CommandModalComponent implements OnInit, OnDestroy {
}
onSubmit(){
this.loading = true;
this.validationMessage = null;
@@ -67,10 +66,11 @@ export class CommandModalComponent implements OnInit, OnDestroy {
.subscribe(commandResult => {
if (this.refreshOnSuccess)
this.dataSource.refresh();
this.hasError = false;
this.modalRef.hide();
this.successEmitter.emit(commandResult);
}, fail => {
this.hasError = true;
// you do not want to close on failure.. so just ignore..
});
}