0.0.8 loading emitter.

This commit is contained in:
David Lebee 2021-03-23 10:20:02 -04:00
parent 85db43327b
commit 311e520427
2 changed files with 21 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@poweredsoft/ngx-bootstrap", "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", "description": "an internal use libary for handling data souces grid filtering sorting, add commands etc",
"keywords": [ "keywords": [
"angular", "angular",

View File

@ -1,5 +1,6 @@
import { Directive, Input, TemplateRef, HostListener, Output, EventEmitter } from '@angular/core'; import { Directive, Input, TemplateRef, HostListener, Output, EventEmitter } from '@angular/core';
import { IDataSource } from '@poweredsoft/data'; import { IDataSource } from '@poweredsoft/data';
import { finalize } from 'rxjs/operators';
import { ConfirmModalService } from '../../confirm-modal/confirm-modal.service'; import { ConfirmModalService } from '../../confirm-modal/confirm-modal.service';
@Directive({ @Directive({
@ -25,26 +26,32 @@ export class CommandDirective {
@Output() success: EventEmitter<any> = new EventEmitter<any>(); @Output() success: EventEmitter<any> = new EventEmitter<any>();
@Output() failure: EventEmitter<any> = new EventEmitter<any>(); @Output() failure: EventEmitter<any> = new EventEmitter<any>();
@Output() loading: EventEmitter<boolean> = new EventEmitter<boolean>();
private doCommand() { private doCommand() {
this.dataSource.resolveCommandModelByName({ this.dataSource.resolveCommandModelByName({
command: this.command, command: this.command,
model: this.model model: this.model
}).subscribe(commandModel => { }).subscribe(commandModel => {
this.dataSource.executeCommandByName(this.command, commandModel).subscribe( this.loading.emit(true);
commandResult => { this.dataSource.executeCommandByName(this.command, commandModel)
if (this.refreshOnSuccess !== false) .pipe(
this.dataSource.refresh(); finalize(() => this.loading.emit(false))
)
.subscribe(
commandResult => {
if (this.refreshOnSuccess !== false)
this.dataSource.refresh();
this.success.emit(commandResult); this.success.emit(commandResult);
}, },
commandError => { commandError => {
this.failure.emit(commandError); this.failure.emit(commandError);
} }
); );
}, resolveCommandError => { }, resolveCommandError => {
this.failure.emit(resolveCommandError); this.failure.emit(resolveCommandError);
}); });
} }