Add NumericInputWidget for use with Buefy themes
				
					
				
			uses a Vue.js component for better logic encapsulation
This commit is contained in:
		
							parent
							
								
									2abe589ef6
								
							
						
					
					
						commit
						3a53ffcc23
					
				
					 4 changed files with 66 additions and 0 deletions
				
			
		
							
								
								
									
										38
									
								
								tailbone/static/js/tailbone.buefy.numericinput.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								tailbone/static/js/tailbone.buefy.numericinput.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,38 @@ | |||
| 
 | ||||
| const NumericInput = { | ||||
|     template: [ | ||||
|         '<b-input', | ||||
|         ':name="name"', | ||||
|         ':value="value"', | ||||
|         '@keydown.native="keyDown"', | ||||
|         '@input="valueChanged"', | ||||
|         '>', | ||||
|         '</b-input>' | ||||
|     ].join(' '), | ||||
| 
 | ||||
|     props: { | ||||
|         name: String, | ||||
|         value: String, | ||||
|         allowEnter: Boolean | ||||
|     }, | ||||
| 
 | ||||
|     methods: { | ||||
| 
 | ||||
|         keyDown(event) { | ||||
|             // by default we only allow numeric keys, and general navigation
 | ||||
|             // keys, but we might also allow Enter key
 | ||||
|             if (!key_modifies(event) && !key_allowed(event)) { | ||||
|                 if (!this.allowEnter || event.which != 13) { | ||||
|                     event.preventDefault() | ||||
|                 } | ||||
|             } | ||||
|         }, | ||||
| 
 | ||||
|         valueChanged(value) { | ||||
|             this.$emit('input', value) | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| Vue.component('numeric-input', NumericInput) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar