mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: show grid
This commit is contained in:
@ -63,7 +63,7 @@ pub fn create(folder: Arc<FolderManager>) -> Module {
|
||||
.event(FolderEvent::UpdateView, update_view_handler)
|
||||
.event(FolderEvent::DeleteView, delete_view_handler)
|
||||
.event(FolderEvent::DuplicateView, duplicate_view_handler)
|
||||
.event(FolderEvent::OpenView, open_view_handler)
|
||||
.event(FolderEvent::SetLatestView, set_latest_view_handler)
|
||||
.event(FolderEvent::CloseView, close_view_handler);
|
||||
|
||||
module = module
|
||||
@ -127,8 +127,8 @@ pub enum FolderEvent {
|
||||
#[event()]
|
||||
CopyLink = 206,
|
||||
|
||||
#[event(input = "ViewId", output = "BlockDelta")]
|
||||
OpenView = 207,
|
||||
#[event(input = "ViewId")]
|
||||
SetLatestView = 207,
|
||||
|
||||
#[event(input = "ViewId")]
|
||||
CloseView = 208,
|
||||
|
@ -206,9 +206,9 @@ impl DefaultFolderBuilder {
|
||||
} else {
|
||||
initial_quill_delta_string()
|
||||
};
|
||||
view_controller.set_latest_view(view);
|
||||
let _ = view_controller.set_latest_view(&view.id);
|
||||
let _ = view_controller
|
||||
.create_view(&view.id, ViewDataType::RichText, Bytes::from(view_data))
|
||||
.create_view(&view.id, ViewDataType::Block, Bytes::from(view_data))
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ pub enum FolderEvent {
|
||||
DeleteView = 204,
|
||||
DuplicateView = 205,
|
||||
CopyLink = 206,
|
||||
OpenView = 207,
|
||||
SetLatestView = 207,
|
||||
CloseView = 208,
|
||||
ReadTrash = 300,
|
||||
PutbackTrash = 301,
|
||||
@ -75,7 +75,7 @@ impl ::protobuf::ProtobufEnum for FolderEvent {
|
||||
204 => ::std::option::Option::Some(FolderEvent::DeleteView),
|
||||
205 => ::std::option::Option::Some(FolderEvent::DuplicateView),
|
||||
206 => ::std::option::Option::Some(FolderEvent::CopyLink),
|
||||
207 => ::std::option::Option::Some(FolderEvent::OpenView),
|
||||
207 => ::std::option::Option::Some(FolderEvent::SetLatestView),
|
||||
208 => ::std::option::Option::Some(FolderEvent::CloseView),
|
||||
300 => ::std::option::Option::Some(FolderEvent::ReadTrash),
|
||||
301 => ::std::option::Option::Some(FolderEvent::PutbackTrash),
|
||||
@ -106,7 +106,7 @@ impl ::protobuf::ProtobufEnum for FolderEvent {
|
||||
FolderEvent::DeleteView,
|
||||
FolderEvent::DuplicateView,
|
||||
FolderEvent::CopyLink,
|
||||
FolderEvent::OpenView,
|
||||
FolderEvent::SetLatestView,
|
||||
FolderEvent::CloseView,
|
||||
FolderEvent::ReadTrash,
|
||||
FolderEvent::PutbackTrash,
|
||||
@ -143,19 +143,19 @@ impl ::protobuf::reflect::ProtobufValue for FolderEvent {
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x0fevent_map.proto*\xd2\x03\n\x0bFolderEvent\x12\x13\n\x0fCreateWorks\
|
||||
\n\x0fevent_map.proto*\xd7\x03\n\x0bFolderEvent\x12\x13\n\x0fCreateWorks\
|
||||
pace\x10\0\x12\x14\n\x10ReadCurWorkspace\x10\x01\x12\x12\n\x0eReadWorksp\
|
||||
aces\x10\x02\x12\x13\n\x0fDeleteWorkspace\x10\x03\x12\x11\n\rOpenWorkspa\
|
||||
ce\x10\x04\x12\x15\n\x11ReadWorkspaceApps\x10\x05\x12\r\n\tCreateApp\x10\
|
||||
e\x12\r\n\tDeleteApp\x10f\x12\x0b\n\x07ReadApp\x10g\x12\r\n\tUpdateApp\
|
||||
\x10h\x12\x0f\n\nCreateView\x10\xc9\x01\x12\r\n\x08ReadView\x10\xca\x01\
|
||||
\x12\x0f\n\nUpdateView\x10\xcb\x01\x12\x0f\n\nDeleteView\x10\xcc\x01\x12\
|
||||
\x12\n\rDuplicateView\x10\xcd\x01\x12\r\n\x08CopyLink\x10\xce\x01\x12\r\
|
||||
\n\x08OpenView\x10\xcf\x01\x12\x0e\n\tCloseView\x10\xd0\x01\x12\x0e\n\tR\
|
||||
eadTrash\x10\xac\x02\x12\x11\n\x0cPutbackTrash\x10\xad\x02\x12\x10\n\x0b\
|
||||
DeleteTrash\x10\xae\x02\x12\x14\n\x0fRestoreAllTrash\x10\xaf\x02\x12\x13\
|
||||
\n\x0eDeleteAllTrash\x10\xb0\x02\x12\x12\n\rApplyDocDelta\x10\x90\x03\
|
||||
\x12\x13\n\x0eExportDocument\x10\xf4\x03b\x06proto3\
|
||||
\x12\n\rDuplicateView\x10\xcd\x01\x12\r\n\x08CopyLink\x10\xce\x01\x12\
|
||||
\x12\n\rSetLatestView\x10\xcf\x01\x12\x0e\n\tCloseView\x10\xd0\x01\x12\
|
||||
\x0e\n\tReadTrash\x10\xac\x02\x12\x11\n\x0cPutbackTrash\x10\xad\x02\x12\
|
||||
\x10\n\x0bDeleteTrash\x10\xae\x02\x12\x14\n\x0fRestoreAllTrash\x10\xaf\
|
||||
\x02\x12\x13\n\x0eDeleteAllTrash\x10\xb0\x02\x12\x12\n\rApplyDocDelta\
|
||||
\x10\x90\x03\x12\x13\n\x0eExportDocument\x10\xf4\x03b\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
@ -17,7 +17,7 @@ enum FolderEvent {
|
||||
DeleteView = 204;
|
||||
DuplicateView = 205;
|
||||
CopyLink = 206;
|
||||
OpenView = 207;
|
||||
SetLatestView = 207;
|
||||
CloseView = 208;
|
||||
ReadTrash = 300;
|
||||
PutbackTrash = 301;
|
||||
|
@ -84,8 +84,7 @@ pub(crate) struct ViewTable {
|
||||
impl ViewTable {
|
||||
pub fn new(view: View) -> Self {
|
||||
let data_type = match view.data_type {
|
||||
ViewDataType::RichText => SqlViewDataType::RichText,
|
||||
ViewDataType::PlainText => SqlViewDataType::PlainText,
|
||||
ViewDataType::Block => SqlViewDataType::Block,
|
||||
ViewDataType::Grid => SqlViewDataType::Grid,
|
||||
};
|
||||
|
||||
@ -107,8 +106,7 @@ impl ViewTable {
|
||||
impl std::convert::From<ViewTable> for View {
|
||||
fn from(table: ViewTable) -> Self {
|
||||
let data_type = match table.view_type {
|
||||
SqlViewDataType::RichText => ViewDataType::RichText,
|
||||
SqlViewDataType::PlainText => ViewDataType::PlainText,
|
||||
SqlViewDataType::Block => ViewDataType::Block,
|
||||
SqlViewDataType::Grid => ViewDataType::Grid,
|
||||
};
|
||||
|
||||
@ -179,26 +177,24 @@ impl ViewChangeset {
|
||||
#[repr(i32)]
|
||||
#[sql_type = "Integer"]
|
||||
pub enum SqlViewDataType {
|
||||
RichText = 0,
|
||||
PlainText = 1,
|
||||
Grid = 2,
|
||||
Block = 0,
|
||||
Grid = 1,
|
||||
}
|
||||
|
||||
impl std::default::Default for SqlViewDataType {
|
||||
fn default() -> Self {
|
||||
SqlViewDataType::RichText
|
||||
SqlViewDataType::Block
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<i32> for SqlViewDataType {
|
||||
fn from(value: i32) -> Self {
|
||||
match value {
|
||||
0 => SqlViewDataType::RichText,
|
||||
1 => SqlViewDataType::PlainText,
|
||||
2 => SqlViewDataType::Grid,
|
||||
0 => SqlViewDataType::Block,
|
||||
1 => SqlViewDataType::Grid,
|
||||
o => {
|
||||
log::error!("Unsupported view type {}, fallback to ViewType::Docs", o);
|
||||
SqlViewDataType::PlainText
|
||||
log::error!("Unsupported view type {}, fallback to ViewType::Block", o);
|
||||
SqlViewDataType::Block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use crate::{
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use flowy_collaboration::entities::{
|
||||
document_info::{BlockDelta, BlockId},
|
||||
document_info::BlockId,
|
||||
revision::{RepeatedRevision, Revision},
|
||||
};
|
||||
use flowy_database::kv::KV;
|
||||
@ -134,14 +134,9 @@ impl ViewController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self), err)]
|
||||
pub(crate) async fn open_view(&self, view_id: &str) -> Result<BlockDelta, FlowyError> {
|
||||
let processor = self.get_data_processor_from_view_id(view_id).await?;
|
||||
let delta_str = processor.delta_str(view_id).await?;
|
||||
pub(crate) fn set_latest_view(&self, view_id: &str) -> Result<(), FlowyError> {
|
||||
KV::set_str(LATEST_VIEW_ID, view_id.to_owned());
|
||||
Ok(BlockDelta {
|
||||
block_id: view_id.to_string(),
|
||||
delta_str,
|
||||
})
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self), err)]
|
||||
@ -231,10 +226,6 @@ impl ViewController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn set_latest_view(&self, view: &View) {
|
||||
KV::set_str(LATEST_VIEW_ID, view.id.clone());
|
||||
}
|
||||
}
|
||||
|
||||
impl ViewController {
|
||||
|
@ -8,7 +8,6 @@ use crate::{
|
||||
errors::FlowyError,
|
||||
services::{TrashController, ViewController},
|
||||
};
|
||||
use flowy_collaboration::entities::document_info::BlockDelta;
|
||||
use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
|
||||
@ -66,13 +65,13 @@ pub(crate) async fn delete_view_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn open_view_handler(
|
||||
pub(crate) async fn set_latest_view_handler(
|
||||
data: Data<ViewId>,
|
||||
controller: AppData<Arc<ViewController>>,
|
||||
) -> DataResult<BlockDelta, FlowyError> {
|
||||
) -> Result<(), FlowyError> {
|
||||
let view_id: ViewId = data.into_inner();
|
||||
let doc = controller.open_view(&view_id.value).await?;
|
||||
data_result(doc)
|
||||
let _ = controller.set_latest_view(&view_id.value)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn close_view_handler(
|
||||
|
@ -164,7 +164,7 @@ pub async fn delete_view(sdk: &FlowySDKTest, view_ids: Vec<String>) {
|
||||
pub async fn open_document(sdk: &FlowySDKTest, view_id: &str) -> BlockInfo {
|
||||
let view_id: ViewId = view_id.into();
|
||||
FolderEventBuilder::new(sdk.clone())
|
||||
.event(OpenView)
|
||||
.event(SetLatestView)
|
||||
.payload(view_id)
|
||||
.async_send()
|
||||
.await
|
||||
|
@ -68,7 +68,7 @@ impl FolderTest {
|
||||
let _ = sdk.init_user().await;
|
||||
let mut workspace = create_workspace(&sdk, "FolderWorkspace", "Folder test workspace").await;
|
||||
let mut app = create_app(&sdk, &workspace.id, "Folder App", "Folder test app").await;
|
||||
let view = create_view(&sdk, &app.id, "Folder View", "Folder test view", ViewDataType::RichText).await;
|
||||
let view = create_view(&sdk, &app.id, "Folder View", "Folder test view", ViewDataType::Block).await;
|
||||
app.belongings = RepeatedView {
|
||||
items: vec![view.clone()],
|
||||
};
|
||||
@ -146,7 +146,7 @@ impl FolderTest {
|
||||
}
|
||||
|
||||
FolderScript::CreateView { name, desc } => {
|
||||
let view = create_view(sdk, &self.app.id, &name, &desc, ViewDataType::RichText).await;
|
||||
let view = create_view(sdk, &self.app.id, &name, &desc, ViewDataType::Block).await;
|
||||
self.view = view;
|
||||
}
|
||||
FolderScript::AssertView(view) => {
|
||||
|
Reference in New Issue
Block a user