Skip to content

Commit 08883d5

Browse files
committed
chore: to string
1 parent 716188a commit 08883d5

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

collab-database/src/fields/type_option/relation_type_option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ impl TypeOptionCellReader for RelationTypeOption {
4848
impl TypeOptionCellWriter for RelationTypeOption {
4949
fn convert_json_to_cell(&self, json_value: Value) -> Cell {
5050
let cell_data = serde_json::from_value::<RelationCellData>(json_value).unwrap_or_default();
51-
Cell::from(&cell_data)
51+
Cell::from(cell_data)
5252
}
5353
}

collab-database/src/template/check_list_parse.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ use crate::template::entity::CELL_DATA;
66
use crate::template::util::TypeOptionCellData;
77
use collab::util::AnyMapExt;
88
use serde::{Deserialize, Serialize};
9-
use std::fmt;
10-
use std::fmt::{Display, Formatter};
119

1210
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1311
pub struct ChecklistCellData {
@@ -16,9 +14,14 @@ pub struct ChecklistCellData {
1614
pub selected_option_ids: Vec<String>,
1715
}
1816

19-
impl Display for ChecklistCellData {
20-
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
21-
write!(f, "{:?}", self)
17+
impl ToString for ChecklistCellData {
18+
fn to_string(&self) -> String {
19+
let selected_options: Vec<String> = self
20+
.selected_options()
21+
.iter()
22+
.map(|option| option.name.clone())
23+
.collect();
24+
selected_options.join(", ")
2225
}
2326
}
2427

collab-database/src/template/relation_parse.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ impl From<&Cell> for RelationCellData {
3737
}
3838
}
3939

40-
impl From<&RelationCellData> for Cell {
41-
fn from(value: &RelationCellData) -> Self {
40+
impl From<RelationCellData> for Cell {
41+
fn from(value: RelationCellData) -> Self {
4242
let data = Any::Array(Arc::from(
4343
value
4444
.row_ids
45-
.clone()
4645
.into_iter()
4746
.map(|id| Any::String(Arc::from(id.to_string())))
4847
.collect::<Vec<_>>(),
@@ -67,3 +66,20 @@ impl From<&str> for RelationCellData {
6766
RelationCellData { row_ids: ids }
6867
}
6968
}
69+
70+
impl From<String> for RelationCellData {
71+
fn from(s: String) -> Self {
72+
RelationCellData::from(s.as_str())
73+
}
74+
}
75+
76+
impl ToString for RelationCellData {
77+
fn to_string(&self) -> String {
78+
self
79+
.row_ids
80+
.iter()
81+
.map(|id| id.to_string())
82+
.collect::<Vec<_>>()
83+
.join(", ")
84+
}
85+
}

0 commit comments

Comments
 (0)