mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: support moving group
This commit is contained in:
@ -98,6 +98,7 @@ pub struct MoveGroupPayloadPB {
|
||||
pub to_group_id: String,
|
||||
}
|
||||
|
||||
#[derive(debug, Debug)]
|
||||
pub struct MoveGroupParams {
|
||||
pub view_id: String,
|
||||
pub from_group_id: String,
|
||||
|
@ -173,6 +173,7 @@ impl GridViewRevisionEditor {
|
||||
Ok(groups.into_iter().map(GroupPB::from).collect())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", err)]
|
||||
pub(crate) async fn move_group(&self, params: MoveGroupParams) -> FlowyResult<()> {
|
||||
let _ = self
|
||||
.group_controller
|
||||
@ -180,7 +181,7 @@ impl GridViewRevisionEditor {
|
||||
.await
|
||||
.move_group(¶ms.from_group_id, ¶ms.to_group_id)?;
|
||||
match self.group_controller.read().await.get_group(¶ms.from_group_id) {
|
||||
None => {}
|
||||
None => tracing::warn!("Can not find the group with id: {}", params.from_group_id),
|
||||
Some((index, group)) => {
|
||||
let inserted_group = InsertedGroupPB {
|
||||
group: GroupPB::from(group),
|
||||
|
@ -135,6 +135,7 @@ where
|
||||
self.mut_configuration(|configuration| {
|
||||
let from_index = configuration.groups.iter().position(|group| group.id == from_id);
|
||||
let to_index = configuration.groups.iter().position(|group| group.id == to_id);
|
||||
tracing::trace!("Swap group index:{:?} with index:{:?}", from_index, to_index);
|
||||
if let (Some(from), Some(to)) = (from_index, to_index) {
|
||||
configuration.groups.swap(from, to);
|
||||
}
|
||||
|
Reference in New Issue
Block a user