{ "version": 3, "sources": ["src/app/member-lookup/member-search/member-search.component.ts", "src/app/member-lookup/member-search/member-search.component.html", "src/app/member-lookup/member-results/member-results.component.ts", "src/app/member-lookup/member-results/member-results.component.html", "src/app/member-lookup/member-demographics/member-demographics.component.ts", "src/app/member-lookup/member-demographics/member-demographics.component.html", "src/app/member-lookup/member/member.component.ts", "src/app/member-lookup/member/member.component.html", "src/app/member-lookup/guards/clear-member-data.guard.ts", "src/app/member-lookup/member-lookup-routing.module.ts", "src/app/member-lookup/member-lookup.module.ts"], "sourcesContent": ["import { Component, OnInit, ViewChild, ElementRef, Renderer2, OnDestroy, AfterViewInit, Directive } from '@angular/core';\r\nimport { UiUtility } from '../../utils/ui-utility';\r\nimport { MemberInfoService } from '../../services/member-info.service';\r\nimport { Member } from '../../services/models/member';\r\nimport { Subscription } from 'rxjs';\r\nimport { ControlContainer, NgForm } from '@angular/forms';\r\nimport { Router, NavigationEnd } from '@angular/router';\r\n\r\n\r\n@Component({\r\n selector: 'app-member-search',\r\n templateUrl: './member-search.component.html',\r\n styleUrls: ['./member-search.component.scss']\r\n})\r\nexport class MemberSearchComponent implements OnInit,OnDestroy,AfterViewInit {\r\n\r\n public clearTrigger: boolean = false;\r\n public memberId: string;\r\n public firstName: string;\r\n public lastName: string;\r\n public dobMonth: number;\r\n public dobDay: number;\r\n public dobYear: number;\r\n public members: Member[];\r\n public currentYear: number;\r\n public citySelected: string = null;\r\n private memberServiceSubscription$: Subscription;\r\n navigationSubscription: Subscription;\r\n\r\n @ViewChild('submitButton') submitBtn: ElementRef;\r\n @ViewChild('searchIdForm') searchIdForm: NgForm;\r\n @ViewChild('searchNameForm') searchNameForm: NgForm;\r\n\r\n\r\n constructor(\r\n private memberService: MemberInfoService,\r\n private renderer: Renderer2,\r\n private router: Router) {}\r\n\r\n ngOnInit(){\r\n // subscribe to the router events. Store the subscription so we can unsubscribe later.\r\n this.navigationSubscription = this.router.events.subscribe((e: any) => {\r\n // If it is a NavigationEnd event re-initalise the component.\r\n if (e instanceof NavigationEnd) {\r\n this.initialiseInvites();\r\n }\r\n });\r\n }\r\n\r\n ngAfterViewInit(): void {\r\n this.setMemberSearchTabWidth();\r\n }\r\n\r\n ngOnDestroy(): void {\r\n if (this.navigationSubscription) {\r\n this.navigationSubscription.unsubscribe();\r\n }\r\n }\r\n\r\n initialiseInvites() {\r\n this.clearSearchByIdData();\r\n this.clearSearchByNameData();\r\n this.searchClear();\r\n }\r\n\r\n public doSearchById() {\r\n this.clearSearchByNameData();\r\n if (!this.memberId) {\r\n return;\r\n }\r\n this.memberServiceSubscription$ = this.memberService.getMembersById(this.memberId)\r\n .subscribe(\r\n result => {\r\n this.members = result;\r\n this.memberServiceSubscription$.unsubscribe();\r\n return result;\r\n },\r\n error => {\r\n }\r\n );\r\n }\r\n\r\n public doSearchByName() {\r\n this.clearSearchByIdData();\r\n if (!this.firstName || !this.lastName) {\r\n return;\r\n }\r\n // Month is zero based -- need to remove one for .NET/SQL date objects\r\n const dateOfBirth = new Date(+this.dobYear, +this.dobMonth - 1, +this.dobDay);\r\n this.memberService.getMembersByName(\r\n this.firstName,\r\n this.lastName,\r\n dateOfBirth,\r\n this.citySelected)\r\n .subscribe(result => {\r\n this.members = result;\r\n },\r\n error => {\r\n }\r\n );\r\n }\r\n\r\n public clearSearchByIdData() {\r\n this.searchIdForm.reset();\r\n }\r\n\r\n public clearSearchByNameData() {\r\n this.searchNameForm.reset();\r\n }\r\n\r\n public searchClear() {\r\n this.memberService.clearMemberList();\r\n this.clearTrigger = !this.clearTrigger;\r\n this.citySelected = null;\r\n }\r\n\r\n processKeyUp($event, current, next) {\r\n {\r\n var today = new Date();\r\n this.currentYear = today.getFullYear();\r\n const inputValue: number = Number(current.model);\r\n\r\n if (current.name === 'monthInput' && (inputValue >= 1 && inputValue <= 12)\r\n && (current.model.length === 2)) {\r\n const input = this.renderer.selectRootElement('#dayInput');\r\n input.focus();\r\n }\r\n else if (current.name === 'dayInput' && (inputValue >= 1 && inputValue <= 31)\r\n && (current.model.length === 2)) {\r\n this.renderer.selectRootElement('#yearInput').focus();\r\n }\r\n else if (current.name === 'yearInput' && (inputValue >= 1900\r\n && inputValue <= this.currentYear)) {\r\n const sbutton = this.renderer.selectRootElement('#submitButton', true);\r\n sbutton.focus();\r\n\r\n }\r\n }\r\n }\r\n\r\n private setMemberSearchTabWidth() {\r\n const tabView = window.document.querySelector('div.member-search-tabview-styles ul.p-tabview-nav');\r\n UiUtility.SetTabsWidthDynamically(tabView, 50);\r\n }\r\n public onCitySelected(city: string) {\r\n this.citySelected = city;\r\n }\r\n}\r\n\r\n\r\n// @Directive({\r\n// selector: '[provide-parent-form]',\r\n// providers: [\r\n// {\r\n// provide: ControlContainer,\r\n// // tslint:disable-next-line: object-literal-shorthand\r\n// useFactory: (form: NgForm) => form,\r\n// deps: [NgForm]\r\n// }\r\n// ]\r\n// })\r\n// export class ProvideParentForm {}\r\n", "