diff --git a/projects/poweredsoft/ngx-bootstrap/package.json b/projects/poweredsoft/ngx-bootstrap/package.json index f73431e..badeeea 100644 --- a/projects/poweredsoft/ngx-bootstrap/package.json +++ b/projects/poweredsoft/ngx-bootstrap/package.json @@ -1,6 +1,6 @@ { "name": "@poweredsoft/ngx-bootstrap", - "version": "0.0.5", + "version": "0.0.6", "description": "an internal use libary for handling data souces grid filtering sorting, add commands etc", "keywords": [ "angular", diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command/directives/command.directive.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command/directives/command.directive.ts index 5d042ba..03b3b44 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command/directives/command.directive.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command/directives/command.directive.ts @@ -1,5 +1,6 @@ import { Directive, Input, TemplateRef, HostListener, Output, EventEmitter } from '@angular/core'; import { IDataSource } from '@poweredsoft/data'; +import { finalize } from 'rxjs/operators'; import { ConfirmModalService } from '../../confirm-modal/confirm-modal.service'; @Directive({ @@ -25,26 +26,32 @@ export class CommandDirective { @Output() success: EventEmitter = new EventEmitter(); @Output() failure: EventEmitter = new EventEmitter(); + @Output() loading: EventEmitter = new EventEmitter(); private doCommand() { this.dataSource.resolveCommandModelByName({ command: this.command, model: this.model }).subscribe(commandModel => { - this.dataSource.executeCommandByName(this.command, commandModel).subscribe( - commandResult => { - if (this.refreshOnSuccess !== false) - this.dataSource.refresh(); + this.loading.emit(true); + this.dataSource.executeCommandByName(this.command, commandModel) + .pipe( + finalize(() => this.loading.emit(false)) + ) + .subscribe( + commandResult => { + if (this.refreshOnSuccess !== false) + this.dataSource.refresh(); - this.success.emit(commandResult); - }, - commandError => { - this.failure.emit(commandError); - } - ); - }, resolveCommandError => { - this.failure.emit(resolveCommandError); - }); + this.success.emit(commandResult); + }, + commandError => { + this.failure.emit(commandError); + } + ); + }, resolveCommandError => { + this.failure.emit(resolveCommandError); + }); }