wip
This commit is contained in:
		
							parent
							
								
									e855b45f95
								
							
						
					
					
						commit
						b7b2cbfe9c
					
				
					 1 changed files with 20 additions and 15 deletions
				
			
		|  | @ -124,25 +124,30 @@ impl Component for Loader { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn view(&self, ctx: &Context<Self>) -> Html { |     fn view(&self, ctx: &Context<Self>) -> Html { | ||||||
|         let link = ctx.link(); |         let cb = move |e: Event| { | ||||||
|  |             let mut result = Vec::new(); | ||||||
|  |             let input: HtmlInputElement = e.target_unchecked_into(); | ||||||
|  | 
 | ||||||
|  |             if let Some(files) = input.files() { | ||||||
|  |                 let files = js_sys::try_iter(&files) | ||||||
|  |                     .unwrap() | ||||||
|  |                     .unwrap() | ||||||
|  |                     .map(|v| web_sys::File::from(v.unwrap())) | ||||||
|  |                     .map(File::from); | ||||||
|  |                 result.extend(files); | ||||||
|  |             } | ||||||
|  |             Msg::StartLoad(result) | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|         html! { |         html! { | ||||||
|             if self.is_loading { |             if self.is_loading { | ||||||
|                 <span><strong>{"processing..."}</strong></span> |                 <span><strong>{"processing..."}</strong></span> | ||||||
|             } else { |             } else { | ||||||
|                 <input type="file" value={self.field_value} multiple=true onchange={link.callback(move |e: Event| { |                 <input | ||||||
|                     let mut result = Vec::new(); |                     type="file" | ||||||
|                     let input: HtmlInputElement = e.target_unchecked_into(); |                     value={self.field_value} | ||||||
| 
 |                     multiple=true | ||||||
|                     if let Some(files) = input.files() { |                     onchange={ctx.link().callback(cb)} | ||||||
|                         let files = js_sys::try_iter(&files) |  | ||||||
|                             .unwrap() |  | ||||||
|                             .unwrap() |  | ||||||
|                             .map(|v| web_sys::File::from(v.unwrap())) |  | ||||||
|                             .map(File::from); |  | ||||||
|                         result.extend(files); |  | ||||||
|                     } |  | ||||||
|                     Msg::StartLoad(result) |  | ||||||
|                     })} |  | ||||||
|                 /> |                 /> | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue