mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge pull request #950 from AppFlowy-IO/fix/no_status_record
chore: save move to no status card
This commit is contained in:
commit
93f4d4377a
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
const DART_LOG = "Dart_LOG";
|
const DART_LOG = "Dart_LOG";
|
||||||
|
|
||||||
class Log {
|
class Log {
|
||||||
static const enableLog = true;
|
static const enableLog = false;
|
||||||
|
|
||||||
static void info(String? message) {
|
static void info(String? message) {
|
||||||
if (enableLog) {
|
if (enableLog) {
|
||||||
|
@ -155,11 +155,12 @@ pub fn select_option_color_from_index(index: usize) -> SelectOptionColorPB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct SelectOptionIds(Vec<String>);
|
pub struct SelectOptionIds(Vec<String>);
|
||||||
|
|
||||||
impl SelectOptionIds {
|
impl SelectOptionIds {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self(vec![])
|
Self::default()
|
||||||
}
|
}
|
||||||
pub fn into_inner(self) -> Vec<String> {
|
pub fn into_inner(self) -> Vec<String> {
|
||||||
self.0
|
self.0
|
||||||
|
@ -134,7 +134,7 @@ impl GridViewManager {
|
|||||||
row_rev: Arc<RowRevision>,
|
row_rev: Arc<RowRevision>,
|
||||||
to_group_id: String,
|
to_group_id: String,
|
||||||
to_row_id: Option<String>,
|
to_row_id: Option<String>,
|
||||||
with_row_changeset: impl FnOnce(RowChangeset) -> AFFuture<()>,
|
recv_row_changeset: impl FnOnce(RowChangeset) -> AFFuture<()>,
|
||||||
) -> FlowyResult<()> {
|
) -> FlowyResult<()> {
|
||||||
let mut row_changeset = RowChangeset::new(row_rev.id.clone());
|
let mut row_changeset = RowChangeset::new(row_rev.id.clone());
|
||||||
let view_editor = self.get_default_view_editor().await?;
|
let view_editor = self.get_default_view_editor().await?;
|
||||||
@ -143,7 +143,7 @@ impl GridViewManager {
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
if !row_changeset.is_empty() {
|
if !row_changeset.is_empty() {
|
||||||
with_row_changeset(row_changeset).await;
|
recv_row_changeset(row_changeset).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
for group_changeset in group_changesets {
|
for group_changeset in group_changesets {
|
||||||
|
@ -93,16 +93,47 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn groups(&self) -> Vec<&Group> {
|
/// Returns the groups without the default group
|
||||||
|
pub(crate) fn concrete_groups(&self) -> Vec<&Group> {
|
||||||
self.groups_map.values().collect()
|
self.groups_map.values().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the all the groups that contain the default group.
|
||||||
pub(crate) fn clone_groups(&self) -> Vec<Group> {
|
pub(crate) fn clone_groups(&self) -> Vec<Group> {
|
||||||
let mut groups: Vec<Group> = self.groups_map.values().cloned().collect();
|
let mut groups: Vec<Group> = self.groups_map.values().cloned().collect();
|
||||||
groups.push(self.default_group.clone());
|
groups.push(self.default_group.clone());
|
||||||
groups
|
groups
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Iterate mut the groups. The default group will be the last one that get mutated.
|
||||||
|
pub(crate) fn iter_mut_groups(&mut self, mut each: impl FnMut(&mut Group)) {
|
||||||
|
self.groups_map.iter_mut().for_each(|(_, group)| {
|
||||||
|
each(group);
|
||||||
|
});
|
||||||
|
|
||||||
|
each(&mut self.default_group);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn move_group(&mut self, from_id: &str, to_id: &str) -> FlowyResult<()> {
|
||||||
|
let from_index = self.groups_map.get_index_of(from_id);
|
||||||
|
let to_index = self.groups_map.get_index_of(to_id);
|
||||||
|
match (from_index, to_index) {
|
||||||
|
(Some(from_index), Some(to_index)) => {
|
||||||
|
self.groups_map.swap_indices(from_index, to_index);
|
||||||
|
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);
|
||||||
|
if let (Some(from), Some(to)) = (from_index, to_index) {
|
||||||
|
configuration.groups.swap(from, to);
|
||||||
|
}
|
||||||
|
true
|
||||||
|
})?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
_ => Err(FlowyError::out_of_bounds()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn merge_groups(&mut self, groups: Vec<Group>) -> FlowyResult<Option<GroupViewChangesetPB>> {
|
pub(crate) fn merge_groups(&mut self, groups: Vec<Group>) -> FlowyResult<Option<GroupViewChangesetPB>> {
|
||||||
let MergeGroupResult {
|
let MergeGroupResult {
|
||||||
groups,
|
groups,
|
||||||
@ -154,7 +185,7 @@ where
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) async fn hide_group(&mut self, group_id: &str) -> FlowyResult<()> {
|
pub(crate) async fn hide_group(&mut self, group_id: &str) -> FlowyResult<()> {
|
||||||
self.mut_configuration_group(group_id, |group_rev| {
|
self.mut_group_rev(group_id, |group_rev| {
|
||||||
group_rev.visible = false;
|
group_rev.visible = false;
|
||||||
})?;
|
})?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -162,45 +193,18 @@ where
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) async fn show_group(&mut self, group_id: &str) -> FlowyResult<()> {
|
pub(crate) async fn show_group(&mut self, group_id: &str) -> FlowyResult<()> {
|
||||||
self.mut_configuration_group(group_id, |group_rev| {
|
self.mut_group_rev(group_id, |group_rev| {
|
||||||
group_rev.visible = true;
|
group_rev.visible = true;
|
||||||
})?;
|
})?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn iter_mut_groups(&mut self, mut each: impl FnMut(&mut Group)) {
|
|
||||||
self.groups_map.iter_mut().for_each(|(_, group)| {
|
|
||||||
each(group);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn get_mut_group(&mut self, group_id: &str) -> Option<&mut Group> {
|
|
||||||
self.groups_map.get_mut(group_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn get_mut_default_group(&mut self) -> &mut Group {
|
pub(crate) fn get_mut_default_group(&mut self) -> &mut Group {
|
||||||
&mut self.default_group
|
&mut self.default_group
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn move_group(&mut self, from_id: &str, to_id: &str) -> FlowyResult<()> {
|
pub(crate) fn get_mut_group(&mut self, group_id: &str) -> Option<&mut Group> {
|
||||||
let from_index = self.groups_map.get_index_of(from_id);
|
self.groups_map.get_mut(group_id)
|
||||||
let to_index = self.groups_map.get_index_of(to_id);
|
|
||||||
match (from_index, to_index) {
|
|
||||||
(Some(from_index), Some(to_index)) => {
|
|
||||||
self.groups_map.swap_indices(from_index, to_index);
|
|
||||||
|
|
||||||
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);
|
|
||||||
if let (Some(from), Some(to)) = (from_index, to_index) {
|
|
||||||
configuration.groups.swap(from, to);
|
|
||||||
}
|
|
||||||
true
|
|
||||||
})?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
_ => Err(FlowyError::out_of_bounds()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the index and group specified by the group_id
|
// Returns the index and group specified by the group_id
|
||||||
@ -231,22 +235,6 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mut_configuration_group(
|
|
||||||
&mut self,
|
|
||||||
group_id: &str,
|
|
||||||
mut_groups_fn: impl Fn(&mut GroupRevision),
|
|
||||||
) -> FlowyResult<()> {
|
|
||||||
self.mut_configuration(|configuration| {
|
|
||||||
match configuration.groups.iter_mut().find(|group| group.id == group_id) {
|
|
||||||
None => false,
|
|
||||||
Some(group_rev) => {
|
|
||||||
mut_groups_fn(group_rev);
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mut_configuration(
|
fn mut_configuration(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut_configuration_fn: impl FnOnce(&mut GroupConfigurationRevision) -> bool,
|
mut_configuration_fn: impl FnOnce(&mut GroupConfigurationRevision) -> bool,
|
||||||
@ -258,6 +246,18 @@ where
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mut_group_rev(&mut self, group_id: &str, mut_groups_fn: impl Fn(&mut GroupRevision)) -> FlowyResult<()> {
|
||||||
|
self.mut_configuration(|configuration| {
|
||||||
|
match configuration.groups.iter_mut().find(|group| group.id == group_id) {
|
||||||
|
None => false,
|
||||||
|
Some(group_rev) => {
|
||||||
|
mut_groups_fn(group_rev);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn merge_groups(old_groups: &[GroupRevision], groups: Vec<Group>) -> MergeGroupResult {
|
fn merge_groups(old_groups: &[GroupRevision], groups: Vec<Group>) -> MergeGroupResult {
|
||||||
|
@ -195,7 +195,7 @@ where
|
|||||||
let mut grouped_rows: Vec<GroupedRow> = vec![];
|
let mut grouped_rows: Vec<GroupedRow> = vec![];
|
||||||
let cell_bytes = decode_any_cell_data(cell_rev.data.clone(), field_rev);
|
let cell_bytes = decode_any_cell_data(cell_rev.data.clone(), field_rev);
|
||||||
let cell_data = cell_bytes.parser::<P>()?;
|
let cell_data = cell_bytes.parser::<P>()?;
|
||||||
for group in self.configuration.groups() {
|
for group in self.configuration.concrete_groups() {
|
||||||
if self.can_group(&group.content, &cell_data) {
|
if self.can_group(&group.content, &cell_data) {
|
||||||
grouped_rows.push(GroupedRow {
|
grouped_rows.push(GroupedRow {
|
||||||
row: row_rev.into(),
|
row: row_rev.into(),
|
||||||
|
Loading…
Reference in New Issue
Block a user