diff --git a/libs/shared-entity/src/dto/workspace_dto.rs b/libs/shared-entity/src/dto/workspace_dto.rs index c09beef8..94e08c2b 100644 --- a/libs/shared-entity/src/dto/workspace_dto.rs +++ b/libs/shared-entity/src/dto/workspace_dto.rs @@ -330,7 +330,7 @@ pub struct PublishedView { #[derive(Default, Debug, Clone, Serialize, Deserialize)] pub struct AFDatabase { pub id: String, - pub names: Vec, + pub views: Vec, } #[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] @@ -339,12 +339,6 @@ pub struct AFDatabaseField { pub field_type: String, } -#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -pub struct AFDatabaseMeta { - pub name: String, - pub icon: String, -} - #[derive(Default, Debug, Clone, Serialize, Deserialize)] pub struct AFDatabaseRow { pub id: String, diff --git a/src/biz/collab/ops.rs b/src/biz/collab/ops.rs index 0301cd81..051bea7e 100644 --- a/src/biz/collab/ops.rs +++ b/src/biz/collab/ops.rs @@ -24,6 +24,7 @@ use shared_entity::dto::workspace_dto::AFDatabase; use shared_entity::dto::workspace_dto::AFDatabaseRow; use shared_entity::dto::workspace_dto::AFDatabaseRowDetail; use shared_entity::dto::workspace_dto::FavoriteFolderView; +use shared_entity::dto::workspace_dto::FolderViewMinimal; use shared_entity::dto::workspace_dto::RecentFolderView; use shared_entity::dto::workspace_dto::TrashFolderView; use sqlx::PgPool; @@ -47,6 +48,7 @@ use super::folder_view::collab_folder_to_folder_view; use super::folder_view::section_items_to_favorite_folder_view; use super::folder_view::section_items_to_recent_folder_view; use super::folder_view::section_items_to_trash_folder_view; +use super::folder_view::to_dto_folder_view_miminal; use super::publish_outline::collab_folder_to_published_outline; /// Create a new collab member @@ -416,17 +418,17 @@ pub async fn list_database( let mut af_databases = Vec::with_capacity(db_metas.len()); for db_meta in db_metas { let id = db_meta.database_id; - let names: Vec = db_meta + let views: Vec = db_meta .linked_views .into_iter() .map(|view_id| { folder .get_view(&view_id) - .map(|v| v.name.clone()) + .map(|view| to_dto_folder_view_miminal(&view)) .unwrap_or_default() }) .collect(); - af_databases.push(AFDatabase { id, names }); + af_databases.push(AFDatabase { id, views }); } Ok(af_databases) @@ -572,9 +574,12 @@ fn convert_database_cells_human_readable( }, }; + println!("field_type: {:#?}", field.field_type); + println!("type_options: {:#?}", field.type_options); + let mut human_readable_cell: HashMap = HashMap::with_capacity(cell.len()); for (key, value) in cell { - let serde_value: String = match key.as_str() { + let value_str: String = match key.as_str() { "created_at" | "last_modified" => match value.cast::() { Ok(timestamp) => chrono::DateTime::from_timestamp(timestamp, 0) .unwrap_or_default() @@ -596,7 +601,7 @@ fn convert_database_cells_human_readable( }, _ => value.to_string(), }; - human_readable_cell.insert(key, serde_value); + human_readable_cell.insert(key, value_str); } human_readable_records.insert(field.name.clone(), human_readable_cell); } diff --git a/tests/workspace/workspace_crud.rs b/tests/workspace/workspace_crud.rs index d003efd5..3e9be5b3 100644 --- a/tests/workspace/workspace_crud.rs +++ b/tests/workspace/workspace_crud.rs @@ -15,8 +15,8 @@ async fn workspace_list_database() { let dbs = c.list_databases(&workspace_id).await.unwrap(); assert_eq!(dbs.len(), 1, "{:?}", dbs); let todos_db = &dbs[0]; - assert_eq!(todos_db.names.len(), 1); - assert!(todos_db.names.contains(&String::from("To-dos"))); + assert_eq!(todos_db.views.len(), 1); + assert_eq!(todos_db.views[0].name, "To-dos"); { let db_row_ids = c .list_database_row_ids(&workspace_id, &todos_db.id)