mirror of
				https://github.com/johrpan/musicus.git
				synced 2025-10-26 19:57:25 +01:00 
			
		
		
		
	Validate entries in editors
This commit is contained in:
		
							parent
							
								
									24f493d7d6
								
							
						
					
					
						commit
						e0619b6b27
					
				
					 8 changed files with 173 additions and 66 deletions
				
			
		|  | @ -78,6 +78,8 @@ impl Screen<(Arc<ImportSession>, Option<Medium>), Medium> for MediumEditor { | |||
|             }); | ||||
|         })); | ||||
| 
 | ||||
|         this.name_entry.connect_changed(clone!(@weak this => move |_| this.validate())); | ||||
| 
 | ||||
|         add_button.connect_clicked(clone!(@weak this => move |_| { | ||||
|             spawn!(@clone this, async move { | ||||
|                 if let Some(track_set) = push!(this.handle, TrackSetEditor, Arc::clone(&this.session)).await { | ||||
|  | @ -157,11 +159,18 @@ impl Screen<(Arc<ImportSession>, Option<Medium>), Medium> for MediumEditor { | |||
|             this.track_set_list.update(length); | ||||
|         } | ||||
| 
 | ||||
|         this.validate(); | ||||
| 
 | ||||
|         this | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl MediumEditor { | ||||
|     /// Validate inputs and enable/disable saving.
 | ||||
|     fn validate(&self) { | ||||
|         self.done_button.set_sensitive(!self.name_entry.get_text().is_empty()); | ||||
|     } | ||||
| 
 | ||||
|     /// Create the medium and, if necessary, upload it to the server.
 | ||||
|     async fn save(&self) -> Result<Medium> { | ||||
|         // Convert the track set data to real track sets.
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Elias Projahn
						Elias Projahn