add confirm modal directive

This commit is contained in:
Yubing325
2020-06-17 11:41:18 -05:00
parent 1cd6e16ce4
commit 96be2876b8
5 changed files with 85 additions and 27 deletions
@@ -42,9 +42,9 @@
<ng-container psDataGridCol="commands">
<ng-container *psDataGridColHeader>Actions</ng-container>
<ng-container *psDataGridCell="let model">
<!-- <button class="btn-warning btn" psbxCommandModal [commandTitle]="'Change ' + model.name + ' name'" commandText="Update"
[dataSource]="merchantDataSource" command="changeMerchant" [model]="model" [template]="changeName">Change</button> -->
<button class="btn-danger btn" (click)="removeMerchant(model.id)">Remove</button>
<button class="btn-danger btn" psbxConfirmModal [commandTitle]="'Are you sure you wnat to remove ' + model.name + '?'" commandText="Remove"
[dataSource]="merchantDataSource" command="removeMerchant" [model]="model" >Remove</button>
<!-- <button class="btn-danger btn" (click)="removeMerchant(model.id)">Remove</button> -->
</ng-container>
</ng-container>
@@ -20,29 +20,29 @@ export class PaginationDemoComponent implements OnInit {
pages:any;
removeMerchant(id:string) {
this.confirmModalService.confirm({
message: 'Do you want to delete this merchant?',
yesText: 'yes delete this merchant',
yesClass: 'danger',
noText: 'no please dont',
noClass: 'light'
}).subscribe(result => {
if(result){
this.merchantDataSource.executeCommandByName('removeMerchant', {
id: id
}).subscribe(
res => {
this.merchantDataSource.refresh();
},
err => {
console.log(err);
alert('failed');
}
);
}
})
}
// removeMerchant(id:string) {
// this.confirmModalService.confirm({
// message: 'Do you want to delete this merchant?',
// yesText: 'yes delete this merchant',
// yesClass: 'danger',
// noText: 'no please dont',
// noClass: 'light'
// }).subscribe(result => {
// if(result){
// this.merchantDataSource.executeCommandByName('removeMerchant', {
// id: id
// }).subscribe(
// res => {
// this.merchantDataSource.refresh();
// },
// err => {
// console.log(err);
// alert('failed');
// }
// );
// }
// })
// }
createDataSource(): IDataSource<IMerchant> {