mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
f0e4f3db61
* chore: field-setting entities-events-notifications * chore: update field settings * chore: add tests * chore: add docs * chore: use an enum for field visibility * chore: clippy warnings * fix: deps fields * chore: collab merge main * chore: collab ref * test: fix tests * fix: tauri bump collab rev
45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
#[macro_export]
|
|
macro_rules! impl_into_field_type {
|
|
($target: ident) => {
|
|
impl std::convert::From<$target> for FieldType {
|
|
fn from(ty: $target) -> Self {
|
|
match ty {
|
|
0 => FieldType::RichText,
|
|
1 => FieldType::Number,
|
|
2 => FieldType::DateTime,
|
|
3 => FieldType::SingleSelect,
|
|
4 => FieldType::MultiSelect,
|
|
5 => FieldType::Checkbox,
|
|
6 => FieldType::URL,
|
|
7 => FieldType::Checklist,
|
|
8 => FieldType::LastEditedTime,
|
|
9 => FieldType::CreatedTime,
|
|
_ => {
|
|
tracing::error!("🔴Can't parser FieldType from value: {}", ty);
|
|
FieldType::RichText
|
|
},
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! impl_into_field_visibility {
|
|
($target: ident) => {
|
|
impl std::convert::From<$target> for FieldVisibility {
|
|
fn from(ty: $target) -> Self {
|
|
match ty {
|
|
0 => FieldVisibility::AlwaysShown,
|
|
1 => FieldVisibility::HideWhenEmpty,
|
|
2 => FieldVisibility::AlwaysHidden,
|
|
_ => {
|
|
tracing::error!("🔴Can't parser FieldVisibility from value: {}", ty);
|
|
FieldVisibility::AlwaysShown
|
|
},
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|