add btnClass to command-modal

This commit is contained in:
Yubing325 2020-07-09 14:28:55 -05:00
parent f702608640
commit fcc39e9fac
5 changed files with 27 additions and 8 deletions

View File

@ -12,7 +12,7 @@
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-light" (click)="modalRef.hide()" <button type="button" class="btn btn-light" (click)="modalRef.hide()"
[disabled]="loading">{{ cancelText }}</button> [disabled]="loading">{{ cancelText }}</button>
<button type="button" class="btn btn-primary" [disabled]="loading" (click)="onSubmit()">{{ commandText }}</button> <button type="button" class="btn btn-{{btnClass}}" [disabled]="loading" (click)="onSubmit()">{{ commandText }}</button>
<br> <br>
<div class="progress" style="width: 100%" *ngIf="loading"> <div class="progress" style="width: 100%" *ngIf="loading">

View File

@ -23,7 +23,7 @@ export class CommandModalComponent implements OnInit, OnDestroy {
cancelText: string; cancelText: string;
form:NgForm; form:NgForm;
validationMessage:string ; validationMessage:string ;
btnClass:string;
successEmitter: EventEmitter<any>; successEmitter: EventEmitter<any>;
private _notifyMessage: Subscription; private _notifyMessage: Subscription;

View File

@ -20,6 +20,7 @@ export class CommandModalDirective {
@Input() commandText: string; @Input() commandText: string;
@Input() cancelText: string; @Input() cancelText: string;
@Input() animated: boolean; @Input() animated: boolean;
@Input() btnClass:string;
@Output() success: EventEmitter<any> = new EventEmitter<any>(); @Output() success: EventEmitter<any> = new EventEmitter<any>();
@ -38,7 +39,8 @@ export class CommandModalDirective {
refreshOnSuccess: this.refreshOnSuccess === undefined ? true : this.refreshOnSuccess, refreshOnSuccess: this.refreshOnSuccess === undefined ? true : this.refreshOnSuccess,
commandText: this.commandText || 'OK', commandText: this.commandText || 'OK',
cancelText: this.cancelText || 'Cancel', cancelText: this.cancelText || 'Cancel',
successEmitter: this.success successEmitter: this.success,
btnClass: this.btnClass || 'primary'
}; };
this.modalService.show(CommandModalComponent, { this.modalService.show(CommandModalComponent, {
animated: this.animated === undefined ? true : this.animated, animated: this.animated === undefined ? true : this.animated,

View File

@ -5,6 +5,7 @@ import { NgSelectDemoRoutingModule } from './ng-select-demo-routing.module';
import { NgSelectModule } from '@ng-select/ng-select'; import { NgSelectModule } from '@ng-select/ng-select';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { PsNgSelectModule } from '@poweredsoft/ng-select'; import { PsNgSelectModule } from '@poweredsoft/ng-select';
import { CommandModule, CommandModalModule } from '@poweredsoft/ngx-bootstrap';
@ -17,7 +18,9 @@ import { PsNgSelectModule } from '@poweredsoft/ng-select';
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
NgSelectDemoRoutingModule, NgSelectDemoRoutingModule,
PsNgSelectModule PsNgSelectModule,
CommandModule,
CommandModalModule
] ]
}) })
export class NgSelectDemoModule { } export class NgSelectDemoModule { }

View File

@ -33,10 +33,16 @@ selected: {{ myValue3 | json }}
<ps-ng-select [dataSource]="merchantDataSource3" bindLabel="name" bindValue="id" [(ngModel)]="myValue2" [serverFiltering]="false"> <ps-ng-select [dataSource]="merchantDataSource3" bindLabel="name" bindValue="id" [(ngModel)]="myValue2" [serverFiltering]="false">
<div *psNgNotFoundTemplate="let searchTerm"> <div *psNgNotFoundTemplate="let searchTerm">
<div class="ng-option disabled"> <div class="ng-option disabled">
No data found for "{{searchTerm}}" <button class="btn btn-success" No data found for "{{searchTerm}}"
psbxCommand <button class="btn-primary btn"
(success)="myValue2 = $event"> psbxCommandModal
Create New {{searchTerm}}</button> commandTitle="Adding a new {{searchTerm}}"
commandText="Add"
[dataSource]="merchantDataSource"
command="addMerchant"
cancelText="Abort"
[template]="theModal"
(success)="myValue2 = $event"> Create New {{searchTerm}}</button>
</div> </div>
</div> </div>
</ps-ng-select> </ps-ng-select>
@ -53,3 +59,11 @@ selected: {{ myValue2 | json }}
</ps-ng-multi-select> </ps-ng-multi-select>
selected: {{ myValue4 | json }} selected: {{ myValue4 | json }}
<ng-template #theModal let-command let-loading="loading">
<form >
Name
<input type="text" required [disabled]="loading" name="name" [(ngModel)]="command.name" placeholder="Enter a merchant name" class="form-control" >
Address
<input type="text" required [disabled]="loading" name="address" [(ngModel)]="command.address" placeholder="Enter the merchant's address" class="form-control" >
</form>
</ng-template>