chore: rename struct property

This commit is contained in:
appflowy
2022-04-09 07:35:35 +08:00
parent 1e997ccaad
commit 953af35029
12 changed files with 150 additions and 470 deletions

View File

@ -215,7 +215,7 @@ class FieldMeta extends $pb.GeneratedMessage {
..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'frozen') ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'frozen')
..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'visibility') ..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) ..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 ..hasRequiredFields = false
; ;
@ -228,7 +228,7 @@ class FieldMeta extends $pb.GeneratedMessage {
$core.bool? frozen, $core.bool? frozen,
$core.bool? visibility, $core.bool? visibility,
$core.int? width, $core.int? width,
TypeOptionDataByFieldTypeId? typeOptionByFieldTypeId, $core.Map<$core.String, $core.String>? typeOptions,
}) { }) {
final _result = create(); final _result = create();
if (id != null) { if (id != null) {
@ -252,8 +252,8 @@ class FieldMeta extends $pb.GeneratedMessage {
if (width != null) { if (width != null) {
_result.width = width; _result.width = width;
} }
if (typeOptionByFieldTypeId != null) { if (typeOptions != null) {
_result.typeOptionByFieldTypeId = typeOptionByFieldTypeId; _result.typeOptions.addAll(typeOptions);
} }
return _result; return _result;
} }
@ -342,56 +342,7 @@ class FieldMeta extends $pb.GeneratedMessage {
void clearWidth() => clearField(7); void clearWidth() => clearField(7);
@$pb.TagNumber(8) @$pb.TagNumber(8)
TypeOptionDataByFieldTypeId get typeOptionByFieldTypeId => $_getN(7); $core.Map<$core.String, $core.String> get typeOptions => $_getMap(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);
} }
enum FieldChangesetPayload_OneOfName { 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) 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(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'blockId') ..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) ..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') ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'visibility')
..hasRequiredFields = false ..hasRequiredFields = false
@ -719,7 +670,7 @@ class RowMeta extends $pb.GeneratedMessage {
factory RowMeta({ factory RowMeta({
$core.String? id, $core.String? id,
$core.String? blockId, $core.String? blockId,
$core.Map<$core.String, CellMeta>? cellByFieldId, $core.Map<$core.String, CellMeta>? cells,
$core.int? height, $core.int? height,
$core.bool? visibility, $core.bool? visibility,
}) { }) {
@ -730,8 +681,8 @@ class RowMeta extends $pb.GeneratedMessage {
if (blockId != null) { if (blockId != null) {
_result.blockId = blockId; _result.blockId = blockId;
} }
if (cellByFieldId != null) { if (cells != null) {
_result.cellByFieldId.addAll(cellByFieldId); _result.cells.addAll(cells);
} }
if (height != null) { if (height != null) {
_result.height = height; _result.height = height;
@ -781,7 +732,7 @@ class RowMeta extends $pb.GeneratedMessage {
void clearBlockId() => clearField(2); void clearBlockId() => clearField(2);
@$pb.TagNumber(3) @$pb.TagNumber(3)
$core.Map<$core.String, CellMeta> get cellByFieldId => $_getMap(2); $core.Map<$core.String, CellMeta> get cells => $_getMap(2);
@$pb.TagNumber(4) @$pb.TagNumber(4)
$core.int get height => $_getIZ(3); $core.int get height => $_getIZ(3);
@ -913,20 +864,15 @@ class RowMetaChangeset extends $pb.GeneratedMessage {
class CellMeta 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) 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(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data')
..hasRequiredFields = false ..hasRequiredFields = false
; ;
CellMeta._() : super(); CellMeta._() : super();
factory CellMeta({ factory CellMeta({
$core.String? fieldId,
$core.String? data, $core.String? data,
}) { }) {
final _result = create(); final _result = create();
if (fieldId != null) {
_result.fieldId = fieldId;
}
if (data != null) { if (data != null) {
_result.data = data; _result.data = data;
} }
@ -954,22 +900,13 @@ class CellMeta extends $pb.GeneratedMessage {
static CellMeta? _defaultInstance; static CellMeta? _defaultInstance;
@$pb.TagNumber(1) @$pb.TagNumber(1)
$core.String get fieldId => $_getSZ(0); $core.String get data => $_getSZ(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)
set fieldId($core.String v) { $_setString(0, v); } set data($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1) @$pb.TagNumber(1)
$core.bool hasFieldId() => $_has(0); $core.bool hasData() => $_has(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)
void clearFieldId() => clearField(1); void clearData() => 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);
} }
enum CellMetaChangeset_OneOfData { enum CellMetaChangeset_OneOfData {

View File

@ -69,24 +69,14 @@ const FieldMeta$json = const {
const {'1': 'frozen', '3': 5, '4': 1, '5': 8, '10': 'frozen'}, const {'1': 'frozen', '3': 5, '4': 1, '5': 8, '10': 'frozen'},
const {'1': 'visibility', '3': 6, '4': 1, '5': 8, '10': 'visibility'}, const {'1': 'visibility', '3': 6, '4': 1, '5': 8, '10': 'visibility'},
const {'1': 'width', '3': 7, '4': 1, '5': 5, '10': 'width'}, 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`. @$core.Deprecated('Use fieldMetaDescriptor instead')
final $typed_data.Uint8List fieldMetaDescriptor = $convert.base64Decode('CglGaWVsZE1ldGESDgoCaWQYASABKAlSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSEgoEZGVzYxgDIAEoCVIEZGVzYxIpCgpmaWVsZF90eXBlGAQgASgOMgouRmllbGRUeXBlUglmaWVsZFR5cGUSFgoGZnJvemVuGAUgASgIUgZmcm96ZW4SHgoKdmlzaWJpbGl0eRgGIAEoCFIKdmlzaWJpbGl0eRIUCgV3aWR0aBgHIAEoBVIFd2lkdGgSWwocdHlwZV9vcHRpb25fYnlfZmllbGRfdHlwZV9pZBgIIAEoCzIcLlR5cGVPcHRpb25EYXRhQnlGaWVsZFR5cGVJZFIXdHlwZU9wdGlvbkJ5RmllbGRUeXBlSWQ='); const FieldMeta_TypeOptionsEntry$json = const {
@$core.Deprecated('Use typeOptionDataByFieldTypeIdDescriptor instead') '1': 'TypeOptionsEntry',
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',
'2': const [ '2': const [
const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'},
const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'},
@ -94,8 +84,8 @@ const TypeOptionDataByFieldTypeId_MapEntry$json = const {
'7': const {'7': true}, '7': const {'7': true},
}; };
/// Descriptor for `TypeOptionDataByFieldTypeId`. Decode as a `google.protobuf.DescriptorProto`. /// Descriptor for `FieldMeta`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List typeOptionDataByFieldTypeIdDescriptor = $convert.base64Decode('ChtUeXBlT3B0aW9uRGF0YUJ5RmllbGRUeXBlSWQSNwoDbWFwGAEgAygLMiUuVHlwZU9wdGlvbkRhdGFCeUZpZWxkVHlwZUlkLk1hcEVudHJ5UgNtYXAaNgoITWFwRW50cnkSEAoDa2V5GAEgASgJUgNrZXkSFAoFdmFsdWUYAiABKAlSBXZhbHVlOgI4AQ=='); final $typed_data.Uint8List fieldMetaDescriptor = $convert.base64Decode('CglGaWVsZE1ldGESDgoCaWQYASABKAlSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSEgoEZGVzYxgDIAEoCVIEZGVzYxIpCgpmaWVsZF90eXBlGAQgASgOMgouRmllbGRUeXBlUglmaWVsZFR5cGUSFgoGZnJvemVuGAUgASgIUgZmcm96ZW4SHgoKdmlzaWJpbGl0eRgGIAEoCFIKdmlzaWJpbGl0eRIUCgV3aWR0aBgHIAEoBVIFd2lkdGgSPgoMdHlwZV9vcHRpb25zGAggAygLMhsuRmllbGRNZXRhLlR5cGVPcHRpb25zRW50cnlSC3R5cGVPcHRpb25zGj4KEFR5cGVPcHRpb25zRW50cnkSEAoDa2V5GAEgASgJUgNrZXkSFAoFdmFsdWUYAiABKAlSBXZhbHVlOgI4AQ==');
@$core.Deprecated('Use fieldChangesetPayloadDescriptor instead') @$core.Deprecated('Use fieldChangesetPayloadDescriptor instead')
const FieldChangesetPayload$json = const { const FieldChangesetPayload$json = const {
'1': 'FieldChangesetPayload', '1': 'FieldChangesetPayload',
@ -140,16 +130,16 @@ const RowMeta$json = const {
'2': const [ '2': const [
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, 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': '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': 'height', '3': 4, '4': 1, '5': 5, '10': 'height'},
const {'1': 'visibility', '3': 5, '4': 1, '5': 8, '10': 'visibility'}, 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') @$core.Deprecated('Use rowMetaDescriptor instead')
const RowMeta_CellByFieldIdEntry$json = const { const RowMeta_CellsEntry$json = const {
'1': 'CellByFieldIdEntry', '1': 'CellsEntry',
'2': const [ '2': const [
const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'},
const {'1': 'value', '3': 2, '4': 1, '5': 11, '6': '.CellMeta', '10': 'value'}, 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`. /// 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') @$core.Deprecated('Use rowMetaChangesetDescriptor instead')
const RowMetaChangeset$json = const { const RowMetaChangeset$json = const {
'1': 'RowMetaChangeset', '1': 'RowMetaChangeset',
@ -191,13 +181,12 @@ final $typed_data.Uint8List rowMetaChangesetDescriptor = $convert.base64Decode('
const CellMeta$json = const { const CellMeta$json = const {
'1': 'CellMeta', '1': 'CellMeta',
'2': const [ '2': const [
const {'1': 'field_id', '3': 1, '4': 1, '5': 9, '10': 'fieldId'}, const {'1': 'data', '3': 1, '4': 1, '5': 9, '10': 'data'},
const {'1': 'data', '3': 2, '4': 1, '5': 9, '10': 'data'},
], ],
}; };
/// Descriptor for `CellMeta`. Decode as a `google.protobuf.DescriptorProto`. /// 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') @$core.Deprecated('Use cellMetaChangesetDescriptor instead')
const CellMetaChangeset$json = const { const CellMetaChangeset$json = const {
'1': 'CellMetaChangeset', '1': 'CellMetaChangeset',

View File

@ -8,7 +8,7 @@ edition = "2018"
name = "dart_ffi" name = "dart_ffi"
# this value will change depending on the target os # this value will change depending on the target os
# default static lib # default static lib
crate-type = ["cdylib"] crate-type = ["staticlib"]
[dependencies] [dependencies]

View File

@ -1,6 +1,7 @@
use crate::services::field::type_options::*; use crate::services::field::type_options::*;
use bytes::Bytes; 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 { pub struct FieldBuilder {
field_meta: FieldMeta, field_meta: FieldMeta,
@ -33,7 +34,7 @@ impl FieldBuilder {
frozen: field.frozen, frozen: field.frozen,
visibility: field.visibility, visibility: field.visibility,
width: field.width, width: field.width,
type_option_by_field_type_id: TypeOptionDataByFieldTypeId::default(), type_options: HashMap::default(),
}; };
Self { Self {
field_meta, field_meta,

View File

@ -279,7 +279,7 @@ impl ClientGridEditor {
match row_meta { match row_meta {
None => Ok(None), None => Ok(None),
Some(row_meta) => { 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) Ok(cell_meta)
} }
} }

View File

@ -38,7 +38,7 @@ impl<'a> CreateRowMetaBuilder<'a> {
} }
Some(field_meta) => { Some(field_meta) => {
let data = apply_cell_data_changeset(&data, None, 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); self.payload.cell_by_field_id.insert(field_id.to_owned(), cell);
Ok(()) Ok(())
} }
@ -54,7 +54,7 @@ impl<'a> CreateRowMetaBuilder<'a> {
Some(field_meta) => { Some(field_meta) => {
let cell_data = SelectOptionCellChangeset::from_insert(&data).cell_data(); let cell_data = SelectOptionCellChangeset::from_insert(&data).cell_data();
let data = apply_cell_data_changeset(&cell_data, None, field_meta)?; 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); self.payload.cell_by_field_id.insert(field_id.to_owned(), cell);
Ok(()) Ok(())
} }
@ -82,7 +82,7 @@ pub fn make_row_meta_from_context(block_id: &str, payload: CreateRowMetaPayload)
RowMeta { RowMeta {
id: payload.row_id, id: payload.row_id,
block_id: block_id.to_owned(), block_id: block_id.to_owned(),
cell_by_field_id: payload.cell_by_field_id, cells: payload.cell_by_field_id,
height: payload.height, height: payload.height,
visibility: payload.visibility, visibility: payload.visibility,
} }

View File

@ -61,7 +61,7 @@ pub fn make_cell_by_field_id(
#[allow(dead_code)] #[allow(dead_code)]
pub fn make_cell(field_id: &str, field_meta: &FieldMeta, row_meta: &RowMeta) -> Option<Cell> { 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) { match decode_cell_data(cell_meta.data, field_meta) {
Ok(content) => Some(Cell::new(field_id, content)), Ok(content) => Some(Cell::new(field_id, content)),
Err(e) => { 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 make_row = |row_meta: &Arc<RowMeta>| {
let cell_by_field_id = row_meta let cell_by_field_id = row_meta
.cell_by_field_id .cells
.clone() .clone()
.into_par_iter() .into_par_iter()
.flat_map(|(field_id, cell_meta)| make_cell_by_field_id(&field_meta_map, field_id, cell_meta)) .flat_map(|(field_id, cell_meta)| make_cell_by_field_id(&field_meta_map, field_id, cell_meta))

View File

@ -101,7 +101,10 @@ pub struct FieldMeta {
pub width: i32, pub width: i32,
#[pb(index = 8)] #[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 { impl FieldMeta {
@ -114,31 +117,28 @@ impl FieldMeta {
frozen: false, frozen: false,
visibility: true, visibility: true,
width: DEFAULT_FIELD_WIDTH, 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) { pub fn insert_type_option_entry<T: TypeOptionDataEntry + ?Sized>(&mut self, entry: &T) {
self.type_option_by_field_type_id self.type_options.insert(entry.field_type().type_id(), entry.json_str());
.insert(entry.field_type().type_id(), entry.json_str());
} }
pub fn get_type_option_entry<T: TypeOptionDataEntity>(&self, field_type: Option<FieldType>) -> Option<T> { 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); 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()) .get(&field_type.type_id())
.map(|s| T::from_json_str(s)) .map(|s| T::from_json_str(s))
} }
pub fn insert_type_option_str(&mut self, field_type: &FieldType, json_str: String) { 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> { 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); 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| s.to_owned())
.get(&field_type.type_id())
.map(|s| s.to_owned())
} }
} }
@ -153,26 +153,6 @@ pub trait TypeOptionDataEntity {
fn from_protobuf_bytes(bytes: Bytes) -> Self; 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)] #[derive(Debug, Clone, Default, ProtoBuf)]
pub struct FieldChangesetPayload { pub struct FieldChangesetPayload {
#[pb(index = 1)] #[pb(index = 1)]
@ -321,7 +301,10 @@ pub struct RowMeta {
pub block_id: String, pub block_id: String,
#[pb(index = 3)] #[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)] #[pb(index = 4)]
pub height: i32, pub height: i32,
@ -335,7 +318,7 @@ impl RowMeta {
Self { Self {
id: uuid::Uuid::new_v4().to_string(), id: uuid::Uuid::new_v4().to_string(),
block_id: block_id.to_owned(), block_id: block_id.to_owned(),
cell_by_field_id: Default::default(), cells: Default::default(),
height: DEFAULT_ROW_HEIGHT, height: DEFAULT_ROW_HEIGHT,
visibility: true, visibility: true,
} }
@ -360,18 +343,12 @@ pub struct RowMetaChangeset {
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, ProtoBuf)] #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, ProtoBuf)]
pub struct CellMeta { pub struct CellMeta {
#[pb(index = 1)] #[pb(index = 1)]
pub field_id: String,
#[pb(index = 2)]
pub data: String, pub data: String,
} }
impl CellMeta { impl CellMeta {
pub fn new(field_id: &str, data: String) -> Self { pub fn new(data: String) -> Self {
Self { Self { data }
field_id: field_id.to_string(),
data,
}
} }
} }
@ -395,7 +372,6 @@ impl std::convert::From<CellMetaChangeset> for RowMetaChangeset {
let mut cell_by_field_id = HashMap::with_capacity(1); let mut cell_by_field_id = HashMap::with_capacity(1);
let field_id = changeset.field_id; let field_id = changeset.field_id;
let cell_meta = CellMeta { let cell_meta = CellMeta {
field_id: field_id.clone(),
data: changeset.data.unwrap_or_else(|| "".to_owned()), data: changeset.data.unwrap_or_else(|| "".to_owned()),
}; };
cell_by_field_id.insert(field_id, cell_meta); 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, row_id: changeset.row_id,
height: None, height: None,
visibility: None, visibility: None,
cell_by_field_id, cell_by_field_id: cell_by_field_id,
} }
} }
} }

View File

@ -727,7 +727,7 @@ pub struct FieldMeta {
pub frozen: bool, pub frozen: bool,
pub visibility: bool, pub visibility: bool,
pub width: i32, 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 // special fields
pub unknown_fields: ::protobuf::UnknownFields, pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize, pub cached_size: ::protobuf::CachedSize,
@ -882,47 +882,34 @@ impl FieldMeta {
self.width = v; 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 { pub fn get_type_options(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> {
self.type_option_by_field_type_id.as_ref().unwrap_or_else(|| <TypeOptionDataByFieldTypeId as ::protobuf::Message>::default_instance()) &self.type_options
} }
pub fn clear_type_option_by_field_type_id(&mut self) { pub fn clear_type_options(&mut self) {
self.type_option_by_field_type_id.clear(); self.type_options.clear();
}
pub fn has_type_option_by_field_type_id(&self) -> bool {
self.type_option_by_field_type_id.is_some()
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_type_option_by_field_type_id(&mut self, v: TypeOptionDataByFieldTypeId) { pub fn set_type_options(&mut self, v: ::std::collections::HashMap<::std::string::String, ::std::string::String>) {
self.type_option_by_field_type_id = ::protobuf::SingularPtrField::some(v); self.type_options = v;
} }
// Mutable pointer to the field. // Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first. pub fn mut_type_options(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, ::std::string::String> {
pub fn mut_type_option_by_field_type_id(&mut self) -> &mut TypeOptionDataByFieldTypeId { &mut self.type_options
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()
} }
// Take field // Take field
pub fn take_type_option_by_field_type_id(&mut self) -> TypeOptionDataByFieldTypeId { pub fn take_type_options(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> {
self.type_option_by_field_type_id.take().unwrap_or_else(|| TypeOptionDataByFieldTypeId::new()) ::std::mem::replace(&mut self.type_options, ::std::collections::HashMap::new())
} }
} }
impl ::protobuf::Message for FieldMeta { impl ::protobuf::Message for FieldMeta {
fn is_initialized(&self) -> bool { fn is_initialized(&self) -> bool {
for v in &self.type_option_by_field_type_id {
if !v.is_initialized() {
return false;
}
};
true true
} }
@ -964,7 +951,7 @@ impl ::protobuf::Message for FieldMeta {
self.width = tmp; self.width = tmp;
}, },
8 => { 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())?; ::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 { if self.width != 0 {
my_size += ::protobuf::rt::value_size(7, self.width, ::protobuf::wire_format::WireTypeVarint); 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() { my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(8, &self.type_options);
let len = v.compute_size();
my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len;
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size); self.cached_size.set(my_size);
my_size my_size
@ -1030,11 +1014,7 @@ impl ::protobuf::Message for FieldMeta {
if self.width != 0 { if self.width != 0 {
os.write_int32(7, self.width)?; os.write_int32(7, self.width)?;
} }
if let Some(ref v) = self.type_option_by_field_type_id.as_ref() { ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(8, &self.type_options, os)?;
os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?;
os.write_raw_varint32(v.get_cached_size())?;
v.write_to_with_cached_sizes(os)?;
}
os.write_unknown_fields(self.get_unknown_fields())?; os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(()) ::std::result::Result::Ok(())
} }
@ -1108,10 +1088,10 @@ impl ::protobuf::Message for FieldMeta {
|m: &FieldMeta| { &m.width }, |m: &FieldMeta| { &m.width },
|m: &mut FieldMeta| { &mut m.width }, |m: &mut FieldMeta| { &mut m.width },
)); ));
fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<TypeOptionDataByFieldTypeId>>( fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>(
"type_option_by_field_type_id", "type_options",
|m: &FieldMeta| { &m.type_option_by_field_type_id }, |m: &FieldMeta| { &m.type_options },
|m: &mut FieldMeta| { &mut m.type_option_by_field_type_id }, |m: &mut FieldMeta| { &mut m.type_options },
)); ));
::protobuf::reflect::MessageDescriptor::new_pb_name::<FieldMeta>( ::protobuf::reflect::MessageDescriptor::new_pb_name::<FieldMeta>(
"FieldMeta", "FieldMeta",
@ -1136,7 +1116,7 @@ impl ::protobuf::Clear for FieldMeta {
self.frozen = false; self.frozen = false;
self.visibility = false; self.visibility = false;
self.width = 0; self.width = 0;
self.type_option_by_field_type_id.clear(); self.type_options.clear();
self.unknown_fields.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)] #[derive(PartialEq,Clone,Default)]
pub struct FieldChangesetPayload { pub struct FieldChangesetPayload {
// message fields // message fields
@ -2186,7 +2012,7 @@ pub struct RowMeta {
// message fields // message fields
pub id: ::std::string::String, pub id: ::std::string::String,
pub block_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 height: i32,
pub visibility: bool, pub visibility: bool,
// special fields // special fields
@ -2257,29 +2083,29 @@ impl RowMeta {
::std::mem::replace(&mut self.block_id, ::std::string::String::new()) ::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> { pub fn get_cells(&self) -> &::std::collections::HashMap<::std::string::String, CellMeta> {
&self.cell_by_field_id &self.cells
} }
pub fn clear_cell_by_field_id(&mut self) { pub fn clear_cells(&mut self) {
self.cell_by_field_id.clear(); self.cells.clear();
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_cell_by_field_id(&mut self, v: ::std::collections::HashMap<::std::string::String, CellMeta>) { pub fn set_cells(&mut self, v: ::std::collections::HashMap<::std::string::String, CellMeta>) {
self.cell_by_field_id = v; self.cells = v;
} }
// Mutable pointer to the field. // Mutable pointer to the field.
pub fn mut_cell_by_field_id(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, CellMeta> { pub fn mut_cells(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, CellMeta> {
&mut self.cell_by_field_id &mut self.cells
} }
// Take field // Take field
pub fn take_cell_by_field_id(&mut self) -> ::std::collections::HashMap<::std::string::String, CellMeta> { pub fn take_cells(&mut self) -> ::std::collections::HashMap<::std::string::String, CellMeta> {
::std::mem::replace(&mut self.cell_by_field_id, ::std::collections::HashMap::new()) ::std::mem::replace(&mut self.cells, ::std::collections::HashMap::new())
} }
// int32 height = 4; // 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)?; ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.block_id)?;
}, },
3 => { 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 => { 4 => {
if wire_type != ::protobuf::wire_format::WireTypeVarint { if wire_type != ::protobuf::wire_format::WireTypeVarint {
@ -2363,7 +2189,7 @@ impl ::protobuf::Message for RowMeta {
if !self.block_id.is_empty() { if !self.block_id.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.block_id); 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 { if self.height != 0 {
my_size += ::protobuf::rt::value_size(4, self.height, ::protobuf::wire_format::WireTypeVarint); 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() { if !self.block_id.is_empty() {
os.write_string(2, &self.block_id)?; 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 { if self.height != 0 {
os.write_int32(4, self.height)?; os.write_int32(4, self.height)?;
} }
@ -2438,9 +2264,9 @@ impl ::protobuf::Message for RowMeta {
|m: &mut RowMeta| { &mut m.block_id }, |m: &mut RowMeta| { &mut m.block_id },
)); ));
fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage<CellMeta>>( fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage<CellMeta>>(
"cell_by_field_id", "cells",
|m: &RowMeta| { &m.cell_by_field_id }, |m: &RowMeta| { &m.cells },
|m: &mut RowMeta| { &mut m.cell_by_field_id }, |m: &mut RowMeta| { &mut m.cells },
)); ));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>(
"height", "height",
@ -2470,7 +2296,7 @@ impl ::protobuf::Clear for RowMeta {
fn clear(&mut self) { fn clear(&mut self) {
self.id.clear(); self.id.clear();
self.block_id.clear(); self.block_id.clear();
self.cell_by_field_id.clear(); self.cells.clear();
self.height = 0; self.height = 0;
self.visibility = false; self.visibility = false;
self.unknown_fields.clear(); self.unknown_fields.clear();
@ -2803,7 +2629,6 @@ impl ::protobuf::reflect::ProtobufValue for RowMetaChangeset {
#[derive(PartialEq,Clone,Default)] #[derive(PartialEq,Clone,Default)]
pub struct CellMeta { pub struct CellMeta {
// message fields // message fields
pub field_id: ::std::string::String,
pub data: ::std::string::String, pub data: ::std::string::String,
// special fields // special fields
pub unknown_fields: ::protobuf::UnknownFields, pub unknown_fields: ::protobuf::UnknownFields,
@ -2821,33 +2646,7 @@ impl CellMeta {
::std::default::Default::default() ::std::default::Default::default()
} }
// string field_id = 1; // string data = 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;
pub fn get_data(&self) -> &str { pub fn get_data(&self) -> &str {
@ -2884,9 +2683,6 @@ impl ::protobuf::Message for CellMeta {
let (field_number, wire_type) = is.read_tag_unpack()?; let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number { match field_number {
1 => { 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)?; ::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)] #[allow(unused_variables)]
fn compute_size(&self) -> u32 { fn compute_size(&self) -> u32 {
let mut my_size = 0; 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() { 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()); my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size); 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<()> { 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() { 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())?; os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(()) ::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; static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| { descriptor.get(|| {
let mut fields = ::std::vec::Vec::new(); 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>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"data", "data",
|m: &CellMeta| { &m.data }, |m: &CellMeta| { &m.data },
@ -2983,7 +2768,6 @@ impl ::protobuf::Message for CellMeta {
impl ::protobuf::Clear for CellMeta { impl ::protobuf::Clear for CellMeta {
fn clear(&mut self) { fn clear(&mut self) {
self.field_id.clear();
self.data.clear(); self.data.clear();
self.unknown_fields.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\ 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\ \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\ 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\ 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)\ \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\ \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\ \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\ \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\ idth\x12>\n\x0ctype_options\x18\x08\x20\x03(\x0b2\x1b.FieldMeta.TypeOpti\
peOptionDataByFieldTypeIdR\x17typeOptionByFieldTypeId\"\x8e\x01\n\x1bTyp\ onsEntryR\x0btypeOptions\x1a>\n\x10TypeOptionsEntry\x12\x10\n\x03key\x18\
eOptionDataByFieldTypeId\x127\n\x03map\x18\x01\x20\x03(\x0b2%.TypeOption\ \x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05value:\
DataByFieldTypeId.MapEntryR\x03map\x1a6\n\x08MapEntry\x12\x10\n\x03key\ \x028\x01\"\xa8\x03\n\x15FieldChangesetPayload\x12\x19\n\x08field_id\x18\
\x18\x01\x20\x01(\tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05va\ \x01\x20\x01(\tR\x07fieldId\x12\x17\n\x07grid_id\x18\x02\x20\x01(\tR\x06\
lue:\x028\x01\"\xa8\x03\n\x15FieldChangesetPayload\x12\x19\n\x08field_id\ gridId\x12\x14\n\x04name\x18\x03\x20\x01(\tH\0R\x04name\x12\x14\n\x04des\
\x18\x01\x20\x01(\tR\x07fieldId\x12\x17\n\x07grid_id\x18\x02\x20\x01(\tR\ c\x18\x04\x20\x01(\tH\x01R\x04desc\x12+\n\nfield_type\x18\x05\x20\x01(\
\x06gridId\x12\x14\n\x04name\x18\x03\x20\x01(\tH\0R\x04name\x12\x14\n\ \x0e2\n.FieldTypeH\x02R\tfieldType\x12\x18\n\x06frozen\x18\x06\x20\x01(\
\x04desc\x18\x04\x20\x01(\tH\x01R\x04desc\x12+\n\nfield_type\x18\x05\x20\ \x08H\x03R\x06frozen\x12\x20\n\nvisibility\x18\x07\x20\x01(\x08H\x04R\nv\
\x01(\x0e2\n.FieldTypeH\x02R\tfieldType\x12\x18\n\x06frozen\x18\x06\x20\ isibility\x12\x16\n\x05width\x18\x08\x20\x01(\x05H\x05R\x05width\x12*\n\
\x01(\x08H\x03R\x06frozen\x12\x20\n\nvisibility\x18\x07\x20\x01(\x08H\ \x10type_option_data\x18\t\x20\x01(\x0cH\x06R\x0etypeOptionDataB\r\n\x0b\
\x04R\nvisibility\x12\x16\n\x05width\x18\x08\x20\x01(\x05H\x05R\x05width\ one_of_nameB\r\n\x0bone_of_descB\x13\n\x11one_of_field_typeB\x0f\n\rone_\
\x12*\n\x10type_option_data\x18\t\x20\x01(\x0cH\x06R\x0etypeOptionDataB\ of_frozenB\x13\n\x11one_of_visibilityB\x0e\n\x0cone_of_widthB\x19\n\x17o\
\r\n\x0bone_of_nameB\r\n\x0bone_of_descB\x13\n\x11one_of_field_typeB\x0f\ ne_of_type_option_data\"8\n\x07AnyData\x12\x17\n\x07type_id\x18\x01\x20\
\n\rone_of_frozenB\x13\n\x11one_of_visibilityB\x0e\n\x0cone_of_widthB\ \x01(\tR\x06typeId\x12\x14\n\x05value\x18\x02\x20\x01(\x0cR\x05value\"\
\x19\n\x17one_of_type_option_data\"8\n\x07AnyData\x12\x17\n\x07type_id\ \xdc\x01\n\x07RowMeta\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x19\
\x18\x01\x20\x01(\tR\x06typeId\x12\x14\n\x05value\x18\x02\x20\x01(\x0cR\ \n\x08block_id\x18\x02\x20\x01(\tR\x07blockId\x12)\n\x05cells\x18\x03\
\x05value\"\xff\x01\n\x07RowMeta\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02\ \x20\x03(\x0b2\x13.RowMeta.CellsEntryR\x05cells\x12\x16\n\x06height\x18\
id\x12\x19\n\x08block_id\x18\x02\x20\x01(\tR\x07blockId\x12D\n\x10cell_b\ \x04\x20\x01(\x05R\x06height\x12\x1e\n\nvisibility\x18\x05\x20\x01(\x08R\
y_field_id\x18\x03\x20\x03(\x0b2\x1b.RowMeta.CellByFieldIdEntryR\rcellBy\ \nvisibility\x1aC\n\nCellsEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03\
FieldId\x12\x16\n\x06height\x18\x04\x20\x01(\x05R\x06height\x12\x1e\n\nv\ key\x12\x1f\n\x05value\x18\x02\x20\x01(\x0b2\t.CellMetaR\x05value:\x028\
isibility\x18\x05\x20\x01(\x08R\nvisibility\x1aK\n\x12CellByFieldIdEntry\ \x01\"\xa7\x02\n\x10RowMetaChangeset\x12\x15\n\x06row_id\x18\x01\x20\x01\
\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x1f\n\x05value\x18\x02\ (\tR\x05rowId\x12\x18\n\x06height\x18\x02\x20\x01(\x05H\0R\x06height\x12\
\x20\x01(\x0b2\t.CellMetaR\x05value:\x028\x01\"\xa7\x02\n\x10RowMetaChan\ \x20\n\nvisibility\x18\x03\x20\x01(\x08H\x01R\nvisibility\x12M\n\x10cell\
geset\x12\x15\n\x06row_id\x18\x01\x20\x01(\tR\x05rowId\x12\x18\n\x06heig\ _by_field_id\x18\x04\x20\x03(\x0b2$.RowMetaChangeset.CellByFieldIdEntryR\
ht\x18\x02\x20\x01(\x05H\0R\x06height\x12\x20\n\nvisibility\x18\x03\x20\ \rcellByFieldId\x1aK\n\x12CellByFieldIdEntry\x12\x10\n\x03key\x18\x01\
\x01(\x08H\x01R\nvisibility\x12M\n\x10cell_by_field_id\x18\x04\x20\x03(\ \x20\x01(\tR\x03key\x12\x1f\n\x05value\x18\x02\x20\x01(\x0b2\t.CellMetaR\
\x0b2$.RowMetaChangeset.CellByFieldIdEntryR\rcellByFieldId\x1aK\n\x12Cel\ \x05value:\x028\x01B\x0f\n\rone_of_heightB\x13\n\x11one_of_visibility\"\
lByFieldIdEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x1f\n\ \x1e\n\x08CellMeta\x12\x12\n\x04data\x18\x01\x20\x01(\tR\x04data\"\x83\
\x05value\x18\x02\x20\x01(\x0b2\t.CellMetaR\x05value:\x028\x01B\x0f\n\ro\ \x01\n\x11CellMetaChangeset\x12\x17\n\x07grid_id\x18\x01\x20\x01(\tR\x06\
ne_of_heightB\x13\n\x11one_of_visibility\"9\n\x08CellMeta\x12\x19\n\x08f\ gridId\x12\x15\n\x06row_id\x18\x02\x20\x01(\tR\x05rowId\x12\x19\n\x08fie\
ield_id\x18\x01\x20\x01(\tR\x07fieldId\x12\x12\n\x04data\x18\x02\x20\x01\ ld_id\x18\x03\x20\x01(\tR\x07fieldId\x12\x14\n\x04data\x18\x04\x20\x01(\
(\tR\x04data\"\x83\x01\n\x11CellMetaChangeset\x12\x17\n\x07grid_id\x18\ \tH\0R\x04dataB\r\n\x0bone_of_data\"\xac\x01\n\x10BuildGridContext\x12+\
\x01\x20\x01(\tR\x06gridId\x12\x15\n\x06row_id\x18\x02\x20\x01(\tR\x05ro\ \n\x0bfield_metas\x18\x01\x20\x03(\x0b2\n.FieldMetaR\nfieldMetas\x12/\n\
wId\x12\x19\n\x08field_id\x18\x03\x20\x01(\tR\x07fieldId\x12\x14\n\x04da\ \x0bblock_metas\x18\x02\x20\x01(\x0b2\x0e.GridBlockMetaR\nblockMetas\x12\
ta\x18\x04\x20\x01(\tH\0R\x04dataB\r\n\x0bone_of_data\"\xac\x01\n\x10Bui\ :\n\x0fblock_meta_data\x18\x03\x20\x01(\x0b2\x12.GridBlockMetaDataR\rblo\
ldGridContext\x12+\n\x0bfield_metas\x18\x01\x20\x03(\x0b2\n.FieldMetaR\n\ ckMetaData*d\n\tFieldType\x12\x0c\n\x08RichText\x10\0\x12\n\n\x06Number\
fieldMetas\x12/\n\x0bblock_metas\x18\x02\x20\x01(\x0b2\x0e.GridBlockMeta\ \x10\x01\x12\x0c\n\x08DateTime\x10\x02\x12\x10\n\x0cSingleSelect\x10\x03\
R\nblockMetas\x12:\n\x0fblock_meta_data\x18\x03\x20\x01(\x0b2\x12.GridBl\ \x12\x0f\n\x0bMultiSelect\x10\x04\x12\x0c\n\x08Checkbox\x10\x05b\x06prot\
ockMetaDataR\rblockMetaData*d\n\tFieldType\x12\x0c\n\x08RichText\x10\0\ o3\
\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\
"; ";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -22,10 +22,7 @@ message FieldMeta {
bool frozen = 5; bool frozen = 5;
bool visibility = 6; bool visibility = 6;
int32 width = 7; int32 width = 7;
TypeOptionDataByFieldTypeId type_option_by_field_type_id = 8; map<string, string> type_options = 8;
}
message TypeOptionDataByFieldTypeId {
map<string, string> map = 1;
} }
message FieldChangesetPayload { message FieldChangesetPayload {
string field_id = 1; string field_id = 1;
@ -45,7 +42,7 @@ message AnyData {
message RowMeta { message RowMeta {
string id = 1; string id = 1;
string block_id = 2; string block_id = 2;
map<string, CellMeta> cell_by_field_id = 3; map<string, CellMeta> cells = 3;
int32 height = 4; int32 height = 4;
bool visibility = 5; bool visibility = 5;
} }
@ -56,8 +53,7 @@ message RowMetaChangeset {
map<string, CellMeta> cell_by_field_id = 4; map<string, CellMeta> cell_by_field_id = 4;
} }
message CellMeta { message CellMeta {
string field_id = 1; string data = 1;
string data = 2;
} }
message CellMetaChangeset { message CellMetaChangeset {
string grid_id = 1; string grid_id = 1;

View File

@ -24,9 +24,9 @@ pub struct GridBlockMetaPad {
impl GridBlockMetaPad { impl GridBlockMetaPad {
pub fn from_delta(delta: GridBlockMetaDelta) -> CollaborateResult<Self> { pub fn from_delta(delta: GridBlockMetaDelta) -> CollaborateResult<Self> {
let s = delta.to_str()?; let s = delta.to_str()?;
tracing::trace!("{}", s);
let meta_data: GridBlockMetaData = serde_json::from_str(&s).map_err(|e| { let meta_data: GridBlockMetaData = serde_json::from_str(&s).map_err(|e| {
let msg = format!("Deserialize delta to block meta failed: {}", e); let msg = format!("Deserialize delta to block meta failed: {}", e);
tracing::error!("{}", s);
CollaborateError::internal().context(msg) CollaborateError::internal().context(msg)
})?; })?;
let block_id = meta_data.block_id; let block_id = meta_data.block_id;
@ -107,7 +107,7 @@ impl GridBlockMetaPad {
let cell_metas = rows let cell_metas = rows
.iter() .iter()
.flat_map(|row| { .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()) Some(cell_meta.clone())
}) })
.collect::<Vec<CellMeta>>(); .collect::<Vec<CellMeta>>();
@ -135,7 +135,7 @@ impl GridBlockMetaPad {
if !changeset.cell_by_field_id.is_empty() { if !changeset.cell_by_field_id.is_empty() {
is_changed = Some(()); is_changed = Some(());
changeset.cell_by_field_id.into_iter().for_each(|(field_id, cell)| { 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 { let row = RowMeta {
id: "1".to_string(), id: "1".to_string(),
block_id: pad.block_id.clone(), block_id: pad.block_id.clone(),
cell_by_field_id: Default::default(), cells: Default::default(),
height: 0, height: 0,
visibility: false, visibility: false,
}; };
@ -283,7 +283,7 @@ mod tests {
RowMeta { RowMeta {
id: id.to_string(), id: id.to_string(),
block_id: pad.block_id.clone(), block_id: pad.block_id.clone(),
cell_by_field_id: Default::default(), cells: Default::default(),
height: 0, height: 0,
visibility: false, visibility: false,
} }
@ -328,7 +328,7 @@ mod tests {
let row = RowMeta { let row = RowMeta {
id: "1".to_string(), id: "1".to_string(),
block_id: pad.block_id.clone(), block_id: pad.block_id.clone(),
cell_by_field_id: Default::default(), cells: Default::default(),
height: 0, height: 0,
visibility: false, visibility: false,
}; };
@ -349,7 +349,7 @@ mod tests {
let row = RowMeta { let row = RowMeta {
id: "1".to_string(), id: "1".to_string(),
block_id: pad.block_id.clone(), block_id: pad.block_id.clone(),
cell_by_field_id: Default::default(), cells: Default::default(),
height: 0, height: 0,
visibility: false, visibility: false,
}; };

View File

@ -28,7 +28,7 @@ impl GridBuilder {
fn check_rows(fields: &[FieldMeta], rows: &[RowMeta]) -> CollaborateResult<()> { fn check_rows(fields: &[FieldMeta], rows: &[RowMeta]) -> CollaborateResult<()> {
let field_ids = fields.iter().map(|field| &field.id).collect::<Vec<&String>>(); let field_ids = fields.iter().map(|field| &field.id).collect::<Vec<&String>>();
for row in rows { 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 { if cell_field_ids != field_ids {
let msg = format!("{:?} contains invalid cells", row); let msg = format!("{:?} contains invalid cells", row);
return Err(CollaborateError::internal().context(msg)); return Err(CollaborateError::internal().context(msg));