Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: rename struct property

appflowy953af350299b
diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/meta.pb.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/meta.pb.dart
index 9e730b17d2..d322e644c0 100644
--- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/meta.pb.dart
+++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/meta.pb.dart
@@ -215,7 +215,7 @@ class FieldMeta extends $pb.GeneratedMessage {
..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'frozen')
..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'visibility')
..a<$core.int>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'width', $pb.PbFieldType.O3)
- ..aOM<TypeOptionDataByFieldTypeId>(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'typeOptionByFieldTypeId', subBuilder: TypeOptionDataByFieldTypeId.create)
+ ..m<$core.String, $core.String>(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'typeOptions', entryClassName: 'FieldMeta.TypeOptionsEntry', keyFieldType: $pb.PbFieldType.OS, valueFieldType: $pb.PbFieldType.OS)
..hasRequiredFields = false
;
@@ -228,7 +228,7 @@ class FieldMeta extends $pb.GeneratedMessage {
$core.bool? frozen,
$core.bool? visibility,
$core.int? width,
- TypeOptionDataByFieldTypeId? typeOptionByFieldTypeId,
+ $core.Map<$core.String, $core.String>? typeOptions,
}) {
final _result = create();
if (id != null) {
@@ -252,8 +252,8 @@ class FieldMeta extends $pb.GeneratedMessage {
if (width != null) {
_result.width = width;
}
- if (typeOptionByFieldTypeId != null) {
- _result.typeOptionByFieldTypeId = typeOptionByFieldTypeId;
+ if (typeOptions != null) {
+ _result.typeOptions.addAll(typeOptions);
}
return _result;
}
@@ -342,56 +342,7 @@ class FieldMeta extends $pb.GeneratedMessage {
void clearWidth() => clearField(7);
@$pb.TagNumber(8)
- TypeOptionDataByFieldTypeId get typeOptionByFieldTypeId => $_getN(7);
- @$pb.TagNumber(8)
- set typeOptionByFieldTypeId(TypeOptionDataByFieldTypeId v) { setField(8, v); }
- @$pb.TagNumber(8)
- $core.bool hasTypeOptionByFieldTypeId() => $_has(7);
- @$pb.TagNumber(8)
- void clearTypeOptionByFieldTypeId() => clearField(8);
- @$pb.TagNumber(8)
- TypeOptionDataByFieldTypeId ensureTypeOptionByFieldTypeId() => $_ensure(7);
-}
-
-class TypeOptionDataByFieldTypeId extends $pb.GeneratedMessage {
- static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'TypeOptionDataByFieldTypeId', createEmptyInstance: create)
- ..m<$core.String, $core.String>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'map', entryClassName: 'TypeOptionDataByFieldTypeId.MapEntry', keyFieldType: $pb.PbFieldType.OS, valueFieldType: $pb.PbFieldType.OS)
- ..hasRequiredFields = false
- ;
-
- TypeOptionDataByFieldTypeId._() : super();
- factory TypeOptionDataByFieldTypeId({
- $core.Map<$core.String, $core.String>? map,
- }) {
- final _result = create();
- if (map != null) {
- _result.map.addAll(map);
- }
- return _result;
- }
- factory TypeOptionDataByFieldTypeId.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
- factory TypeOptionDataByFieldTypeId.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
- @$core.Deprecated(
- 'Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
- 'Will be removed in next major version')
- TypeOptionDataByFieldTypeId clone() => TypeOptionDataByFieldTypeId()..mergeFromMessage(this);
- @$core.Deprecated(
- 'Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
- 'Will be removed in next major version')
- TypeOptionDataByFieldTypeId copyWith(void Function(TypeOptionDataByFieldTypeId) updates) => super.copyWith((message) => updates(message as TypeOptionDataByFieldTypeId)) as TypeOptionDataByFieldTypeId; // ignore: deprecated_member_use
- $pb.BuilderInfo get info_ => _i;
- @$core.pragma('dart2js:noInline')
- static TypeOptionDataByFieldTypeId create() => TypeOptionDataByFieldTypeId._();
- TypeOptionDataByFieldTypeId createEmptyInstance() => create();
- static $pb.PbList<TypeOptionDataByFieldTypeId> createRepeated() => $pb.PbList<TypeOptionDataByFieldTypeId>();
- @$core.pragma('dart2js:noInline')
- static TypeOptionDataByFieldTypeId getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<TypeOptionDataByFieldTypeId>(create);
- static TypeOptionDataByFieldTypeId? _defaultInstance;
-
- @$pb.TagNumber(1)
- $core.Map<$core.String, $core.String> get map => $_getMap(0);
+ $core.Map<$core.String, $core.String> get typeOptions => $_getMap(7);
}
enum FieldChangesetPayload_OneOfName {
@@ -709,7 +660,7 @@ class RowMeta extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RowMeta', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'blockId')
- ..m<$core.String, CellMeta>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'cellByFieldId', entryClassName: 'RowMeta.CellByFieldIdEntry', keyFieldType: $pb.PbFieldType.OS, valueFieldType: $pb.PbFieldType.OM, valueCreator: CellMeta.create)
+ ..m<$core.String, CellMeta>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'cells', entryClassName: 'RowMeta.CellsEntry', keyFieldType: $pb.PbFieldType.OS, valueFieldType: $pb.PbFieldType.OM, valueCreator: CellMeta.create)
..a<$core.int>(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'height', $pb.PbFieldType.O3)
..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'visibility')
..hasRequiredFields = false
@@ -719,7 +670,7 @@ class RowMeta extends $pb.GeneratedMessage {
factory RowMeta({
$core.String? id,
$core.String? blockId,
- $core.Map<$core.String, CellMeta>? cellByFieldId,
+ $core.Map<$core.String, CellMeta>? cells,
$core.int? height,
$core.bool? visibility,
}) {
@@ -730,8 +681,8 @@ class RowMeta extends $pb.GeneratedMessage {
if (blockId != null) {
_result.blockId = blockId;
}
- if (cellByFieldId != null) {
- _result.cellByFieldId.addAll(cellByFieldId);
+ if (cells != null) {
+ _result.cells.addAll(cells);
}
if (height != null) {
_result.height = height;
@@ -781,7 +732,7 @@ class RowMeta extends $pb.GeneratedMessage {
void clearBlockId() => clearField(2);
@$pb.TagNumber(3)
- $core.Map<$core.String, CellMeta> get cellByFieldId => $_getMap(2);
+ $core.Map<$core.String, CellMeta> get cells => $_getMap(2);
@$pb.TagNumber(4)
$core.int get height => $_getIZ(3);
@@ -913,20 +864,15 @@ class RowMetaChangeset extends $pb.GeneratedMessage {
class CellMeta extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CellMeta', createEmptyInstance: create)
- ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'fieldId')
- ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data')
+ ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data')
..hasRequiredFields = false
;
CellMeta._() : super();
factory CellMeta({
- $core.String? fieldId,
$core.String? data,
}) {
final _result = create();
- if (fieldId != null) {
- _result.fieldId = fieldId;
- }
if (data != null) {
_result.data = data;
}
@@ -954,22 +900,13 @@ class CellMeta extends $pb.GeneratedMessage {
static CellMeta? _defaultInstance;
@$pb.TagNumber(1)
- $core.String get fieldId => $_getSZ(0);
+ $core.String get data => $_getSZ(0);
@$pb.TagNumber(1)
- set fieldId($core.String v) { $_setString(0, v); }
+ set data($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
- $core.bool hasFieldId() => $_has(0);
+ $core.bool hasData() => $_has(0);
@$pb.TagNumber(1)
- void clearFieldId() => clearField(1);
-
- @$pb.TagNumber(2)
- $core.String get data => $_getSZ(1);
- @$pb.TagNumber(2)
- set data($core.String v) { $_setString(1, v); }
- @$pb.TagNumber(2)
- $core.bool hasData() => $_has(1);
- @$pb.TagNumber(2)
- void clearData() => clearField(2);
+ void clearData() => clearField(1);
}
enum CellMetaChangeset_OneOfData {
diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/meta.pbjson.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/meta.pbjson.dart
index 65e813160f..71b0c1b8e0 100644
--- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/meta.pbjson.dart
+++ b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-grid-data-model/meta.pbjson.dart
@@ -69,24 +69,14 @@ const FieldMeta$json = const {
const {'1': 'frozen', '3': 5, '4': 1, '5': 8, '10': 'frozen'},
const {'1': 'visibility', '3': 6, '4': 1, '5': 8, '10': 'visibility'},
const {'1': 'width', '3': 7, '4': 1, '5': 5, '10': 'width'},
- const {'1': 'type_option_by_field_type_id', '3': 8, '4': 1, '5': 11, '6': '.TypeOptionDataByFieldTypeId', '10': 'typeOptionByFieldTypeId'},
+ const {'1': 'type_options', '3': 8, '4': 3, '5': 11, '6': '.FieldMeta.TypeOptionsEntry', '10': 'typeOptions'},
],
+ '3': const [FieldMeta_TypeOptionsEntry$json],
};
-/// Descriptor for `FieldMeta`. Decode as a `google.protobuf.DescriptorProto`.
-final $typed_data.Uint8List fieldMetaDescriptor = $convert.base64Decode('CglGaWVsZE1ldGESDgoCaWQYASABKAlSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSEgoEZGVzYxgDIAEoCVIEZGVzYxIpCgpmaWVsZF90eXBlGAQgASgOMgouRmllbGRUeXBlUglmaWVsZFR5cGUSFgoGZnJvemVuGAUgASgIUgZmcm96ZW4SHgoKdmlzaWJpbGl0eRgGIAEoCFIKdmlzaWJpbGl0eRIUCgV3aWR0aBgHIAEoBVIFd2lkdGgSWwocdHlwZV9vcHRpb25fYnlfZmllbGRfdHlwZV9pZBgIIAEoCzIcLlR5cGVPcHRpb25EYXRhQnlGaWVsZFR5cGVJZFIXdHlwZU9wdGlvbkJ5RmllbGRUeXBlSWQ=');
-@$core.Deprecated('Use typeOptionDataByFieldTypeIdDescriptor instead')
-const TypeOptionDataByFieldTypeId$json = const {
- '1': 'TypeOptionDataByFieldTypeId',
- '2': const [
- const {'1': 'map', '3': 1, '4': 3, '5': 11, '6': '.TypeOptionDataByFieldTypeId.MapEntry', '10': 'map'},
- ],
- '3': const [TypeOptionDataByFieldTypeId_MapEntry$json],
-};
-
-@$core.Deprecated('Use typeOptionDataByFieldTypeIdDescriptor instead')
-const TypeOptionDataByFieldTypeId_MapEntry$json = const {
- '1': 'MapEntry',
+@$core.Deprecated('Use fieldMetaDescriptor instead')
+const FieldMeta_TypeOptionsEntry$json = const {
+ '1': 'TypeOptionsEntry',
'2': const [
const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'},
const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'},
@@ -94,8 +84,8 @@ const TypeOptionDataByFieldTypeId_MapEntry$json = const {
'7': const {'7': true},
};
-/// Descriptor for `TypeOptionDataByFieldTypeId`. Decode as a `google.protobuf.DescriptorProto`.
-final $typed_data.Uint8List typeOptionDataByFieldTypeIdDescriptor = $convert.base64Decode('ChtUeXBlT3B0aW9uRGF0YUJ5RmllbGRUeXBlSWQSNwoDbWFwGAEgAygLMiUuVHlwZU9wdGlvbkRhdGFCeUZpZWxkVHlwZUlkLk1hcEVudHJ5UgNtYXAaNgoITWFwRW50cnkSEAoDa2V5GAEgASgJUgNrZXkSFAoFdmFsdWUYAiABKAlSBXZhbHVlOgI4AQ==');
+/// Descriptor for `FieldMeta`. Decode as a `google.protobuf.DescriptorProto`.
+final $typed_data.Uint8List fieldMetaDescriptor = $convert.base64Decode('CglGaWVsZE1ldGESDgoCaWQYASABKAlSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSEgoEZGVzYxgDIAEoCVIEZGVzYxIpCgpmaWVsZF90eXBlGAQgASgOMgouRmllbGRUeXBlUglmaWVsZFR5cGUSFgoGZnJvemVuGAUgASgIUgZmcm96ZW4SHgoKdmlzaWJpbGl0eRgGIAEoCFIKdmlzaWJpbGl0eRIUCgV3aWR0aBgHIAEoBVIFd2lkdGgSPgoMdHlwZV9vcHRpb25zGAggAygLMhsuRmllbGRNZXRhLlR5cGVPcHRpb25zRW50cnlSC3R5cGVPcHRpb25zGj4KEFR5cGVPcHRpb25zRW50cnkSEAoDa2V5GAEgASgJUgNrZXkSFAoFdmFsdWUYAiABKAlSBXZhbHVlOgI4AQ==');
@$core.Deprecated('Use fieldChangesetPayloadDescriptor instead')
const FieldChangesetPayload$json = const {
'1': 'FieldChangesetPayload',
@@ -140,16 +130,16 @@ const RowMeta$json = const {
'2': const [
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
const {'1': 'block_id', '3': 2, '4': 1, '5': 9, '10': 'blockId'},
- const {'1': 'cell_by_field_id', '3': 3, '4': 3, '5': 11, '6': '.RowMeta.CellByFieldIdEntry', '10': 'cellByFieldId'},
+ const {'1': 'cells', '3': 3, '4': 3, '5': 11, '6': '.RowMeta.CellsEntry', '10': 'cells'},
const {'1': 'height', '3': 4, '4': 1, '5': 5, '10': 'height'},
const {'1': 'visibility', '3': 5, '4': 1, '5': 8, '10': 'visibility'},
],
- '3': const [RowMeta_CellByFieldIdEntry$json],
+ '3': const [RowMeta_CellsEntry$json],
};
@$core.Deprecated('Use rowMetaDescriptor instead')
-const RowMeta_CellByFieldIdEntry$json = const {
- '1': 'CellByFieldIdEntry',
+const RowMeta_CellsEntry$json = const {
+ '1': 'CellsEntry',
'2': const [
const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'},
const {'1': 'value', '3': 2, '4': 1, '5': 11, '6': '.CellMeta', '10': 'value'},
@@ -158,7 +148,7 @@ const RowMeta_CellByFieldIdEntry$json = const {
};
/// Descriptor for `RowMeta`. Decode as a `google.protobuf.DescriptorProto`.
-final $typed_data.Uint8List rowMetaDescriptor = $convert.base64Decode('CgdSb3dNZXRhEg4KAmlkGAEgASgJUgJpZBIZCghibG9ja19pZBgCIAEoCVIHYmxvY2tJZBJEChBjZWxsX2J5X2ZpZWxkX2lkGAMgAygLMhsuUm93TWV0YS5DZWxsQnlGaWVsZElkRW50cnlSDWNlbGxCeUZpZWxkSWQSFgoGaGVpZ2h0GAQgASgFUgZoZWlnaHQSHgoKdmlzaWJpbGl0eRgFIAEoCFIKdmlzaWJpbGl0eRpLChJDZWxsQnlGaWVsZElkRW50cnkSEAoDa2V5GAEgASgJUgNrZXkSHwoFdmFsdWUYAiABKAsyCS5DZWxsTWV0YVIFdmFsdWU6AjgB');
+final $typed_data.Uint8List rowMetaDescriptor = $convert.base64Decode('CgdSb3dNZXRhEg4KAmlkGAEgASgJUgJpZBIZCghibG9ja19pZBgCIAEoCVIHYmxvY2tJZBIpCgVjZWxscxgDIAMoCzITLlJvd01ldGEuQ2VsbHNFbnRyeVIFY2VsbHMSFgoGaGVpZ2h0GAQgASgFUgZoZWlnaHQSHgoKdmlzaWJpbGl0eRgFIAEoCFIKdmlzaWJpbGl0eRpDCgpDZWxsc0VudHJ5EhAKA2tleRgBIAEoCVIDa2V5Eh8KBXZhbHVlGAIgASgLMgkuQ2VsbE1ldGFSBXZhbHVlOgI4AQ==');
@$core.Deprecated('Use rowMetaChangesetDescriptor instead')
const RowMetaChangeset$json = const {
'1': 'RowMetaChangeset',
@@ -191,13 +181,12 @@ final $typed_data.Uint8List rowMetaChangesetDescriptor = $convert.base64Decode('
const CellMeta$json = const {
'1': 'CellMeta',
'2': const [
- const {'1': 'field_id', '3': 1, '4': 1, '5': 9, '10': 'fieldId'},
- const {'1': 'data', '3': 2, '4': 1, '5': 9, '10': 'data'},
+ const {'1': 'data', '3': 1, '4': 1, '5': 9, '10': 'data'},
],
};
/// Descriptor for `CellMeta`. Decode as a `google.protobuf.DescriptorProto`.
-final $typed_data.Uint8List cellMetaDescriptor = $convert.base64Decode('CghDZWxsTWV0YRIZCghmaWVsZF9pZBgBIAEoCVIHZmllbGRJZBISCgRkYXRhGAIgASgJUgRkYXRh');
+final $typed_data.Uint8List cellMetaDescriptor = $convert.base64Decode('CghDZWxsTWV0YRISCgRkYXRhGAEgASgJUgRkYXRh');
@$core.Deprecated('Use cellMetaChangesetDescriptor instead')
const CellMetaChangeset$json = const {
'1': 'CellMetaChangeset',
diff --git a/frontend/rust-lib/dart-ffi/Cargo.toml b/frontend/rust-lib/dart-ffi/Cargo.toml
index 143dc76b1e..df26694331 100644
--- a/frontend/rust-lib/dart-ffi/Cargo.toml
+++ b/frontend/rust-lib/dart-ffi/Cargo.toml
@@ -8,7 +8,7 @@ edition = "2018"
name = "dart_ffi"
# this value will change depending on the target os
# default static lib
-crate-type = ["cdylib"]
+crate-type = ["staticlib"]
[dependencies]
diff --git a/frontend/rust-lib/flowy-grid/src/services/field/field_builder.rs b/frontend/rust-lib/flowy-grid/src/services/field/field_builder.rs
index 9a654d4c43..d18e6aa07f 100644
--- a/frontend/rust-lib/flowy-grid/src/services/field/field_builder.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/field/field_builder.rs
@@ -1,6 +1,7 @@
use crate::services::field::type_options::*;
use bytes::Bytes;
-use flowy_grid_data_model::entities::{Field, FieldMeta, FieldType, TypeOptionDataByFieldTypeId, TypeOptionDataEntry};
+use flowy_grid_data_model::entities::{Field, FieldMeta, FieldType, TypeOptionDataEntry};
+use std::collections::HashMap;
pub struct FieldBuilder {
field_meta: FieldMeta,
@@ -33,7 +34,7 @@ impl FieldBuilder {
frozen: field.frozen,
visibility: field.visibility,
width: field.width,
- type_option_by_field_type_id: TypeOptionDataByFieldTypeId::default(),
+ type_options: HashMap::default(),
};
Self {
field_meta,
diff --git a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs
index 94f499fea1..b934d4bc35 100644
--- a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs
@@ -279,7 +279,7 @@ impl ClientGridEditor {
match row_meta {
None => Ok(None),
Some(row_meta) => {
- let cell_meta = row_meta.cell_by_field_id.get(field_id).cloned();
+ let cell_meta = row_meta.cells.get(field_id).cloned();
Ok(cell_meta)
}
}
diff --git a/frontend/rust-lib/flowy-grid/src/services/row/row_builder.rs b/frontend/rust-lib/flowy-grid/src/services/row/row_builder.rs
index 0a0da4df57..2e6970d2c9 100644
--- a/frontend/rust-lib/flowy-grid/src/services/row/row_builder.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/row/row_builder.rs
@@ -38,7 +38,7 @@ impl<'a> CreateRowMetaBuilder<'a> {
}
Some(field_meta) => {
let data = apply_cell_data_changeset(&data, None, field_meta)?;
- let cell = CellMeta::new(field_id, data);
+ let cell = CellMeta::new(data);
self.payload.cell_by_field_id.insert(field_id.to_owned(), cell);
Ok(())
}
@@ -54,7 +54,7 @@ impl<'a> CreateRowMetaBuilder<'a> {
Some(field_meta) => {
let cell_data = SelectOptionCellChangeset::from_insert(&data).cell_data();
let data = apply_cell_data_changeset(&cell_data, None, field_meta)?;
- let cell = CellMeta::new(field_id, data);
+ let cell = CellMeta::new(data);
self.payload.cell_by_field_id.insert(field_id.to_owned(), cell);
Ok(())
}
@@ -82,7 +82,7 @@ pub fn make_row_meta_from_context(block_id: &str, payload: CreateRowMetaPayload)
RowMeta {
id: payload.row_id,
block_id: block_id.to_owned(),
- cell_by_field_id: payload.cell_by_field_id,
+ cells: payload.cell_by_field_id,
height: payload.height,
visibility: payload.visibility,
}
diff --git a/frontend/rust-lib/flowy-grid/src/services/row/row_loader.rs b/frontend/rust-lib/flowy-grid/src/services/row/row_loader.rs
index b37d937c0f..89f7db216c 100644
--- a/frontend/rust-lib/flowy-grid/src/services/row/row_loader.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/row/row_loader.rs
@@ -61,7 +61,7 @@ pub fn make_cell_by_field_id(
#[allow(dead_code)]
pub fn make_cell(field_id: &str, field_meta: &FieldMeta, row_meta: &RowMeta) -> Option<Cell> {
- let cell_meta = row_meta.cell_by_field_id.get(field_id)?.clone();
+ let cell_meta = row_meta.cells.get(field_id)?.clone();
match decode_cell_data(cell_meta.data, field_meta) {
Ok(content) => Some(Cell::new(field_id, content)),
Err(e) => {
@@ -83,7 +83,7 @@ pub(crate) fn make_rows_from_row_metas(fields: &[FieldMeta], row_metas: &[Arc<Ro
let make_row = |row_meta: &Arc<RowMeta>| {
let cell_by_field_id = row_meta
- .cell_by_field_id
+ .cells
.clone()
.into_par_iter()
.flat_map(|(field_id, cell_meta)| make_cell_by_field_id(&field_meta_map, field_id, cell_meta))
diff --git a/shared-lib/flowy-grid-data-model/src/entities/meta.rs b/shared-lib/flowy-grid-data-model/src/entities/meta.rs
index cf48a70823..a170e9c4d4 100644
--- a/shared-lib/flowy-grid-data-model/src/entities/meta.rs
+++ b/shared-lib/flowy-grid-data-model/src/entities/meta.rs
@@ -101,7 +101,10 @@ pub struct FieldMeta {
pub width: i32,
#[pb(index = 8)]
- pub type_option_by_field_type_id: TypeOptionDataByFieldTypeId,
+ /// type_options contains key/value pairs
+ /// key: id of the FieldType
+ /// value: type option data string
+ pub type_options: HashMap<String, String>,
}
impl FieldMeta {
@@ -114,31 +117,28 @@ impl FieldMeta {
frozen: false,
visibility: true,
width: DEFAULT_FIELD_WIDTH,
- type_option_by_field_type_id: Default::default(),
+ type_options: Default::default(),
}
}
pub fn insert_type_option_entry<T: TypeOptionDataEntry + ?Sized>(&mut self, entry: &T) {
- self.type_option_by_field_type_id
- .insert(entry.field_type().type_id(), entry.json_str());
+ self.type_options.insert(entry.field_type().type_id(), entry.json_str());
}
pub fn get_type_option_entry<T: TypeOptionDataEntity>(&self, field_type: Option<FieldType>) -> Option<T> {
let field_type = field_type.as_ref().unwrap_or(&self.field_type);
- self.type_option_by_field_type_id
+ self.type_options
.get(&field_type.type_id())
.map(|s| T::from_json_str(s))
}
pub fn insert_type_option_str(&mut self, field_type: &FieldType, json_str: String) {
- self.type_option_by_field_type_id.insert(field_type.type_id(), json_str);
+ self.type_options.insert(field_type.type_id(), json_str);
}
pub fn get_type_option_str(&self, field_type: Option<FieldType>) -> Option<String> {
let field_type = field_type.as_ref().unwrap_or(&self.field_type);
- self.type_option_by_field_type_id
- .get(&field_type.type_id())
- .map(|s| s.to_owned())
+ self.type_options.get(&field_type.type_id()).map(|s| s.to_owned())
}
}
@@ -153,26 +153,6 @@ pub trait TypeOptionDataEntity {
fn from_protobuf_bytes(bytes: Bytes) -> Self;
}
-#[derive(Debug, Clone, Serialize, Deserialize, Default, ProtoBuf, PartialEq, Eq)]
-pub struct TypeOptionDataByFieldTypeId {
- #[pb(index = 1)]
- pub map: HashMap<String, String>,
-}
-
-impl std::ops::Deref for TypeOptionDataByFieldTypeId {
- type Target = HashMap<String, String>;
-
- fn deref(&self) -> &Self::Target {
- &self.map
- }
-}
-
-impl std::ops::DerefMut for TypeOptionDataByFieldTypeId {
- fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.map
- }
-}
-
#[derive(Debug, Clone, Default, ProtoBuf)]
pub struct FieldChangesetPayload {
#[pb(index = 1)]
@@ -321,7 +301,10 @@ pub struct RowMeta {
pub block_id: String,
#[pb(index = 3)]
- pub cell_by_field_id: HashMap<String, CellMeta>,
+ /// cells contains key/value pairs.
+ /// key: field id,
+ /// value: CellMeta
+ pub cells: HashMap<String, CellMeta>,
#[pb(index = 4)]
pub height: i32,
@@ -335,7 +318,7 @@ impl RowMeta {
Self {
id: uuid::Uuid::new_v4().to_string(),
block_id: block_id.to_owned(),
- cell_by_field_id: Default::default(),
+ cells: Default::default(),
height: DEFAULT_ROW_HEIGHT,
visibility: true,
}
@@ -360,18 +343,12 @@ pub struct RowMetaChangeset {
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, ProtoBuf)]
pub struct CellMeta {
#[pb(index = 1)]
- pub field_id: String,
-
- #[pb(index = 2)]
pub data: String,
}
impl CellMeta {
- pub fn new(field_id: &str, data: String) -> Self {
- Self {
- field_id: field_id.to_string(),
- data,
- }
+ pub fn new(data: String) -> Self {
+ Self { data }
}
}
@@ -395,7 +372,6 @@ impl std::convert::From<CellMetaChangeset> for RowMetaChangeset {
let mut cell_by_field_id = HashMap::with_capacity(1);
let field_id = changeset.field_id;
let cell_meta = CellMeta {
- field_id: field_id.clone(),
data: changeset.data.unwrap_or_else(|| "".to_owned()),
};
cell_by_field_id.insert(field_id, cell_meta);
@@ -404,7 +380,7 @@ impl std::convert::From<CellMetaChangeset> for RowMetaChangeset {
row_id: changeset.row_id,
height: None,
visibility: None,
- cell_by_field_id,
+ cell_by_field_id: cell_by_field_id,
}
}
}
diff --git a/shared-lib/flowy-grid-data-model/src/protobuf/model/meta.rs b/shared-lib/flowy-grid-data-model/src/protobuf/model/meta.rs
index 97e14eb738..f90832a447 100644
--- a/shared-lib/flowy-grid-data-model/src/protobuf/model/meta.rs
+++ b/shared-lib/flowy-grid-data-model/src/protobuf/model/meta.rs
@@ -727,7 +727,7 @@ pub struct FieldMeta {
pub frozen: bool,
pub visibility: bool,
pub width: i32,
- pub type_option_by_field_type_id: ::protobuf::SingularPtrField<TypeOptionDataByFieldTypeId>,
+ pub type_options: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
@@ -882,47 +882,34 @@ impl FieldMeta {
self.width = v;
}
- // .TypeOptionDataByFieldTypeId type_option_by_field_type_id = 8;
+ // repeated .FieldMeta.TypeOptionsEntry type_options = 8;
- pub fn get_type_option_by_field_type_id(&self) -> &TypeOptionDataByFieldTypeId {
- self.type_option_by_field_type_id.as_ref().unwrap_or_else(|| <TypeOptionDataByFieldTypeId as ::protobuf::Message>::default_instance())
+ pub fn get_type_options(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> {
+ &self.type_options
}
- pub fn clear_type_option_by_field_type_id(&mut self) {
- self.type_option_by_field_type_id.clear();
- }
-
- pub fn has_type_option_by_field_type_id(&self) -> bool {
- self.type_option_by_field_type_id.is_some()
+ pub fn clear_type_options(&mut self) {
+ self.type_options.clear();
}
// Param is passed by value, moved
- pub fn set_type_option_by_field_type_id(&mut self, v: TypeOptionDataByFieldTypeId) {
- self.type_option_by_field_type_id = ::protobuf::SingularPtrField::some(v);
+ pub fn set_type_options(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) {
+ self.type_options = v;
}
// Mutable pointer to the field.
- // If field is not initialized, it is initialized with default value first.
- pub fn mut_type_option_by_field_type_id(&mut self) -> &mut TypeOptionDataByFieldTypeId {
- if self.type_option_by_field_type_id.is_none() {
- self.type_option_by_field_type_id.set_default();
- }
- self.type_option_by_field_type_id.as_mut().unwrap()
+ pub fn mut_type_options(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> {
+ &mut self.type_options
}
// Take field
- pub fn take_type_option_by_field_type_id(&mut self) -> TypeOptionDataByFieldTypeId {
- self.type_option_by_field_type_id.take().unwrap_or_else(|| TypeOptionDataByFieldTypeId::new())
+ pub fn take_type_options(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> {
+ ::std::mem::replace(&mut self.type_options, ::std::collections::HashMap::new())
}
}
impl ::protobuf::Message for FieldMeta {
fn is_initialized(&self) -> bool {
- for v in &self.type_option_by_field_type_id {
- if !v.is_initialized() {
- return false;
- }
- };
true
}
@@ -964,7 +951,7 @@ impl ::protobuf::Message for FieldMeta {
self.width = tmp;
},
8 => {
- ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.type_option_by_field_type_id)?;
+ ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(wire_type, is, &mut self.type_options)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
@@ -999,10 +986,7 @@ impl ::protobuf::Message for FieldMeta {
if self.width != 0 {
my_size += ::protobuf::rt::value_size(7, self.width, ::protobuf::wire_format::WireTypeVarint);
}
- if let Some(ref v) = self.type_option_by_field_type_id.as_ref() {
- let len = v.compute_size();
- my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len;
- }
+ my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(8, &self.type_options);
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
@@ -1030,11 +1014,7 @@ impl ::protobuf::Message for FieldMeta {
if self.width != 0 {
os.write_int32(7, self.width)?;
}
- if let Some(ref v) = self.type_option_by_field_type_id.as_ref() {
- os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?;
- os.write_raw_varint32(v.get_cached_size())?;
- v.write_to_with_cached_sizes(os)?;
- }
+ ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(8, &self.type_options, os)?;
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
@@ -1108,10 +1088,10 @@ impl ::protobuf::Message for FieldMeta {
|m: &FieldMeta| { &m.width },
|m: &mut FieldMeta| { &mut m.width },
));
- fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<TypeOptionDataByFieldTypeId>>(
- "type_option_by_field_type_id",
- |m: &FieldMeta| { &m.type_option_by_field_type_id },
- |m: &mut FieldMeta| { &mut m.type_option_by_field_type_id },
+ fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(
+ "type_options",
+ |m: &FieldMeta| { &m.type_options },
+ |m: &mut FieldMeta| { &mut m.type_options },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<FieldMeta>(
"FieldMeta",
@@ -1136,7 +1116,7 @@ impl ::protobuf::Clear for FieldMeta {
self.frozen = false;
self.visibility = false;
self.width = 0;
- self.type_option_by_field_type_id.clear();
+ self.type_options.clear();
self.unknown_fields.clear();
}
}
@@ -1153,160 +1133,6 @@ impl ::protobuf::reflect::ProtobufValue for FieldMeta {
}
}
-#[derive(PartialEq,Clone,Default)]
-pub struct TypeOptionDataByFieldTypeId {
- // message fields
- pub map: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
- // special fields
- pub unknown_fields: ::protobuf::UnknownFields,
- pub cached_size: ::protobuf::CachedSize,
-}
-
-impl<'a> ::std::default::Default for &'a TypeOptionDataByFieldTypeId {
- fn default() -> &'a TypeOptionDataByFieldTypeId {
- <TypeOptionDataByFieldTypeId as ::protobuf::Message>::default_instance()
- }
-}
-
-impl TypeOptionDataByFieldTypeId {
- pub fn new() -> TypeOptionDataByFieldTypeId {
- ::std::default::Default::default()
- }
-
- // repeated .TypeOptionDataByFieldTypeId.MapEntry map = 1;
-
-
- pub fn get_map(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> {
- &self.map
- }
- pub fn clear_map(&mut self) {
- self.map.clear();
- }
-
- // Param is passed by value, moved
- pub fn set_map(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) {
- self.map = v;
- }
-
- // Mutable pointer to the field.
- pub fn mut_map(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> {
- &mut self.map
- }
-
- // Take field
- pub fn take_map(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> {
- ::std::mem::replace(&mut self.map, ::std::collections::HashMap::new())
- }
-}
-
-impl ::protobuf::Message for TypeOptionDataByFieldTypeId {
- fn is_initialized(&self) -> bool {
- true
- }
-
- fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
- while !is.eof()? {
- let (field_number, wire_type) = is.read_tag_unpack()?;
- match field_number {
- 1 => {
- ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(wire_type, is, &mut self.map)?;
- },
- _ => {
- ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
- },
- };
- }
- ::std::result::Result::Ok(())
- }
-
- // Compute sizes of nested messages
- #[allow(unused_variables)]
- fn compute_size(&self) -> u32 {
- let mut my_size = 0;
- my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.map);
- my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
- self.cached_size.set(my_size);
- my_size
- }
-
- fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
- ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(1, &self.map, os)?;
- os.write_unknown_fields(self.get_unknown_fields())?;
- ::std::result::Result::Ok(())
- }
-
- fn get_cached_size(&self) -> u32 {
- self.cached_size.get()
- }
-
- fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
- &self.unknown_fields
- }
-
- fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
- &mut self.unknown_fields
- }
-
- fn as_any(&self) -> &dyn (::std::any::Any) {
- self as &dyn (::std::any::Any)
- }
- fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
- self as &mut dyn (::std::any::Any)
- }
- fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
- self
- }
-
- fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
- Self::descriptor_static()
- }
-
- fn new() -> TypeOptionDataByFieldTypeId {
- TypeOptionDataByFieldTypeId::new()
- }
-
- fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
- static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
- descriptor.get(|| {
- let mut fields = ::std::vec::Vec::new();
- fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(
- "map",
- |m: &TypeOptionDataByFieldTypeId| { &m.map },
- |m: &mut TypeOptionDataByFieldTypeId| { &mut m.map },
- ));
- ::protobuf::reflect::MessageDescriptor::new_pb_name::<TypeOptionDataByFieldTypeId>(
- "TypeOptionDataByFieldTypeId",
- fields,
- file_descriptor_proto()
- )
- })
- }
-
- fn default_instance() -> &'static TypeOptionDataByFieldTypeId {
- static instance: ::protobuf::rt::LazyV2<TypeOptionDataByFieldTypeId> = ::protobuf::rt::LazyV2::INIT;
- instance.get(TypeOptionDataByFieldTypeId::new)
- }
-}
-
-impl ::protobuf::Clear for TypeOptionDataByFieldTypeId {
- fn clear(&mut self) {
- self.map.clear();
- self.unknown_fields.clear();
- }
-}
-
-impl ::std::fmt::Debug for TypeOptionDataByFieldTypeId {
- fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
- ::protobuf::text_format::fmt(self, f)
- }
-}
-
-impl ::protobuf::reflect::ProtobufValue for TypeOptionDataByFieldTypeId {
- fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
- ::protobuf::reflect::ReflectValueRef::Message(self)
- }
-}
-
#[derive(PartialEq,Clone,Default)]
pub struct FieldChangesetPayload {
// message fields
@@ -2186,7 +2012,7 @@ pub struct RowMeta {
// message fields
pub id: ::std::string::String,
pub block_id: ::std::string::String,
- pub cell_by_field_id: ::std::collections::HashMap<::std::string::String, CellMeta>,
+ pub cells: ::std::collections::HashMap<::std::string::String, CellMeta>,
pub height: i32,
pub visibility: bool,
// special fields
@@ -2257,29 +2083,29 @@ impl RowMeta {
::std::mem::replace(&mut self.block_id, ::std::string::String::new())
}
- // repeated .RowMeta.CellByFieldIdEntry cell_by_field_id = 3;
+ // repeated .RowMeta.CellsEntry cells = 3;
- pub fn get_cell_by_field_id(&self) -> &::std::collections::HashMap<::std::string::String, CellMeta> {
- &self.cell_by_field_id
+ pub fn get_cells(&self) -> &::std::collections::HashMap<::std::string::String, CellMeta> {
+ &self.cells
}
- pub fn clear_cell_by_field_id(&mut self) {
- self.cell_by_field_id.clear();
+ pub fn clear_cells(&mut self) {
+ self.cells.clear();
}
// Param is passed by value, moved
- pub fn set_cell_by_field_id(&mut self, v: ::std::collections::HashMap<::std::string::String, CellMeta>) {
- self.cell_by_field_id = v;
+ pub fn set_cells(&mut self, v: ::std::collections::HashMap<::std::string::String, CellMeta>) {
+ self.cells = v;
}
// Mutable pointer to the field.
- pub fn mut_cell_by_field_id(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, CellMeta> {
- &mut self.cell_by_field_id
+ pub fn mut_cells(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, CellMeta> {
+ &mut self.cells
}
// Take field
- pub fn take_cell_by_field_id(&mut self) -> ::std::collections::HashMap<::std::string::String, CellMeta> {
- ::std::mem::replace(&mut self.cell_by_field_id, ::std::collections::HashMap::new())
+ pub fn take_cells(&mut self) -> ::std::collections::HashMap<::std::string::String, CellMeta> {
+ ::std::mem::replace(&mut self.cells, ::std::collections::HashMap::new())
}
// int32 height = 4;
@@ -2329,7 +2155,7 @@ impl ::protobuf::Message for RowMeta {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.block_id)?;
},
3 => {
- ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage<CellMeta>>(wire_type, is, &mut self.cell_by_field_id)?;
+ ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage<CellMeta>>(wire_type, is, &mut self.cells)?;
},
4 => {
if wire_type != ::protobuf::wire_format::WireTypeVarint {
@@ -2363,7 +2189,7 @@ impl ::protobuf::Message for RowMeta {
if !self.block_id.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.block_id);
}
- my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage<CellMeta>>(3, &self.cell_by_field_id);
+ my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage<CellMeta>>(3, &self.cells);
if self.height != 0 {
my_size += ::protobuf::rt::value_size(4, self.height, ::protobuf::wire_format::WireTypeVarint);
}
@@ -2382,7 +2208,7 @@ impl ::protobuf::Message for RowMeta {
if !self.block_id.is_empty() {
os.write_string(2, &self.block_id)?;
}
- ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage<CellMeta>>(3, &self.cell_by_field_id, os)?;
+ ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage<CellMeta>>(3, &self.cells, os)?;
if self.height != 0 {
os.write_int32(4, self.height)?;
}
@@ -2438,9 +2264,9 @@ impl ::protobuf::Message for RowMeta {
|m: &mut RowMeta| { &mut m.block_id },
));
fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage<CellMeta>>(
- "cell_by_field_id",
- |m: &RowMeta| { &m.cell_by_field_id },
- |m: &mut RowMeta| { &mut m.cell_by_field_id },
+ "cells",
+ |m: &RowMeta| { &m.cells },
+ |m: &mut RowMeta| { &mut m.cells },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>(
"height",
@@ -2470,7 +2296,7 @@ impl ::protobuf::Clear for RowMeta {
fn clear(&mut self) {
self.id.clear();
self.block_id.clear();
- self.cell_by_field_id.clear();
+ self.cells.clear();
self.height = 0;
self.visibility = false;
self.unknown_fields.clear();
@@ -2803,7 +2629,6 @@ impl ::protobuf::reflect::ProtobufValue for RowMetaChangeset {
#[derive(PartialEq,Clone,Default)]
pub struct CellMeta {
// message fields
- pub field_id: ::std::string::String,
pub data: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
@@ -2821,33 +2646,7 @@ impl CellMeta {
::std::default::Default::default()
}
- // string field_id = 1;
-
-
- pub fn get_field_id(&self) -> &str {
- &self.field_id
- }
- pub fn clear_field_id(&mut self) {
- self.field_id.clear();
- }
-
- // Param is passed by value, moved
- pub fn set_field_id(&mut self, v: ::std::string::String) {
- self.field_id = v;
- }
-
- // Mutable pointer to the field.
- // If field is not initialized, it is initialized with default value first.
- pub fn mut_field_id(&mut self) -> &mut ::std::string::String {
- &mut self.field_id
- }
-
- // Take field
- pub fn take_field_id(&mut self) -> ::std::string::String {
- ::std::mem::replace(&mut self.field_id, ::std::string::String::new())
- }
-
- // string data = 2;
+ // string data = 1;
pub fn get_data(&self) -> &str {
@@ -2884,9 +2683,6 @@ impl ::protobuf::Message for CellMeta {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
- ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.field_id)?;
- },
- 2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.data)?;
},
_ => {
@@ -2901,11 +2697,8 @@ impl ::protobuf::Message for CellMeta {
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
- if !self.field_id.is_empty() {
- my_size += ::protobuf::rt::string_size(1, &self.field_id);
- }
if !self.data.is_empty() {
- my_size += ::protobuf::rt::string_size(2, &self.data);
+ my_size += ::protobuf::rt::string_size(1, &self.data);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
@@ -2913,11 +2706,8 @@ impl ::protobuf::Message for CellMeta {
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
- if !self.field_id.is_empty() {
- os.write_string(1, &self.field_id)?;
- }
if !self.data.is_empty() {
- os.write_string(2, &self.data)?;
+ os.write_string(1, &self.data)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
@@ -2957,11 +2747,6 @@ impl ::protobuf::Message for CellMeta {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
- fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
- "field_id",
- |m: &CellMeta| { &m.field_id },
- |m: &mut CellMeta| { &mut m.field_id },
- ));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"data",
|m: &CellMeta| { &m.data },
@@ -2983,7 +2768,6 @@ impl ::protobuf::Message for CellMeta {
impl ::protobuf::Clear for CellMeta {
fn clear(&mut self) {
- self.field_id.clear();
self.data.clear();
self.unknown_fields.clear();
}
@@ -3676,55 +3460,52 @@ static file_descriptor_proto_data: &'static [u8] = b"\
ockId\x12&\n\x0fstart_row_index\x18\x02\x20\x01(\x05R\rstartRowIndex\x12\
\x1b\n\trow_count\x18\x03\x20\x01(\x05R\x08rowCount\"U\n\x11GridBlockMet\
aData\x12\x19\n\x08block_id\x18\x01\x20\x01(\tR\x07blockId\x12%\n\trow_m\
- etas\x18\x02\x20\x03(\x0b2\x08.RowMetaR\x08rowMetas\"\x99\x02\n\tFieldMe\
+ etas\x18\x02\x20\x03(\x0b2\x08.RowMetaR\x08rowMetas\"\xbc\x02\n\tFieldMe\
ta\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x12\n\x04name\x18\x02\
\x20\x01(\tR\x04name\x12\x12\n\x04desc\x18\x03\x20\x01(\tR\x04desc\x12)\
\n\nfield_type\x18\x04\x20\x01(\x0e2\n.FieldTypeR\tfieldType\x12\x16\n\
\x06frozen\x18\x05\x20\x01(\x08R\x06frozen\x12\x1e\n\nvisibility\x18\x06\
\x20\x01(\x08R\nvisibility\x12\x14\n\x05width\x18\x07\x20\x01(\x05R\x05w\
- idth\x12[\n\x1ctype_option_by_field_type_id\x18\x08\x20\x01(\x0b2\x1c.Ty\
- peOptionDataByFieldTypeIdR\x17typeOptionByFieldTypeId\"\x8e\x01\n\x1bTyp\
- eOptionDataByFieldTypeId\x127\n\x03map\x18\x01\x20\x03(\x0b2%.TypeOption\
- DataByFieldTypeId.MapEntryR\x03map\x1a6\n\x08MapEntry\x12\x10\n\x03key\
- \x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05va\
- lue:\x028\x01\"\xa8\x03\n\x15FieldChangesetPayload\x12\x19\n\x08field_id\
- \x18\x01\x20\x01(\tR\x07fieldId\x12\x17\n\x07grid_id\x18\x02\x20\x01(\tR\
- \x06gridId\x12\x14\n\x04name\x18\x03\x20\x01(\tH\0R\x04name\x12\x14\n\
- \x04desc\x18\x04\x20\x01(\tH\x01R\x04desc\x12+\n\nfield_type\x18\x05\x20\
- \x01(\x0e2\n.FieldTypeH\x02R\tfieldType\x12\x18\n\x06frozen\x18\x06\x20\
- \x01(\x08H\x03R\x06frozen\x12\x20\n\nvisibility\x18\x07\x20\x01(\x08H\
- \x04R\nvisibility\x12\x16\n\x05width\x18\x08\x20\x01(\x05H\x05R\x05width\
- \x12*\n\x10type_option_data\x18\t\x20\x01(\x0cH\x06R\x0etypeOptionDataB\
- \r\n\x0bone_of_nameB\r\n\x0bone_of_descB\x13\n\x11one_of_field_typeB\x0f\
- \n\rone_of_frozenB\x13\n\x11one_of_visibilityB\x0e\n\x0cone_of_widthB\
- \x19\n\x17one_of_type_option_data\"8\n\x07AnyData\x12\x17\n\x07type_id\
- \x18\x01\x20\x01(\tR\x06typeId\x12\x14\n\x05value\x18\x02\x20\x01(\x0cR\
- \x05value\"\xff\x01\n\x07RowMeta\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02\
- id\x12\x19\n\x08block_id\x18\x02\x20\x01(\tR\x07blockId\x12D\n\x10cell_b\
- y_field_id\x18\x03\x20\x03(\x0b2\x1b.RowMeta.CellByFieldIdEntryR\rcellBy\
- FieldId\x12\x16\n\x06height\x18\x04\x20\x01(\x05R\x06height\x12\x1e\n\nv\
- isibility\x18\x05\x20\x01(\x08R\nvisibility\x1aK\n\x12CellByFieldIdEntry\
- \x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x1f\n\x05value\x18\x02\
- \x20\x01(\x0b2\t.CellMetaR\x05value:\x028\x01\"\xa7\x02\n\x10RowMetaChan\
- geset\x12\x15\n\x06row_id\x18\x01\x20\x01(\tR\x05rowId\x12\x18\n\x06heig\
- ht\x18\x02\x20\x01(\x05H\0R\x06height\x12\x20\n\nvisibility\x18\x03\x20\
- \x01(\x08H\x01R\nvisibility\x12M\n\x10cell_by_field_id\x18\x04\x20\x03(\
- \x0b2$.RowMetaChangeset.CellByFieldIdEntryR\rcellByFieldId\x1aK\n\x12Cel\
- lByFieldIdEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x1f\n\
- \x05value\x18\x02\x20\x01(\x0b2\t.CellMetaR\x05value:\x028\x01B\x0f\n\ro\
- ne_of_heightB\x13\n\x11one_of_visibility\"9\n\x08CellMeta\x12\x19\n\x08f\
- ield_id\x18\x01\x20\x01(\tR\x07fieldId\x12\x12\n\x04data\x18\x02\x20\x01\
- (\tR\x04data\"\x83\x01\n\x11CellMetaChangeset\x12\x17\n\x07grid_id\x18\
- \x01\x20\x01(\tR\x06gridId\x12\x15\n\x06row_id\x18\x02\x20\x01(\tR\x05ro\
- wId\x12\x19\n\x08field_id\x18\x03\x20\x01(\tR\x07fieldId\x12\x14\n\x04da\
- ta\x18\x04\x20\x01(\tH\0R\x04dataB\r\n\x0bone_of_data\"\xac\x01\n\x10Bui\
- ldGridContext\x12+\n\x0bfield_metas\x18\x01\x20\x03(\x0b2\n.FieldMetaR\n\
- fieldMetas\x12/\n\x0bblock_metas\x18\x02\x20\x01(\x0b2\x0e.GridBlockMeta\
- R\nblockMetas\x12:\n\x0fblock_meta_data\x18\x03\x20\x01(\x0b2\x12.GridBl\
- ockMetaDataR\rblockMetaData*d\n\tFieldType\x12\x0c\n\x08RichText\x10\0\
- \x12\n\n\x06Number\x10\x01\x12\x0c\n\x08DateTime\x10\x02\x12\x10\n\x0cSi\
- ngleSelect\x10\x03\x12\x0f\n\x0bMultiSelect\x10\x04\x12\x0c\n\x08Checkbo\
- x\x10\x05b\x06proto3\
+ idth\x12>\n\x0ctype_options\x18\x08\x20\x03(\x0b2\x1b.FieldMeta.TypeOpti\
+ onsEntryR\x0btypeOptions\x1a>\n\x10TypeOptionsEntry\x12\x10\n\x03key\x18\
+ \x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05value:\
+ \x028\x01\"\xa8\x03\n\x15FieldChangesetPayload\x12\x19\n\x08field_id\x18\
+ \x01\x20\x01(\tR\x07fieldId\x12\x17\n\x07grid_id\x18\x02\x20\x01(\tR\x06\
+ gridId\x12\x14\n\x04name\x18\x03\x20\x01(\tH\0R\x04name\x12\x14\n\x04des\
+ c\x18\x04\x20\x01(\tH\x01R\x04desc\x12+\n\nfield_type\x18\x05\x20\x01(\
+ \x0e2\n.FieldTypeH\x02R\tfieldType\x12\x18\n\x06frozen\x18\x06\x20\x01(\
+ \x08H\x03R\x06frozen\x12\x20\n\nvisibility\x18\x07\x20\x01(\x08H\x04R\nv\
+ isibility\x12\x16\n\x05width\x18\x08\x20\x01(\x05H\x05R\x05width\x12*\n\
+ \x10type_option_data\x18\t\x20\x01(\x0cH\x06R\x0etypeOptionDataB\r\n\x0b\
+ one_of_nameB\r\n\x0bone_of_descB\x13\n\x11one_of_field_typeB\x0f\n\rone_\
+ of_frozenB\x13\n\x11one_of_visibilityB\x0e\n\x0cone_of_widthB\x19\n\x17o\
+ ne_of_type_option_data\"8\n\x07AnyData\x12\x17\n\x07type_id\x18\x01\x20\
+ \x01(\tR\x06typeId\x12\x14\n\x05value\x18\x02\x20\x01(\x0cR\x05value\"\
+ \xdc\x01\n\x07RowMeta\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x19\
+ \n\x08block_id\x18\x02\x20\x01(\tR\x07blockId\x12)\n\x05cells\x18\x03\
+ \x20\x03(\x0b2\x13.RowMeta.CellsEntryR\x05cells\x12\x16\n\x06height\x18\
+ \x04\x20\x01(\x05R\x06height\x12\x1e\n\nvisibility\x18\x05\x20\x01(\x08R\
+ \nvisibility\x1aC\n\nCellsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03\
+ key\x12\x1f\n\x05value\x18\x02\x20\x01(\x0b2\t.CellMetaR\x05value:\x028\
+ \x01\"\xa7\x02\n\x10RowMetaChangeset\x12\x15\n\x06row_id\x18\x01\x20\x01\
+ (\tR\x05rowId\x12\x18\n\x06height\x18\x02\x20\x01(\x05H\0R\x06height\x12\
+ \x20\n\nvisibility\x18\x03\x20\x01(\x08H\x01R\nvisibility\x12M\n\x10cell\
+ _by_field_id\x18\x04\x20\x03(\x0b2$.RowMetaChangeset.CellByFieldIdEntryR\
+ \rcellByFieldId\x1aK\n\x12CellByFieldIdEntry\x12\x10\n\x03key\x18\x01\
+ \x20\x01(\tR\x03key\x12\x1f\n\x05value\x18\x02\x20\x01(\x0b2\t.CellMetaR\
+ \x05value:\x028\x01B\x0f\n\rone_of_heightB\x13\n\x11one_of_visibility\"\
+ \x1e\n\x08CellMeta\x12\x12\n\x04data\x18\x01\x20\x01(\tR\x04data\"\x83\
+ \x01\n\x11CellMetaChangeset\x12\x17\n\x07grid_id\x18\x01\x20\x01(\tR\x06\
+ gridId\x12\x15\n\x06row_id\x18\x02\x20\x01(\tR\x05rowId\x12\x19\n\x08fie\
+ ld_id\x18\x03\x20\x01(\tR\x07fieldId\x12\x14\n\x04data\x18\x04\x20\x01(\
+ \tH\0R\x04dataB\r\n\x0bone_of_data\"\xac\x01\n\x10BuildGridContext\x12+\
+ \n\x0bfield_metas\x18\x01\x20\x03(\x0b2\n.FieldMetaR\nfieldMetas\x12/\n\
+ \x0bblock_metas\x18\x02\x20\x01(\x0b2\x0e.GridBlockMetaR\nblockMetas\x12\
+ :\n\x0fblock_meta_data\x18\x03\x20\x01(\x0b2\x12.GridBlockMetaDataR\rblo\
+ ckMetaData*d\n\tFieldType\x12\x0c\n\x08RichText\x10\0\x12\n\n\x06Number\
+ \x10\x01\x12\x0c\n\x08DateTime\x10\x02\x12\x10\n\x0cSingleSelect\x10\x03\
+ \x12\x0f\n\x0bMultiSelect\x10\x04\x12\x0c\n\x08Checkbox\x10\x05b\x06prot\
+ o3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
diff --git a/shared-lib/flowy-grid-data-model/src/protobuf/proto/meta.proto b/shared-lib/flowy-grid-data-model/src/protobuf/proto/meta.proto
index ca00b88b57..18c05896fe 100644
--- a/shared-lib/flowy-grid-data-model/src/protobuf/proto/meta.proto
+++ b/shared-lib/flowy-grid-data-model/src/protobuf/proto/meta.proto
@@ -22,10 +22,7 @@ message FieldMeta {
bool frozen = 5;
bool visibility = 6;
int32 width = 7;
- TypeOptionDataByFieldTypeId type_option_by_field_type_id = 8;
-}
-message TypeOptionDataByFieldTypeId {
- map<string, string> map = 1;
+ map<string, string> type_options = 8;
}
message FieldChangesetPayload {
string field_id = 1;
@@ -45,7 +42,7 @@ message AnyData {
message RowMeta {
string id = 1;
string block_id = 2;
- map<string, CellMeta> cell_by_field_id = 3;
+ map<string, CellMeta> cells = 3;
int32 height = 4;
bool visibility = 5;
}
@@ -56,8 +53,7 @@ message RowMetaChangeset {
map<string, CellMeta> cell_by_field_id = 4;
}
message CellMeta {
- string field_id = 1;
- string data = 2;
+ string data = 1;
}
message CellMetaChangeset {
string grid_id = 1;
diff --git a/shared-lib/flowy-sync/src/client_grid/grid_block_meta_pad.rs b/shared-lib/flowy-sync/src/client_grid/grid_block_meta_pad.rs
index 688b32cccc..2d70309fef 100644
--- a/shared-lib/flowy-sync/src/client_grid/grid_block_meta_pad.rs
+++ b/shared-lib/flowy-sync/src/client_grid/grid_block_meta_pad.rs
@@ -24,9 +24,9 @@ pub struct GridBlockMetaPad {
impl GridBlockMetaPad {
pub fn from_delta(delta: GridBlockMetaDelta) -> CollaborateResult<Self> {
let s = delta.to_str()?;
- tracing::trace!("{}", s);
let meta_data: GridBlockMetaData = serde_json::from_str(&s).map_err(|e| {
let msg = format!("Deserialize delta to block meta failed: {}", e);
+ tracing::error!("{}", s);
CollaborateError::internal().context(msg)
})?;
let block_id = meta_data.block_id;
@@ -107,7 +107,7 @@ impl GridBlockMetaPad {
let cell_metas = rows
.iter()
.flat_map(|row| {
- let cell_meta = row.cell_by_field_id.get(field_id)?;
+ let cell_meta = row.cells.get(field_id)?;
Some(cell_meta.clone())
})
.collect::<Vec<CellMeta>>();
@@ -135,7 +135,7 @@ impl GridBlockMetaPad {
if !changeset.cell_by_field_id.is_empty() {
is_changed = Some(());
changeset.cell_by_field_id.into_iter().for_each(|(field_id, cell)| {
- row.cell_by_field_id.insert(field_id, cell);
+ row.cells.insert(field_id, cell);
})
}
@@ -237,7 +237,7 @@ mod tests {
let row = RowMeta {
id: "1".to_string(),
block_id: pad.block_id.clone(),
- cell_by_field_id: Default::default(),
+ cells: Default::default(),
height: 0,
visibility: false,
};
@@ -283,7 +283,7 @@ mod tests {
RowMeta {
id: id.to_string(),
block_id: pad.block_id.clone(),
- cell_by_field_id: Default::default(),
+ cells: Default::default(),
height: 0,
visibility: false,
}
@@ -328,7 +328,7 @@ mod tests {
let row = RowMeta {
id: "1".to_string(),
block_id: pad.block_id.clone(),
- cell_by_field_id: Default::default(),
+ cells: Default::default(),
height: 0,
visibility: false,
};
@@ -349,7 +349,7 @@ mod tests {
let row = RowMeta {
id: "1".to_string(),
block_id: pad.block_id.clone(),
- cell_by_field_id: Default::default(),
+ cells: Default::default(),
height: 0,
visibility: false,
};
diff --git a/shared-lib/flowy-sync/src/client_grid/grid_builder.rs b/shared-lib/flowy-sync/src/client_grid/grid_builder.rs
index 2b91e1352c..43b85de269 100644
--- a/shared-lib/flowy-sync/src/client_grid/grid_builder.rs
+++ b/shared-lib/flowy-sync/src/client_grid/grid_builder.rs
@@ -28,7 +28,7 @@ impl GridBuilder {
fn check_rows(fields: &[FieldMeta], rows: &[RowMeta]) -> CollaborateResult<()> {
let field_ids = fields.iter().map(|field| &field.id).collect::<Vec<&String>>();
for row in rows {
- let cell_field_ids = row.cell_by_field_id.keys().into_iter().collect::<Vec<&String>>();
+ let cell_field_ids = row.cells.keys().into_iter().collect::<Vec<&String>>();
if cell_field_ids != field_ids {
let msg = format!("{:?} contains invalid cells", row);
return Err(CollaborateError::internal().context(msg));