| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  | use crate::database::database_editor::DatabaseEditorTest;
 | 
					
						
							| 
									
										
										
										
											2023-02-21 15:47:51 +08:00
										 |  |  | use database_model::{FieldRevision, RowChangeset};
 | 
					
						
							| 
									
										
										
										
											2023-01-31 08:28:31 +08:00
										 |  |  | use flowy_database::entities::{
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   CreateRowParams, FieldType, GroupPB, LayoutTypePB, MoveGroupParams, MoveGroupRowParams, RowPB,
 | 
					
						
							|  |  |  | };
 | 
					
						
							|  |  |  | use flowy_database::services::cell::{
 | 
					
						
							|  |  |  |   delete_select_option_cell, insert_select_option_cell, insert_url_cell,
 | 
					
						
							| 
									
										
										
										
											2022-08-22 16:16:15 +08:00
										 |  |  | };
 | 
					
						
							| 
									
										
										
										
											2023-01-31 08:28:31 +08:00
										 |  |  | use flowy_database::services::field::{
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   edit_single_select_type_option, SelectOptionPB, SelectTypeOptionSharedAction,
 | 
					
						
							|  |  |  |   SingleSelectTypeOptionPB,
 | 
					
						
							| 
									
										
										
										
											2022-09-02 21:34:00 +08:00
										 |  |  | };
 | 
					
						
							| 
									
										
										
										
											2022-09-01 09:03:33 +08:00
										 |  |  | use std::sync::Arc;
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | pub enum GroupScript {
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   AssertGroupRowCount {
 | 
					
						
							|  |  |  |     group_index: usize,
 | 
					
						
							|  |  |  |     row_count: usize,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   AssertGroupCount(usize),
 | 
					
						
							|  |  |  |   AssertGroup {
 | 
					
						
							|  |  |  |     group_index: usize,
 | 
					
						
							|  |  |  |     expected_group: GroupPB,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   AssertRow {
 | 
					
						
							|  |  |  |     group_index: usize,
 | 
					
						
							|  |  |  |     row_index: usize,
 | 
					
						
							|  |  |  |     row: RowPB,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   MoveRow {
 | 
					
						
							|  |  |  |     from_group_index: usize,
 | 
					
						
							|  |  |  |     from_row_index: usize,
 | 
					
						
							|  |  |  |     to_group_index: usize,
 | 
					
						
							|  |  |  |     to_row_index: usize,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   CreateRow {
 | 
					
						
							|  |  |  |     group_index: usize,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   DeleteRow {
 | 
					
						
							|  |  |  |     group_index: usize,
 | 
					
						
							|  |  |  |     row_index: usize,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   UpdateGroupedCell {
 | 
					
						
							|  |  |  |     from_group_index: usize,
 | 
					
						
							|  |  |  |     row_index: usize,
 | 
					
						
							|  |  |  |     to_group_index: usize,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   UpdateGroupedCellWithData {
 | 
					
						
							|  |  |  |     from_group_index: usize,
 | 
					
						
							|  |  |  |     row_index: usize,
 | 
					
						
							|  |  |  |     cell_data: String,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   MoveGroup {
 | 
					
						
							|  |  |  |     from_group_index: usize,
 | 
					
						
							|  |  |  |     to_group_index: usize,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   UpdateSingleSelectSelectOption {
 | 
					
						
							|  |  |  |     inserted_options: Vec<SelectOptionPB>,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							|  |  |  |   GroupByField {
 | 
					
						
							|  |  |  |     field_id: String,
 | 
					
						
							|  |  |  |   },
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-02 23:02:49 +08:00
										 |  |  | pub struct DatabaseGroupTest {
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   inner: DatabaseEditorTest,
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-02 23:02:49 +08:00
										 |  |  | impl DatabaseGroupTest {
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   pub async fn new() -> Self {
 | 
					
						
							|  |  |  |     let editor_test = DatabaseEditorTest::new_board().await;
 | 
					
						
							|  |  |  |     Self { inner: editor_test }
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   pub async fn run_scripts(&mut self, scripts: Vec<GroupScript>) {
 | 
					
						
							|  |  |  |     for script in scripts {
 | 
					
						
							|  |  |  |       self.run_script(script).await;
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  |     }
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   pub async fn run_script(&mut self, script: GroupScript) {
 | 
					
						
							|  |  |  |     match script {
 | 
					
						
							|  |  |  |       GroupScript::AssertGroupRowCount {
 | 
					
						
							|  |  |  |         group_index,
 | 
					
						
							|  |  |  |         row_count,
 | 
					
						
							|  |  |  |       } => {
 | 
					
						
							|  |  |  |         assert_eq!(row_count, self.group_at_index(group_index).await.rows.len());
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::AssertGroupCount(count) => {
 | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  |         let groups = self.editor.load_groups(&self.view_id).await.unwrap();
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |         assert_eq!(count, groups.len());
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::MoveRow {
 | 
					
						
							|  |  |  |         from_group_index,
 | 
					
						
							|  |  |  |         from_row_index,
 | 
					
						
							|  |  |  |         to_group_index,
 | 
					
						
							|  |  |  |         to_row_index,
 | 
					
						
							|  |  |  |       } => {
 | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  |         let groups: Vec<GroupPB> = self.editor.load_groups(&self.view_id).await.unwrap().items;
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |         let from_row = groups
 | 
					
						
							|  |  |  |           .get(from_group_index)
 | 
					
						
							|  |  |  |           .unwrap()
 | 
					
						
							|  |  |  |           .rows
 | 
					
						
							|  |  |  |           .get(from_row_index)
 | 
					
						
							|  |  |  |           .unwrap();
 | 
					
						
							|  |  |  |         let to_group = groups.get(to_group_index).unwrap();
 | 
					
						
							|  |  |  |         let to_row = to_group.rows.get(to_row_index).unwrap();
 | 
					
						
							|  |  |  |         let params = MoveGroupRowParams {
 | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  |           view_id: self.view_id.clone(),
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |           from_row_id: from_row.id.clone(),
 | 
					
						
							|  |  |  |           to_group_id: to_group.group_id.clone(),
 | 
					
						
							|  |  |  |           to_row_id: Some(to_row.id.clone()),
 | 
					
						
							|  |  |  |         };
 | 
					
						
							| 
									
										
										
										
											2022-08-18 21:43:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |         self.editor.move_group_row(params).await.unwrap();
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::AssertRow {
 | 
					
						
							|  |  |  |         group_index,
 | 
					
						
							|  |  |  |         row_index,
 | 
					
						
							|  |  |  |         row,
 | 
					
						
							|  |  |  |       } => {
 | 
					
						
							|  |  |  |         //
 | 
					
						
							|  |  |  |         let group = self.group_at_index(group_index).await;
 | 
					
						
							|  |  |  |         let compare_row = group.rows.get(row_index).unwrap().clone();
 | 
					
						
							|  |  |  |         assert_eq!(row.id, compare_row.id);
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::CreateRow { group_index } => {
 | 
					
						
							|  |  |  |         let group = self.group_at_index(group_index).await;
 | 
					
						
							|  |  |  |         let params = CreateRowParams {
 | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  |           view_id: self.view_id.clone(),
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |           start_row_id: None,
 | 
					
						
							|  |  |  |           group_id: Some(group.group_id.clone()),
 | 
					
						
							|  |  |  |           layout: LayoutTypePB::Board,
 | 
					
						
							|  |  |  |         };
 | 
					
						
							|  |  |  |         let _ = self.editor.create_row(params).await.unwrap();
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::DeleteRow {
 | 
					
						
							|  |  |  |         group_index,
 | 
					
						
							|  |  |  |         row_index,
 | 
					
						
							|  |  |  |       } => {
 | 
					
						
							|  |  |  |         let row = self.row_at_index(group_index, row_index).await;
 | 
					
						
							|  |  |  |         self.editor.delete_row(&row.id).await.unwrap();
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::UpdateGroupedCell {
 | 
					
						
							|  |  |  |         from_group_index,
 | 
					
						
							|  |  |  |         row_index,
 | 
					
						
							|  |  |  |         to_group_index,
 | 
					
						
							|  |  |  |       } => {
 | 
					
						
							|  |  |  |         let from_group = self.group_at_index(from_group_index).await;
 | 
					
						
							|  |  |  |         let to_group = self.group_at_index(to_group_index).await;
 | 
					
						
							|  |  |  |         let field_id = from_group.field_id;
 | 
					
						
							|  |  |  |         let field_rev = self.editor.get_field_rev(&field_id).await.unwrap();
 | 
					
						
							|  |  |  |         let field_type: FieldType = field_rev.ty.into();
 | 
					
						
							| 
									
										
										
										
											2022-08-30 15:21:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |         let cell_rev = if to_group.is_default {
 | 
					
						
							|  |  |  |           match field_type {
 | 
					
						
							|  |  |  |             FieldType::SingleSelect => {
 | 
					
						
							|  |  |  |               delete_select_option_cell(vec![to_group.group_id.clone()], &field_rev)
 | 
					
						
							|  |  |  |             },
 | 
					
						
							|  |  |  |             FieldType::MultiSelect => {
 | 
					
						
							|  |  |  |               delete_select_option_cell(vec![to_group.group_id.clone()], &field_rev)
 | 
					
						
							|  |  |  |             },
 | 
					
						
							|  |  |  |             _ => {
 | 
					
						
							|  |  |  |               panic!("Unsupported group field type");
 | 
					
						
							|  |  |  |             },
 | 
					
						
							|  |  |  |           }
 | 
					
						
							|  |  |  |         } else {
 | 
					
						
							|  |  |  |           match field_type {
 | 
					
						
							|  |  |  |             FieldType::SingleSelect => {
 | 
					
						
							|  |  |  |               insert_select_option_cell(vec![to_group.group_id.clone()], &field_rev)
 | 
					
						
							|  |  |  |             },
 | 
					
						
							|  |  |  |             FieldType::MultiSelect => {
 | 
					
						
							|  |  |  |               insert_select_option_cell(vec![to_group.group_id.clone()], &field_rev)
 | 
					
						
							|  |  |  |             },
 | 
					
						
							|  |  |  |             FieldType::URL => insert_url_cell(to_group.group_id.clone(), &field_rev),
 | 
					
						
							|  |  |  |             _ => {
 | 
					
						
							|  |  |  |               panic!("Unsupported group field type");
 | 
					
						
							|  |  |  |             },
 | 
					
						
							|  |  |  |           }
 | 
					
						
							|  |  |  |         };
 | 
					
						
							| 
									
										
										
										
											2022-08-19 11:56:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |         let row_id = self.row_at_index(from_group_index, row_index).await.id;
 | 
					
						
							|  |  |  |         let mut row_changeset = RowChangeset::new(row_id);
 | 
					
						
							|  |  |  |         row_changeset.cell_by_field_id.insert(field_id, cell_rev);
 | 
					
						
							|  |  |  |         self.editor.update_row(row_changeset).await.unwrap();
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::UpdateGroupedCellWithData {
 | 
					
						
							|  |  |  |         from_group_index,
 | 
					
						
							|  |  |  |         row_index,
 | 
					
						
							|  |  |  |         cell_data,
 | 
					
						
							|  |  |  |       } => {
 | 
					
						
							|  |  |  |         let from_group = self.group_at_index(from_group_index).await;
 | 
					
						
							|  |  |  |         let field_id = from_group.field_id;
 | 
					
						
							|  |  |  |         let field_rev = self.editor.get_field_rev(&field_id).await.unwrap();
 | 
					
						
							|  |  |  |         let field_type: FieldType = field_rev.ty.into();
 | 
					
						
							|  |  |  |         let cell_rev = match field_type {
 | 
					
						
							|  |  |  |           FieldType::URL => insert_url_cell(cell_data, &field_rev),
 | 
					
						
							|  |  |  |           _ => {
 | 
					
						
							|  |  |  |             panic!("Unsupported group field type");
 | 
					
						
							|  |  |  |           },
 | 
					
						
							|  |  |  |         };
 | 
					
						
							| 
									
										
										
										
											2023-02-02 23:02:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |         let row_id = self.row_at_index(from_group_index, row_index).await.id;
 | 
					
						
							|  |  |  |         let mut row_changeset = RowChangeset::new(row_id);
 | 
					
						
							|  |  |  |         row_changeset.cell_by_field_id.insert(field_id, cell_rev);
 | 
					
						
							|  |  |  |         self.editor.update_row(row_changeset).await.unwrap();
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::MoveGroup {
 | 
					
						
							|  |  |  |         from_group_index,
 | 
					
						
							|  |  |  |         to_group_index,
 | 
					
						
							|  |  |  |       } => {
 | 
					
						
							|  |  |  |         let from_group = self.group_at_index(from_group_index).await;
 | 
					
						
							|  |  |  |         let to_group = self.group_at_index(to_group_index).await;
 | 
					
						
							|  |  |  |         let params = MoveGroupParams {
 | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  |           view_id: self.view_id.clone(),
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |           from_group_id: from_group.group_id,
 | 
					
						
							|  |  |  |           to_group_id: to_group.group_id,
 | 
					
						
							|  |  |  |         };
 | 
					
						
							|  |  |  |         self.editor.move_group(params).await.unwrap();
 | 
					
						
							|  |  |  |         //
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::AssertGroup {
 | 
					
						
							|  |  |  |         group_index,
 | 
					
						
							|  |  |  |         expected_group: group_pb,
 | 
					
						
							|  |  |  |       } => {
 | 
					
						
							|  |  |  |         let group = self.group_at_index(group_index).await;
 | 
					
						
							|  |  |  |         assert_eq!(group.group_id, group_pb.group_id);
 | 
					
						
							|  |  |  |         assert_eq!(group.desc, group_pb.desc);
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::UpdateSingleSelectSelectOption { inserted_options } => {
 | 
					
						
							|  |  |  |         self
 | 
					
						
							|  |  |  |           .edit_single_select_type_option(|type_option| {
 | 
					
						
							|  |  |  |             for inserted_option in inserted_options {
 | 
					
						
							|  |  |  |               type_option.insert_option(inserted_option);
 | 
					
						
							| 
									
										
										
										
											2022-08-24 16:57:53 +08:00
										 |  |  |             }
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |           })
 | 
					
						
							|  |  |  |           .await;
 | 
					
						
							|  |  |  |       },
 | 
					
						
							|  |  |  |       GroupScript::GroupByField { field_id } => {
 | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  |         self
 | 
					
						
							|  |  |  |           .editor
 | 
					
						
							|  |  |  |           .group_by_field(&self.view_id, &field_id)
 | 
					
						
							|  |  |  |           .await
 | 
					
						
							|  |  |  |           .unwrap();
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |       },
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  |     }
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-08-18 21:43:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   pub async fn group_at_index(&self, index: usize) -> GroupPB {
 | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  |     let groups = self.editor.load_groups(&self.view_id).await.unwrap().items;
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |     groups.get(index).unwrap().clone()
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-08-19 11:56:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   pub async fn row_at_index(&self, group_index: usize, row_index: usize) -> RowPB {
 | 
					
						
							|  |  |  |     let groups = self.group_at_index(group_index).await;
 | 
					
						
							|  |  |  |     groups.rows.get(row_index).unwrap().clone()
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-09-01 09:03:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   #[allow(dead_code)]
 | 
					
						
							|  |  |  |   pub async fn get_multi_select_field(&self) -> Arc<FieldRevision> {
 | 
					
						
							|  |  |  |     let field = self
 | 
					
						
							|  |  |  |       .inner
 | 
					
						
							|  |  |  |       .field_revs
 | 
					
						
							|  |  |  |       .iter()
 | 
					
						
							|  |  |  |       .find(|field_rev| {
 | 
					
						
							|  |  |  |         let field_type: FieldType = field_rev.ty.into();
 | 
					
						
							|  |  |  |         field_type.is_multi_select()
 | 
					
						
							|  |  |  |       })
 | 
					
						
							|  |  |  |       .unwrap()
 | 
					
						
							|  |  |  |       .clone();
 | 
					
						
							|  |  |  |     field
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-09-02 09:49:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   pub async fn get_single_select_field(&self) -> Arc<FieldRevision> {
 | 
					
						
							|  |  |  |     self
 | 
					
						
							|  |  |  |       .inner
 | 
					
						
							|  |  |  |       .field_revs
 | 
					
						
							|  |  |  |       .iter()
 | 
					
						
							|  |  |  |       .find(|field_rev| {
 | 
					
						
							|  |  |  |         let field_type: FieldType = field_rev.ty.into();
 | 
					
						
							|  |  |  |         field_type.is_single_select()
 | 
					
						
							|  |  |  |       })
 | 
					
						
							|  |  |  |       .unwrap()
 | 
					
						
							|  |  |  |       .clone()
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-09-02 09:49:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   pub async fn edit_single_select_type_option(
 | 
					
						
							|  |  |  |     &self,
 | 
					
						
							|  |  |  |     action: impl FnOnce(&mut SingleSelectTypeOptionPB),
 | 
					
						
							|  |  |  |   ) {
 | 
					
						
							|  |  |  |     let single_select = self.get_single_select_field().await;
 | 
					
						
							| 
									
										
										
										
											2023-02-26 16:27:17 +08:00
										 |  |  |     edit_single_select_type_option(
 | 
					
						
							|  |  |  |       &self.view_id,
 | 
					
						
							|  |  |  |       &single_select.id,
 | 
					
						
							|  |  |  |       self.editor.clone(),
 | 
					
						
							|  |  |  |       action,
 | 
					
						
							|  |  |  |     )
 | 
					
						
							|  |  |  |     .await
 | 
					
						
							|  |  |  |     .unwrap();
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2023-01-19 13:26:55 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   pub async fn get_url_field(&self) -> Arc<FieldRevision> {
 | 
					
						
							|  |  |  |     self
 | 
					
						
							|  |  |  |       .inner
 | 
					
						
							|  |  |  |       .field_revs
 | 
					
						
							|  |  |  |       .iter()
 | 
					
						
							|  |  |  |       .find(|field_rev| {
 | 
					
						
							|  |  |  |         let field_type: FieldType = field_rev.ty.into();
 | 
					
						
							|  |  |  |         field_type.is_url()
 | 
					
						
							|  |  |  |       })
 | 
					
						
							|  |  |  |       .unwrap()
 | 
					
						
							|  |  |  |       .clone()
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-02 23:02:49 +08:00
										 |  |  | impl std::ops::Deref for DatabaseGroupTest {
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   type Target = DatabaseEditorTest;
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   fn deref(&self) -> &Self::Target {
 | 
					
						
							|  |  |  |     &self.inner
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-02 23:02:49 +08:00
										 |  |  | impl std::ops::DerefMut for DatabaseGroupTest {
 | 
					
						
							| 
									
										
										
										
											2023-02-13 09:29:49 +08:00
										 |  |  |   fn deref_mut(&mut self) -> &mut Self::Target {
 | 
					
						
							|  |  |  |     &mut self.inner
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2022-08-18 17:40:23 +08:00
										 |  |  | }
 |