Last active
February 28, 2020 16:58
-
-
Save carlosdelfino/dd0b97fefc2924f673cf1390ba9e7f9c to your computer and use it in GitHub Desktop.
como listar papeis e permitir que somente seja marcado após processamento.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="papeis-section container-fluid row"> | |
<div class="col col-3" *ngFor="let papel of _papeis$ | async" > | |
<mat-checkbox class="col col-2" class="papeis-margin" [checked]="checkPapel(papel) | async" [indeterminate]="waittingPapel(papel)|async" (click)="clickCheckPapel(papel)" labelPosition="after"> | |
{{papel.nome}} | |
</mat-checkbox> | |
<div class="col col-1"></div> | |
</div> | |
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
waittingPapeis: {[index: string]: BehaviorSubject<boolean>;} = {}; | |
checkPapeis: {[index: string]: BehaviorSubject<boolean>;} = {}; | |
waittingPapeis$: {[index: string]: Observable<boolean>;} = {}; | |
checkPapeis$: {[index: string]: Observable<boolean>;} = {}; | |
/** | |
* Verifica se o papel informado é atribuido ao Voluntário | |
*/ | |
checkPapel(p: Papel): Observable<boolean> { | |
// tslint:disable-next-line:forin | |
if (!this.checkPapeis[p.uid]){ | |
this.checkPapeis[p.uid] = new BehaviorSubject<boolean>(false); | |
this.checkPapeis$[p.uid] = this.checkPapeis[p.uid].asObservable(); | |
} | |
return this.checkPapeis$[p.uid]; | |
} | |
waittingPapel(p: Papel): Observable<boolean> { | |
// tslint:disable-next-line:forin | |
if (!this.waittingPapeis[p.uid]){ | |
this.waittingPapeis[p.uid] = new BehaviorSubject<boolean>(false); | |
this.waittingPapeis$[p.uid] = this.waittingPapeis[p.uid].asObservable() | |
} | |
return this.waittingPapeis$[p.uid]; | |
} | |
clickCheckPapel(event: boolean, p: Papel) : boolean{ | |
console.log("ClickCheckPapel"); | |
console.log(p); | |
console.log(event); | |
this.waittingPapeis[p.uid].next(true); | |
this.checkPapeis[p.uid].next(true); | |
// execução remota fora do meu controle | |
this.serviçoRemoto(this.voluntario, p, event).then(()=>{ | |
this.waittingPapeis[p.uid].next(false); | |
this.checkPapeis[p.uid].next(true); | |
}; | |
return false; | |
//return this.clickCheckObservable$; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment