mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-16 13:36:07 +00:00

* feat: add flowy-database2 * chore: config type option data * chore: impl type option * feat: config group * fix: group compile * feat: add sort * chore: setting * chore: insert with specific type * chore: custom group * chore: rename any map * chore: use group setting * chore: update * chore: open database event * chore: update database editor * chore: update * chore: update view editor * chore: update * chore: update view editor * chore: sort feat * chore: update handler * chore: update * chore: config handler event * feat: impl handlers * feat: impl handlers * chore: layout setting * feat: impl handlers * chore: remove flowy-folder ref * chore: integrate flowy-database2 * feat: get cell * chore: create database with data * chore: create view * chore: fix dart compile * fix: some bugs * chore: update * chore: merge develop * chore: fix warning * chore: integrate rocksdb * fix: rocksdb compile errros * fix: update cell * chore: update the bundle identifier * fix: create row * fix: switch to field * fix: duplicate grid * test: migrate tests * test: migrate tests * test: update test * test: migrate tests * chore: add patch
56 lines
1.8 KiB
Rust
56 lines
1.8 KiB
Rust
use collab_database::fields::Field;
|
|
use flowy_database2::entities::{CreateFieldParams, FieldType};
|
|
use flowy_database2::services::field::{
|
|
type_option_to_pb, DateCellChangeset, FieldBuilder, RichTextTypeOption, SelectOption,
|
|
SingleSelectTypeOption,
|
|
};
|
|
|
|
pub fn create_text_field(grid_id: &str) -> (CreateFieldParams, Field) {
|
|
let field_type = FieldType::RichText;
|
|
let type_option = RichTextTypeOption::default();
|
|
let text_field = FieldBuilder::new(field_type.clone(), type_option.clone())
|
|
.name("Name")
|
|
.visibility(true)
|
|
.primary(true)
|
|
.build();
|
|
|
|
let type_option_data = type_option_to_pb(type_option.into(), &field_type).to_vec();
|
|
let params = CreateFieldParams {
|
|
view_id: grid_id.to_owned(),
|
|
field_type,
|
|
type_option_data: Some(type_option_data),
|
|
};
|
|
(params, text_field)
|
|
}
|
|
|
|
pub fn create_single_select_field(grid_id: &str) -> (CreateFieldParams, Field) {
|
|
let field_type = FieldType::SingleSelect;
|
|
let mut type_option = SingleSelectTypeOption::default();
|
|
type_option.options.push(SelectOption::new("Done"));
|
|
type_option.options.push(SelectOption::new("Progress"));
|
|
let single_select_field = FieldBuilder::new(field_type.clone(), type_option.clone())
|
|
.name("Name")
|
|
.visibility(true)
|
|
.build();
|
|
|
|
let type_option_data = type_option_to_pb(type_option.into(), &field_type).to_vec();
|
|
let params = CreateFieldParams {
|
|
view_id: grid_id.to_owned(),
|
|
field_type,
|
|
type_option_data: Some(type_option_data),
|
|
};
|
|
(params, single_select_field)
|
|
}
|
|
|
|
// The grid will contains all existing field types and there are three empty rows in this grid.
|
|
|
|
pub fn make_date_cell_string(s: &str) -> String {
|
|
serde_json::to_string(&DateCellChangeset {
|
|
date: Some(s.to_string()),
|
|
time: None,
|
|
is_utc: true,
|
|
include_time: Some(false),
|
|
})
|
|
.unwrap()
|
|
}
|