| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | import {UIElement} from "./UIElement"; | 
					
						
							|  |  |  | import {Question} from "../Logic/Question"; | 
					
						
							|  |  |  | import {UIEventSource} from "./UIEventSource"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export class QuestionPicker extends UIElement { | 
					
						
							|  |  |  |     private readonly _questions: Question[]; | 
					
						
							|  |  |  |     private readonly tags: any; | 
					
						
							|  |  |  |     private source: UIEventSource<any>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor(questions: Question[], | 
					
						
							|  |  |  |                 tags: UIEventSource<any>) { | 
					
						
							|  |  |  |         super(tags); | 
					
						
							|  |  |  |         this._questions = questions; | 
					
						
							|  |  |  |         this.tags = tags.data; | 
					
						
							|  |  |  |         this.source = tags; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     protected InnerRender(): string { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         let t = this.tags; | 
					
						
							|  |  |  |         let highestPriority = Number.MIN_VALUE; | 
					
						
							|  |  |  |         let highestQ: Question; | 
					
						
							|  |  |  |         for (const q of this._questions) { | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |             if (!q.Applicable(t)) { | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             const priority = q.question.severity; | 
					
						
							|  |  |  |             if (priority > highestPriority) { | 
					
						
							|  |  |  |                 highestPriority = priority; | 
					
						
							|  |  |  |                 highestQ = q; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (highestQ === undefined) { | 
					
						
							| 
									
										
										
										
											2020-07-01 21:21:29 +02:00
										 |  |  |             return "Er zijn geen vragen meer!"; | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 18:59:47 +02:00
										 |  |  |         return "<div class='question'>" + | 
					
						
							| 
									
										
										
										
											2020-06-28 00:06:23 +02:00
										 |  |  |             highestQ.CreateHtml(this.source).Render() + | 
					
						
							|  |  |  |             "</div>"; | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |