More data type fixes for <tailbone-datepicker>
traditionally the caller has always dealt with string values only, so the component should never emit events with date values, etc.
This commit is contained in:
		
							parent
							
								
									d607ab2981
								
							
						
					
					
						commit
						28fb3f44a7
					
				
					 1 changed files with 9 additions and 12 deletions
				
			
		|  | @ -27,20 +27,14 @@ const TailboneDatepicker = { | |||
|     }, | ||||
| 
 | ||||
|     data() { | ||||
|         let buefyValue = this.value | ||||
|         if (buefyValue && !buefyValue.getDate) { | ||||
|             buefyValue = this.parseDate(this.value) | ||||
|         } | ||||
|         return { | ||||
|             buefyValue, | ||||
|             buefyValue: this.parseDate(this.value), | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     watch: { | ||||
|         value(to, from) { | ||||
|             if (this.buefyValue != to) { | ||||
|                 this.buefyValue = to | ||||
|             } | ||||
|             this.buefyValue = this.parseDate(to) | ||||
|         }, | ||||
|     }, | ||||
| 
 | ||||
|  | @ -61,13 +55,16 @@ const TailboneDatepicker = { | |||
|         }, | ||||
| 
 | ||||
|         parseDate(date) { | ||||
|             // note, this assumes classic YYYY-MM-DD (i.e. ISO?) format
 | ||||
|             var parts = date.split('-') | ||||
|             return new Date(parts[0], parseInt(parts[1]) - 1, parts[2]) | ||||
|             if (typeof(date) == 'string') { | ||||
|                 // note, this assumes classic YYYY-MM-DD (i.e. ISO?) format
 | ||||
|                 var parts = date.split('-') | ||||
|                 return new Date(parts[0], parseInt(parts[1]) - 1, parts[2]) | ||||
|             } | ||||
|             return date | ||||
|         }, | ||||
| 
 | ||||
|         dateChanged(date) { | ||||
|             this.$emit('input', date) | ||||
|             this.$emit('input', this.formatDate(date)) | ||||
|         }, | ||||
| 
 | ||||
|         focus() { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar