AppFlowy/frontend/rust-lib/flowy-database2/src/entities/macros.rs
Richard Shiue f0e4f3db61
chore: per-view field settings (#3199)
* 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
2023-08-27 22:31:32 +08:00

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
},
}
}
}
};
}