| 
									
										
										
										
											2016-03-05 17:53:34 -05:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { Injectable }       from '@angular/core'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-18 12:00:04 -04:00
										 |  |  | import { DropdownQuestion } from './question-dropdown'; | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { QuestionBase }     from './question-base'; | 
					
						
							|  |  |  | import { TextboxQuestion }  from './question-textbox'; | 
					
						
							| 
									
										
										
										
											2016-03-05 17:53:34 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Injectable() | 
					
						
							|  |  |  | export class QuestionService { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Todo: get from a remote source of question metadata
 | 
					
						
							|  |  |  |   // Todo: make asynchronous
 | 
					
						
							|  |  |  |   getQuestions() { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |     let questions: QuestionBase<any>[] = [ | 
					
						
							| 
									
										
										
										
											2016-03-05 17:53:34 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |       new DropdownQuestion({ | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |         key: 'brave', | 
					
						
							| 
									
										
										
										
											2016-03-05 17:53:34 -05:00
										 |  |  |         label: 'Bravery Rating', | 
					
						
							|  |  |  |         options: [ | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |           {key: 'solid',  value: 'Solid'}, | 
					
						
							|  |  |  |           {key: 'great',  value: 'Great'}, | 
					
						
							|  |  |  |           {key: 'good',   value: 'Good'}, | 
					
						
							|  |  |  |           {key: 'unproven', value: 'Unproven'} | 
					
						
							| 
									
										
										
										
											2016-03-05 17:53:34 -05:00
										 |  |  |         ], | 
					
						
							|  |  |  |         order: 3 | 
					
						
							|  |  |  |       }), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       new TextboxQuestion({ | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |         key: 'firstName', | 
					
						
							|  |  |  |         label: 'First name', | 
					
						
							|  |  |  |         value: 'Bombasto', | 
					
						
							| 
									
										
										
										
											2016-03-05 17:53:34 -05:00
										 |  |  |         required: true, | 
					
						
							|  |  |  |         order: 1 | 
					
						
							|  |  |  |       }), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       new TextboxQuestion({ | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |         key: 'emailAddress', | 
					
						
							|  |  |  |         label: 'Email', | 
					
						
							| 
									
										
										
										
											2016-03-05 17:53:34 -05:00
										 |  |  |         type: 'email', | 
					
						
							|  |  |  |         order: 2 | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |     return questions.sort((a, b) => a.order - b.order); | 
					
						
							| 
									
										
										
										
											2016-03-05 17:53:34 -05:00
										 |  |  |   } | 
					
						
							|  |  |  | } |