| 
									
										
										
										
											2023-04-04 14:08:50 +08:00
										 |  |  | use crate::entities::{CreateViewParams, ViewLayoutPB};
 | 
					
						
							| 
									
										
										
										
											2023-04-04 08:41:16 +08:00
										 |  |  | use crate::manager::Folder2Manager;
 | 
					
						
							| 
									
										
										
										
											2023-06-01 20:23:27 +08:00
										 |  |  | use crate::view_operation::gen_view_id;
 | 
					
						
							| 
									
										
										
										
											2023-04-04 08:41:16 +08:00
										 |  |  | use std::collections::HashMap;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[cfg(feature = "test_helper")]
 | 
					
						
							|  |  |  | impl Folder2Manager {
 | 
					
						
							|  |  |  |   pub async fn create_test_grid_view(
 | 
					
						
							|  |  |  |     &self,
 | 
					
						
							|  |  |  |     app_id: &str,
 | 
					
						
							|  |  |  |     name: &str,
 | 
					
						
							|  |  |  |     ext: HashMap<String, String>,
 | 
					
						
							|  |  |  |   ) -> String {
 | 
					
						
							|  |  |  |     self
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:08:50 +08:00
										 |  |  |       .create_test_view(app_id, name, ViewLayoutPB::Grid, ext)
 | 
					
						
							| 
									
										
										
										
											2023-04-04 08:41:16 +08:00
										 |  |  |       .await
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pub async fn create_test_board_view(
 | 
					
						
							|  |  |  |     &self,
 | 
					
						
							|  |  |  |     app_id: &str,
 | 
					
						
							|  |  |  |     name: &str,
 | 
					
						
							|  |  |  |     ext: HashMap<String, String>,
 | 
					
						
							|  |  |  |   ) -> String {
 | 
					
						
							|  |  |  |     self
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:08:50 +08:00
										 |  |  |       .create_test_view(app_id, name, ViewLayoutPB::Board, ext)
 | 
					
						
							| 
									
										
										
										
											2023-04-04 08:41:16 +08:00
										 |  |  |       .await
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   async fn create_test_view(
 | 
					
						
							|  |  |  |     &self,
 | 
					
						
							|  |  |  |     app_id: &str,
 | 
					
						
							|  |  |  |     name: &str,
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:08:50 +08:00
										 |  |  |     layout: ViewLayoutPB,
 | 
					
						
							| 
									
										
										
										
											2023-04-04 08:41:16 +08:00
										 |  |  |     ext: HashMap<String, String>,
 | 
					
						
							|  |  |  |   ) -> String {
 | 
					
						
							|  |  |  |     let view_id = gen_view_id();
 | 
					
						
							|  |  |  |     let params = CreateViewParams {
 | 
					
						
							| 
									
										
										
										
											2023-05-31 14:08:54 +08:00
										 |  |  |       parent_view_id: app_id.to_string(),
 | 
					
						
							| 
									
										
										
										
											2023-04-04 08:41:16 +08:00
										 |  |  |       name: name.to_string(),
 | 
					
						
							|  |  |  |       desc: "".to_string(),
 | 
					
						
							|  |  |  |       layout,
 | 
					
						
							|  |  |  |       view_id: view_id.clone(),
 | 
					
						
							|  |  |  |       initial_data: vec![],
 | 
					
						
							| 
									
										
										
										
											2023-05-31 14:08:54 +08:00
										 |  |  |       meta: ext,
 | 
					
						
							| 
									
										
										
										
											2023-06-03 13:40:12 +08:00
										 |  |  |       set_as_current: true,
 | 
					
						
							| 
									
										
										
										
											2023-04-04 08:41:16 +08:00
										 |  |  |     };
 | 
					
						
							|  |  |  |     self.create_view_with_params(params).await.unwrap();
 | 
					
						
							|  |  |  |     view_id
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | }
 |