fixed error message on command modal shows everytime
This commit is contained in:
parent
565d41c329
commit
fbcd9fa568
@ -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..
|
||||
});
|
||||
}
|
||||
|
@ -55,18 +55,10 @@
|
||||
<button class="btn-info btn" psbxCommandModal [commandTitle]="'Change ' + model.name + ' name'"
|
||||
commandText="Update" [dataSource]="merchantDataSource" command="changeMerchant" [model]="model"
|
||||
[template]="theModal">Change</button>
|
||||
<button class="btn-danger btn"
|
||||
psbxCommand
|
||||
[dataSource]="merchantDataSource"
|
||||
command="removeMerchant"
|
||||
[model]="model"
|
||||
[confirm]="true"
|
||||
yesClass="warning"
|
||||
noClass = "secondary"
|
||||
noText = "Cancel Delete"
|
||||
yesText = "Delete It"
|
||||
confirmMessage="Are you sure you want to delete this merchant?"
|
||||
>RemoveIt</button></div>
|
||||
<button class="btn-danger btn" psbxCommand [dataSource]="merchantDataSource" command="removeMerchant"
|
||||
[model]="model" [confirm]="true" yesClass="warning" noClass="secondary" noText="Cancel Delete"
|
||||
yesText="Delete It"
|
||||
confirmMessage="Are you sure you want to delete this merchant?">RemoveIt</button></div>
|
||||
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
@ -78,17 +70,16 @@
|
||||
|
||||
<ng-template #theModal let-command let-loading="loading">
|
||||
<label for="name">Name</label>
|
||||
<input type="text" required [(ngModel)]="command.name" placeholder="Enter a merchant name"
|
||||
class="form-control">
|
||||
<input type="text" required [(ngModel)]="command.name" placeholder="Enter a merchant name" class="form-control">
|
||||
<label for="address">Address</label>
|
||||
<input type="text" required [(ngModel)]="command.address"
|
||||
placeholder="Enter the merchant's address" class="form-control">
|
||||
<input type="text" required [(ngModel)]="command.address" placeholder="Enter the merchant's address"
|
||||
class="form-control">
|
||||
<label for="address">Priority</label>
|
||||
<input type="number" required [(ngModel)]="command.ordering"
|
||||
placeholder="Enter the merchant's Priority" class="form-control">
|
||||
<input type="number" required [(ngModel)]="command.ordering" placeholder="Enter the merchant's Priority"
|
||||
class="form-control">
|
||||
<label for="address">Priority</label>
|
||||
<input type="date" required [(ngModel)]="command.openDate"
|
||||
placeholder="Enter the merchant's Priority" class="form-control">
|
||||
<input type="date" required [(ngModel)]="command.openDate" placeholder="Enter the merchant's Priority"
|
||||
class="form-control">
|
||||
|
||||
</ng-template>
|
||||
|
||||
@ -100,6 +91,3 @@
|
||||
<button type="button" class="btn btn-primary">No</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user