Skip to content

Commit 5a30f46

Browse files
authored
feat: sort cell (#1593)
* chore: call cell decode data * chore: cache cell decoded data * chore: update cache cell data * chore: cache cell data * refactor: separate cell type option functionalities * refactor: add TypeOptionCellDataFilter trait * chore: remove unused codes * chore: fix wanrings * chore: add sort tests * chore: sort single select and multi select Co-authored-by: nathan <[email protected]>
1 parent 6a465ac commit 5a30f46

File tree

62 files changed

+1623
-844
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1623
-844
lines changed

frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_persistence.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class DateCellDataPersistence
6363

6464
CellPathPB _makeCellPath(GridCellIdentifier cellId) {
6565
return CellPathPB.create()
66-
..gridId = cellId.gridId
66+
..viewId = cellId.gridId
6767
..fieldId = cellId.fieldId
6868
..rowId = cellId.rowId;
6969
}

frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class CellService {
4646
required GridCellIdentifier cellId,
4747
}) {
4848
final payload = CellPathPB.create()
49-
..gridId = cellId.gridId
49+
..viewId = cellId.gridId
5050
..fieldId = cellId.fieldId
5151
..rowId = cellId.rowId;
5252
return GridEventGetCell(payload).send();

frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SelectOptionFFIService {
2323
return result.fold(
2424
(option) {
2525
final cellIdentifier = CellPathPB.create()
26-
..gridId = gridId
26+
..viewId = gridId
2727
..fieldId = fieldId
2828
..rowId = rowId;
2929
final payload = SelectOptionChangesetPB.create()
@@ -62,7 +62,7 @@ class SelectOptionFFIService {
6262

6363
Future<Either<SelectOptionCellDataPB, FlowyError>> getOptionContext() {
6464
final payload = CellPathPB.create()
65-
..gridId = gridId
65+
..viewId = gridId
6666
..fieldId = fieldId
6767
..rowId = rowId;
6868

@@ -87,7 +87,7 @@ class SelectOptionFFIService {
8787

8888
CellPathPB _cellIdentifier() {
8989
return CellPathPB.create()
90-
..gridId = gridId
90+
..viewId = gridId
9191
..fieldId = fieldId
9292
..rowId = rowId;
9393
}

frontend/app_flowy/lib/workspace/presentation/widgets/emoji_picker/src/emoji_lists.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2706,7 +2706,7 @@ final Map<String, String> flags = Map.fromIterables([
27062706
'Flag: Armenia',
27072707
'Flag: Angola',
27082708
'Flag: Antarctica',
2709-
'Flag: Argentina',
2709+
'Flag: argentina',
27102710
'Flag: American Samoa',
27112711
'Flag: Austria',
27122712
'Flag: Australia',
@@ -2775,7 +2775,7 @@ final Map<String, String> flags = Map.fromIterables([
27752775
'Flag: Falkland Islands',
27762776
'Flag: Micronesia',
27772777
'Flag: Faroe Islands',
2778-
'Flag: France',
2778+
'Flag: france',
27792779
'Flag: Gabon',
27802780
'Flag: United Kingdom',
27812781
'Flag: Grenada',

frontend/app_flowy/packages/appflowy_editor_plugins/lib/src/emoji_picker/src/emoji_lists.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2706,7 +2706,7 @@ final Map<String, String> flags = Map.fromIterables([
27062706
'Flag: Armenia',
27072707
'Flag: Angola',
27082708
'Flag: Antarctica',
2709-
'Flag: Argentina',
2709+
'Flag: argentina',
27102710
'Flag: American Samoa',
27112711
'Flag: Austria',
27122712
'Flag: Australia',
@@ -2775,7 +2775,7 @@ final Map<String, String> flags = Map.fromIterables([
27752775
'Flag: Falkland Islands',
27762776
'Flag: Micronesia',
27772777
'Flag: Faroe Islands',
2778-
'Flag: France',
2778+
'Flag: france',
27792779
'Flag: Gabon',
27802780
'Flag: United Kingdom',
27812781
'Flag: Grenada',

frontend/rust-lib/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/rust-lib/flowy-grid/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ futures = "0.3.15"
4545
atomic_refcell = "0.1.8"
4646
crossbeam-utils = "0.8.7"
4747
async-stream = "0.3.2"
48+
parking_lot = "0.12.1"
4849

4950
[dev-dependencies]
5051
flowy-test = { path = "../flowy-test" }

frontend/rust-lib/flowy-grid/src/entities/cell_entities.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl TryInto<CreateSelectOptionParams> for CreateSelectOptionPayloadPB {
4141
#[derive(Debug, Clone, Default, ProtoBuf)]
4242
pub struct CellPathPB {
4343
#[pb(index = 1)]
44-
pub grid_id: String,
44+
pub view_id: String,
4545

4646
#[pb(index = 2)]
4747
pub field_id: String,
@@ -50,6 +50,8 @@ pub struct CellPathPB {
5050
pub row_id: String,
5151
}
5252

53+
/// Represents as the cell identifier. It's used to locate the cell in corresponding
54+
/// view's row with the field id.
5355
pub struct CellPathParams {
5456
pub view_id: String,
5557
pub field_id: String,
@@ -60,7 +62,7 @@ impl TryInto<CellPathParams> for CellPathPB {
6062
type Error = ErrorCode;
6163

6264
fn try_into(self) -> Result<CellPathParams, Self::Error> {
63-
let grid_id = NotEmptyStr::parse(self.grid_id).map_err(|_| ErrorCode::GridIdIsEmpty)?;
65+
let grid_id = NotEmptyStr::parse(self.view_id).map_err(|_| ErrorCode::GridIdIsEmpty)?;
6466
let field_id = NotEmptyStr::parse(self.field_id).map_err(|_| ErrorCode::FieldIdIsEmpty)?;
6567
let row_id = NotEmptyStr::parse(self.row_id).map_err(|_| ErrorCode::RowIdIsEmpty)?;
6668
Ok(CellPathParams {
@@ -70,15 +72,19 @@ impl TryInto<CellPathParams> for CellPathPB {
7072
})
7173
}
7274
}
75+
76+
/// Represents as the data of the cell.
7377
#[derive(Debug, Default, ProtoBuf)]
7478
pub struct CellPB {
7579
#[pb(index = 1)]
7680
pub field_id: String,
7781

78-
// The data was encoded in field_type's data type
82+
/// Encoded the data using the helper struct `CellProtobufBlob`.
83+
/// Check out the `CellProtobufBlob` for more information.
7984
#[pb(index = 2)]
8085
pub data: Vec<u8>,
8186

87+
/// the field_type will be None if the field with field_id is not found
8288
#[pb(index = 3, one_of)]
8389
pub field_type: Option<FieldType>,
8490
}

frontend/rust-lib/flowy-grid/src/entities/filter_entities/checkbox_filter.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::services::filter::FromFilterString;
12
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
23
use flowy_error::ErrorCode;
34
use grid_rev_model::FilterRevision;
@@ -39,6 +40,18 @@ impl std::convert::TryFrom<u8> for CheckboxFilterConditionPB {
3940
}
4041
}
4142

43+
impl FromFilterString for CheckboxFilterPB {
44+
fn from_filter_rev(filter_rev: &FilterRevision) -> Self
45+
where
46+
Self: Sized,
47+
{
48+
CheckboxFilterPB {
49+
condition: CheckboxFilterConditionPB::try_from(filter_rev.condition)
50+
.unwrap_or(CheckboxFilterConditionPB::IsChecked),
51+
}
52+
}
53+
}
54+
4255
impl std::convert::From<&FilterRevision> for CheckboxFilterPB {
4356
fn from(rev: &FilterRevision) -> Self {
4457
CheckboxFilterPB {

frontend/rust-lib/flowy-grid/src/entities/filter_entities/checklist_filter.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::services::filter::FromFilterString;
12
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
23
use flowy_error::ErrorCode;
34
use grid_rev_model::FilterRevision;
@@ -39,6 +40,18 @@ impl std::convert::TryFrom<u8> for ChecklistFilterConditionPB {
3940
}
4041
}
4142

43+
impl FromFilterString for ChecklistFilterPB {
44+
fn from_filter_rev(filter_rev: &FilterRevision) -> Self
45+
where
46+
Self: Sized,
47+
{
48+
ChecklistFilterPB {
49+
condition: ChecklistFilterConditionPB::try_from(filter_rev.condition)
50+
.unwrap_or(ChecklistFilterConditionPB::IsIncomplete),
51+
}
52+
}
53+
}
54+
4255
impl std::convert::From<&FilterRevision> for ChecklistFilterPB {
4356
fn from(rev: &FilterRevision) -> Self {
4457
ChecklistFilterPB {

0 commit comments

Comments
 (0)