Skip to content

Commit 257766b

Browse files
committed
fix: select option color backward compatibility
1 parent cc31b09 commit 257766b

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ mod checklist_type_option_tests {
108108

109109
let json_value = json!({
110110
"options": [
111-
{ "id": "1", "name": "Option1", "color": 0 },
112-
{ "id": "2", "name": "Option2", "color": 1 }
111+
{ "id": "1", "name": "Option1", "color": "Pink" },
112+
{ "id": "2", "name": "Option2", "color": "LightPink" }
113113
],
114114
"selected_option_ids": ["1"]
115115
});

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ impl SelectOption {
120120
}
121121
}
122122
#[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)]
123-
#[serde(try_from = "u8", into = "u8")]
124123
#[repr(u8)]
125124
#[derive(Default)]
126125
pub enum SelectOptionColor {
@@ -553,4 +552,35 @@ mod tests {
553552
let result = select_type_option.convert_raw_cell_data(&raw_data);
554553
assert_eq!(result, "Option 1, Option 2");
555554
}
555+
556+
#[test]
557+
fn test_select_content_deser() {
558+
let js_str = r#"{
559+
"options": [
560+
{
561+
"id": "CEZD",
562+
"name": "To Do",
563+
"color": "Purple"
564+
},
565+
{
566+
"id": "TznH",
567+
"name": "Doing",
568+
"color": "Orange"
569+
},
570+
{
571+
"id": "__n6",
572+
"name": "✅ Done",
573+
"color": "Yellow"
574+
}
575+
],
576+
"disable_color": false
577+
}"#;
578+
579+
let select_ty_opt = serde_json::from_str::<SelectTypeOption>(js_str).unwrap();
580+
assert_eq!(select_ty_opt.options.len(), 3);
581+
assert_eq!(select_ty_opt.options[0].name, "To Do");
582+
assert_eq!(select_ty_opt.options[1].color, SelectOptionColor::Orange);
583+
assert_eq!(select_ty_opt.options[2].id, "__n6");
584+
assert_eq!(select_ty_opt.disable_color, false);
585+
}
556586
}

0 commit comments

Comments
 (0)