forked from MapComplete/MapComplete
		
	Fix dynamism in questions with new VariableInputElement
This commit is contained in:
		
							parent
							
								
									b6b20ed3ca
								
							
						
					
					
						commit
						abae813606
					
				
					 6 changed files with 98 additions and 61 deletions
				
			
		
							
								
								
									
										35
									
								
								UI/Input/VariableInputElement.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								UI/Input/VariableInputElement.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| import {InputElement} from "./InputElement"; | ||||
| import {UIEventSource} from "../../Logic/UIEventSource"; | ||||
| import BaseUIElement from "../BaseUIElement"; | ||||
| import {VariableUiElement} from "../Base/VariableUIElement"; | ||||
| 
 | ||||
| export default class VariableInputElement<T> extends InputElement<T> { | ||||
| 
 | ||||
|     private readonly value: UIEventSource<T>; | ||||
|     private readonly element: BaseUIElement | ||||
|     public readonly IsSelected: UIEventSource<boolean>; | ||||
|     private readonly upstream: UIEventSource<InputElement<T>>; | ||||
| 
 | ||||
|     constructor(upstream: UIEventSource<InputElement<T>>) { | ||||
| 
 | ||||
|         super() | ||||
|         this.upstream = upstream; | ||||
|         this.value = upstream.bind(v => v.GetValue()) | ||||
|         this.element = new VariableUiElement(upstream) | ||||
|         this.IsSelected = upstream.bind(v => v.IsSelected) | ||||
|     } | ||||
| 
 | ||||
|     GetValue(): UIEventSource<T> { | ||||
|         return this.value; | ||||
|     } | ||||
| 
 | ||||
|     protected InnerConstructElement(): HTMLElement { | ||||
|         return this.element.ConstructElement(); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     IsValid(t: T): boolean { | ||||
|         return this.upstream.data.IsValid(t); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue