Guest User

Untitled

a guest
Oct 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import { map, takeWhile } from 'rxjs/operators';
  2. import { Observable } from 'rxjs';
  3. import { ObservableInput } from 'observable-input/lib';
  4.  
  5. import { Component, EventEmitter, Inject, Input, LOCALE_ID, Output } from '@angular/core';
  6. import { ListItem } from '@gat/components';
  7.  
  8. @Component({
  9. selector: 'gat-suggestion-patient',
  10. templateUrl: './suggestion-patient.component.html',
  11. styleUrls: ['./suggestion-patient.component.scss'],
  12. })
  13. export class SuggestionPatientComponent {
  14.  
  15. @Output() onSelectedPatient = new EventEmitter<ListItem>();
  16.  
  17. @Input() @ObservableInput()
  18. patientList: Observable<any>;
  19.  
  20. listItems$: Observable<any>;
  21.  
  22. constructor(
  23. @Inject(LOCALE_ID) private locale: string | any,
  24. ) {
  25. this.listItems$ = this.patientList.pipe(map(this.toListItem));
  26. }
  27.  
  28. toListItem(patient) {
  29. if (patient) {
  30. return patient.map(p => {
  31. return {
  32. id: p.id,
  33. title: p.firstName + ' ' + p.lastName,
  34. body: p.dob,
  35. //FIXME this.locale is undefined !
  36. // body: p.dob ? formatDate(p.dob, 'yyyy-MM-dd', this.locale) : '',
  37. avatar: p.avatar,
  38. isAvatar: true
  39. };
  40. });
  41. }
  42. }
  43.  
  44. }
Add Comment
Please, Sign In to add comment