mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: auto resize row height
This commit is contained in:
@ -51,16 +51,16 @@ impl ClientGridBlockMetaEditor {
|
||||
let mut row_count = 0;
|
||||
let mut row_index = None;
|
||||
let _ = self
|
||||
.modify(|pad| {
|
||||
.modify(|block_pad| {
|
||||
if let Some(start_row_id) = start_row_id.as_ref() {
|
||||
match pad.index_of_row(start_row_id) {
|
||||
match block_pad.index_of_row(start_row_id) {
|
||||
None => {}
|
||||
Some(index) => row_index = Some(index + 1),
|
||||
}
|
||||
}
|
||||
|
||||
let change = pad.add_row_meta(row, start_row_id)?;
|
||||
row_count = pad.number_of_rows();
|
||||
let change = block_pad.add_row_meta(row, start_row_id)?;
|
||||
row_count = block_pad.number_of_rows();
|
||||
Ok(change)
|
||||
})
|
||||
.await?;
|
||||
@ -71,9 +71,9 @@ impl ClientGridBlockMetaEditor {
|
||||
pub async fn delete_rows(&self, ids: Vec<Cow<'_, String>>) -> FlowyResult<i32> {
|
||||
let mut row_count = 0;
|
||||
let _ = self
|
||||
.modify(|pad| {
|
||||
let changeset = pad.delete_rows(ids)?;
|
||||
row_count = pad.number_of_rows();
|
||||
.modify(|block_pad| {
|
||||
let changeset = block_pad.delete_rows(ids)?;
|
||||
row_count = block_pad.number_of_rows();
|
||||
Ok(changeset)
|
||||
})
|
||||
.await?;
|
||||
@ -81,7 +81,14 @@ impl ClientGridBlockMetaEditor {
|
||||
}
|
||||
|
||||
pub async fn update_row(&self, changeset: RowMetaChangeset) -> FlowyResult<()> {
|
||||
let _ = self.modify(|pad| Ok(pad.update_row(changeset)?)).await?;
|
||||
let _ = self.modify(|block_pad| Ok(block_pad.update_row(changeset)?)).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn move_row(&self, row_id: &str, from: usize, to: usize) -> FlowyResult<()> {
|
||||
let _ = self
|
||||
.modify(|block_pad| Ok(block_pad.move_row(row_id, from, to)?))
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -154,6 +154,32 @@ impl GridBlockMetaEditorManager {
|
||||
Ok(changesets)
|
||||
}
|
||||
|
||||
pub(crate) async fn move_row(&self, row_id: &str, from: usize, to: usize) -> FlowyResult<()> {
|
||||
let editor = self.get_editor_from_row_id(row_id).await?;
|
||||
let _ = editor.move_row(row_id, from, to).await?;
|
||||
|
||||
match editor.get_row_metas(Some(vec![Cow::Borrowed(row_id)])).await?.pop() {
|
||||
None => {}
|
||||
Some(row_meta) => {
|
||||
let row_order = RowOrder::from(&row_meta);
|
||||
let insert_row = IndexRowOrder {
|
||||
row_order: row_order.clone(),
|
||||
index: Some(to as i32),
|
||||
};
|
||||
let notified_changeset = GridRowsChangeset {
|
||||
block_id: editor.block_id.clone(),
|
||||
inserted_rows: vec![insert_row],
|
||||
deleted_rows: vec![row_order],
|
||||
updated_rows: vec![],
|
||||
};
|
||||
|
||||
let _ = self.notify_did_update_rows(notified_changeset).await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn update_cell(&self, changeset: CellChangeset) -> FlowyResult<()> {
|
||||
let row_id = changeset.row_id.clone();
|
||||
let editor = self.get_editor_from_row_id(&row_id).await?;
|
||||
|
@ -388,7 +388,7 @@ impl ClientGridEditor {
|
||||
self.move_field(¶ms.item_id, params.from_index, params.to_index)
|
||||
.await
|
||||
}
|
||||
MoveItemType::MoveRow => self.move_row(params.from_index, params.to_index, ¶ms.item_id).await,
|
||||
MoveItemType::MoveRow => self.move_row(¶ms.item_id, params.from_index, params.to_index).await,
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,9 +411,12 @@ impl ClientGridEditor {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn move_row(&self, from: i32, to: i32, row_id: &str) -> FlowyResult<()> {
|
||||
// GridRowsChangeset
|
||||
todo!()
|
||||
pub async fn move_row(&self, row_id: &str, from: i32, to: i32) -> FlowyResult<()> {
|
||||
let _ = self
|
||||
.block_meta_manager
|
||||
.move_row(row_id, from as usize, to as usize)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delta_bytes(&self) -> Bytes {
|
||||
|
Reference in New Issue
Block a user