mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-24 14:47:13 -04:00
refactor: remove FieldTypeOptionContext
This commit is contained in:
parent
467e0093b2
commit
a59a0af05b
33 changed files with 401 additions and 320 deletions
|
@ -15,7 +15,7 @@ import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart' show EditFieldContext;
|
import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart' show FieldTypeOptionData;
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-grid/number_type_option.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-grid/number_type_option.pb.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
|
||||||
|
@ -157,7 +157,7 @@ void _resolveGridDeps(GetIt getIt) {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
getIt.registerFactoryParam<FieldEditorBloc, String, EditFieldContextLoader>(
|
getIt.registerFactoryParam<FieldEditorBloc, String, FieldContextLoader>(
|
||||||
(gridId, fieldLoader) => FieldEditorBloc(
|
(gridId, fieldLoader) => FieldEditorBloc(
|
||||||
gridId: gridId,
|
gridId: gridId,
|
||||||
fieldLoader: fieldLoader,
|
fieldLoader: fieldLoader,
|
||||||
|
@ -195,7 +195,7 @@ void _resolveGridDeps(GetIt getIt) {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
getIt.registerFactoryParam<FieldEditorPannelBloc, EditFieldContext, void>(
|
getIt.registerFactoryParam<FieldEditorPannelBloc, FieldTypeOptionData, void>(
|
||||||
(context, _) => FieldEditorPannelBloc(context),
|
(context, _) => FieldEditorPannelBloc(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,8 @@ class _GridCellContext<T, D> extends Equatable {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Either<List<int>, FlowyError>> getTypeOptionData() {
|
Future<Either<FieldTypeOptionData, FlowyError>> getTypeOptionData() {
|
||||||
return _fieldService.getTypeOptionData(fieldType: fieldType);
|
return _fieldService.getFieldTypeOptionData(fieldType: fieldType);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Option<FlowyError>> saveCellData(D data) {
|
Future<Option<FlowyError>> saveCellData(D data) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ class FieldActionSheetBloc extends Bloc<FieldActionSheetEvent, FieldActionSheetS
|
||||||
final FieldService fieldService;
|
final FieldService fieldService;
|
||||||
|
|
||||||
FieldActionSheetBloc({required Field field, required this.fieldService})
|
FieldActionSheetBloc({required Field field, required this.fieldService})
|
||||||
: super(FieldActionSheetState.initial(EditFieldContext.create()..gridField = field)) {
|
: super(FieldActionSheetState.initial(FieldTypeOptionData.create()..field_2 = field)) {
|
||||||
on<FieldActionSheetEvent>(
|
on<FieldActionSheetEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
await event.map(
|
await event.map(
|
||||||
|
@ -67,14 +67,14 @@ class FieldActionSheetEvent with _$FieldActionSheetEvent {
|
||||||
@freezed
|
@freezed
|
||||||
class FieldActionSheetState with _$FieldActionSheetState {
|
class FieldActionSheetState with _$FieldActionSheetState {
|
||||||
const factory FieldActionSheetState({
|
const factory FieldActionSheetState({
|
||||||
required EditFieldContext editContext,
|
required FieldTypeOptionData fieldTypeOptionData,
|
||||||
required String errorText,
|
required String errorText,
|
||||||
required String fieldName,
|
required String fieldName,
|
||||||
}) = _FieldActionSheetState;
|
}) = _FieldActionSheetState;
|
||||||
|
|
||||||
factory FieldActionSheetState.initial(EditFieldContext editContext) => FieldActionSheetState(
|
factory FieldActionSheetState.initial(FieldTypeOptionData data) => FieldActionSheetState(
|
||||||
editContext: editContext,
|
fieldTypeOptionData: data,
|
||||||
errorText: '',
|
errorText: '',
|
||||||
fieldName: editContext.gridField.name,
|
fieldName: data.field_2.name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,16 @@ class FieldCellBloc extends Bloc<FieldCellEvent, FieldCellState> {
|
||||||
super(FieldCellState.initial(cellContext)) {
|
super(FieldCellState.initial(cellContext)) {
|
||||||
on<FieldCellEvent>(
|
on<FieldCellEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
await event.map(
|
event.when(
|
||||||
initial: (_InitialCell value) async {
|
initial: () {
|
||||||
_startListening();
|
_startListening();
|
||||||
},
|
},
|
||||||
didReceiveFieldUpdate: (_DidReceiveFieldUpdate value) {
|
didReceiveFieldUpdate: (field) {
|
||||||
emit(state.copyWith(field: value.field));
|
emit(state.copyWith(field: field));
|
||||||
},
|
},
|
||||||
updateWidth: (_UpdateWidth value) {
|
updateWidth: (offset) {
|
||||||
final defaultWidth = state.field.width.toDouble();
|
final defaultWidth = state.field.width.toDouble();
|
||||||
final width = defaultWidth + value.offset;
|
final width = defaultWidth + offset;
|
||||||
if (width > defaultWidth && width < 300) {
|
if (width > defaultWidth && width < 300) {
|
||||||
_fieldService.updateField(width: width);
|
_fieldService.updateField(width: width);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,27 +12,26 @@ part 'field_editor_bloc.freezed.dart';
|
||||||
|
|
||||||
class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
||||||
final String gridId;
|
final String gridId;
|
||||||
final EditFieldContextLoader _loader;
|
final FieldContextLoader _loader;
|
||||||
|
|
||||||
FieldEditorBloc({
|
FieldEditorBloc({
|
||||||
required this.gridId,
|
required this.gridId,
|
||||||
required EditFieldContextLoader fieldLoader,
|
required FieldContextLoader fieldLoader,
|
||||||
}) : _loader = fieldLoader,
|
}) : _loader = fieldLoader,
|
||||||
super(FieldEditorState.initial(gridId)) {
|
super(FieldEditorState.initial(gridId)) {
|
||||||
on<FieldEditorEvent>(
|
on<FieldEditorEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
await event.map(
|
await event.map(
|
||||||
initial: (_InitialField value) async {
|
initial: (_InitialField value) async {
|
||||||
await _getEditFieldContext(emit);
|
await _getFieldTypeOptionContext(emit);
|
||||||
},
|
},
|
||||||
updateName: (_UpdateName value) {
|
updateName: (_UpdateName value) {
|
||||||
final newContext = _updateEditContext(name: value.name);
|
final newContext = _updateEditContext(name: value.name);
|
||||||
emit(state.copyWith(editFieldContext: newContext));
|
emit(state.copyWith(fieldTypeOptionData: newContext));
|
||||||
},
|
},
|
||||||
updateField: (_UpdateField value) {
|
updateField: (_UpdateField value) {
|
||||||
final newContext = _updateEditContext(field: value.field, typeOptionData: value.typeOptionData);
|
final data = _updateEditContext(field: value.field, typeOptionData: value.typeOptionData);
|
||||||
|
emit(state.copyWith(fieldTypeOptionData: data));
|
||||||
emit(state.copyWith(editFieldContext: newContext));
|
|
||||||
},
|
},
|
||||||
done: (_Done value) async {
|
done: (_Done value) async {
|
||||||
await _saveField(emit);
|
await _saveField(emit);
|
||||||
|
@ -47,26 +46,26 @@ class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Option<EditFieldContext> _updateEditContext({
|
Option<FieldTypeOptionData> _updateEditContext({
|
||||||
String? name,
|
String? name,
|
||||||
Field? field,
|
Field? field,
|
||||||
List<int>? typeOptionData,
|
List<int>? typeOptionData,
|
||||||
}) {
|
}) {
|
||||||
return state.editFieldContext.fold(
|
return state.fieldTypeOptionData.fold(
|
||||||
() => none(),
|
() => none(),
|
||||||
(context) {
|
(context) {
|
||||||
context.freeze();
|
context.freeze();
|
||||||
final newContext = context.rebuild((newContext) {
|
final newFieldTypeOptionData = context.rebuild((newContext) {
|
||||||
newContext.gridField.rebuild((newField) {
|
newContext.field_2.rebuild((newField) {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
newField.name = name;
|
newField.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
newContext.gridField = newField;
|
newContext.field_2 = newField;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
newContext.gridField = field;
|
newContext.field_2 = field;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeOptionData != null) {
|
if (typeOptionData != null) {
|
||||||
|
@ -76,35 +75,35 @@ class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
||||||
|
|
||||||
FieldService.insertField(
|
FieldService.insertField(
|
||||||
gridId: gridId,
|
gridId: gridId,
|
||||||
field: newContext.gridField,
|
field: newFieldTypeOptionData.field_2,
|
||||||
typeOptionData: newContext.typeOptionData,
|
typeOptionData: newFieldTypeOptionData.typeOptionData,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Some(newContext);
|
return Some(newFieldTypeOptionData);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _saveField(Emitter<FieldEditorState> emit) async {
|
Future<void> _saveField(Emitter<FieldEditorState> emit) async {
|
||||||
await state.editFieldContext.fold(
|
await state.fieldTypeOptionData.fold(
|
||||||
() async => null,
|
() async => null,
|
||||||
(context) async {
|
(data) async {
|
||||||
final result = await FieldService.insertField(
|
final result = await FieldService.insertField(
|
||||||
gridId: gridId,
|
gridId: gridId,
|
||||||
field: context.gridField,
|
field: data.field_2,
|
||||||
typeOptionData: context.typeOptionData,
|
typeOptionData: data.typeOptionData,
|
||||||
);
|
);
|
||||||
result.fold((l) => null, (r) => null);
|
result.fold((l) => null, (r) => null);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _getEditFieldContext(Emitter<FieldEditorState> emit) async {
|
Future<void> _getFieldTypeOptionContext(Emitter<FieldEditorState> emit) async {
|
||||||
final result = await _loader.load();
|
final result = await _loader.load();
|
||||||
result.fold(
|
result.fold(
|
||||||
(context) {
|
(context) {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
editFieldContext: Some(context),
|
fieldTypeOptionData: Some(context),
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
(err) => Log.error(err),
|
(err) => Log.error(err),
|
||||||
|
@ -125,12 +124,12 @@ class FieldEditorState with _$FieldEditorState {
|
||||||
const factory FieldEditorState({
|
const factory FieldEditorState({
|
||||||
required String gridId,
|
required String gridId,
|
||||||
required String errorText,
|
required String errorText,
|
||||||
required Option<EditFieldContext> editFieldContext,
|
required Option<FieldTypeOptionData> fieldTypeOptionData,
|
||||||
}) = _FieldEditorState;
|
}) = _FieldEditorState;
|
||||||
|
|
||||||
factory FieldEditorState.initial(String gridId) => FieldEditorState(
|
factory FieldEditorState.initial(String gridId) => FieldEditorState(
|
||||||
gridId: gridId,
|
gridId: gridId,
|
||||||
editFieldContext: none(),
|
fieldTypeOptionData: none(),
|
||||||
errorText: '',
|
errorText: '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import 'dart:async';
|
||||||
part 'field_editor_pannel_bloc.freezed.dart';
|
part 'field_editor_pannel_bloc.freezed.dart';
|
||||||
|
|
||||||
class FieldEditorPannelBloc extends Bloc<FieldEditorPannelEvent, FieldEditorPannelState> {
|
class FieldEditorPannelBloc extends Bloc<FieldEditorPannelEvent, FieldEditorPannelState> {
|
||||||
FieldEditorPannelBloc(EditFieldContext editContext) : super(FieldEditorPannelState.initial(editContext)) {
|
FieldEditorPannelBloc(FieldTypeOptionData editContext) : super(FieldEditorPannelState.initial(editContext)) {
|
||||||
on<FieldEditorPannelEvent>(
|
on<FieldEditorPannelEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
await event.map(
|
await event.map(
|
||||||
|
@ -45,9 +45,9 @@ class FieldEditorPannelState with _$FieldEditorPannelState {
|
||||||
required Uint8List typeOptionData,
|
required Uint8List typeOptionData,
|
||||||
}) = _FieldEditorPannelState;
|
}) = _FieldEditorPannelState;
|
||||||
|
|
||||||
factory FieldEditorPannelState.initial(EditFieldContext context) => FieldEditorPannelState(
|
factory FieldEditorPannelState.initial(FieldTypeOptionData data) => FieldEditorPannelState(
|
||||||
gridId: context.gridId,
|
gridId: data.gridId,
|
||||||
field: context.gridField,
|
field: data.field_2,
|
||||||
typeOptionData: Uint8List.fromList(context.typeOptionData),
|
typeOptionData: Uint8List.fromList(data.typeOptionData),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class FieldService {
|
||||||
|
|
||||||
FieldService({required this.gridId, required this.fieldId});
|
FieldService({required this.gridId, required this.fieldId});
|
||||||
|
|
||||||
Future<Either<EditFieldContext, FlowyError>> switchToField(FieldType fieldType) {
|
Future<Either<FieldTypeOptionData, FlowyError>> switchToField(FieldType fieldType) {
|
||||||
final payload = EditFieldPayload.create()
|
final payload = EditFieldPayload.create()
|
||||||
..gridId = gridId
|
..gridId = gridId
|
||||||
..fieldId = fieldId
|
..fieldId = fieldId
|
||||||
|
@ -21,15 +21,6 @@ class FieldService {
|
||||||
return GridEventSwitchToField(payload).send();
|
return GridEventSwitchToField(payload).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Either<EditFieldContext, FlowyError>> getEditFieldContext(FieldType fieldType) {
|
|
||||||
final payload = EditFieldPayload.create()
|
|
||||||
..gridId = gridId
|
|
||||||
..fieldId = fieldId
|
|
||||||
..fieldType = fieldType;
|
|
||||||
|
|
||||||
return GridEventGetEditFieldContext(payload).send();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Either<Unit, FlowyError>> moveField(int fromIndex, int toIndex) {
|
Future<Either<Unit, FlowyError>> moveField(int fromIndex, int toIndex) {
|
||||||
final payload = MoveItemPayload.create()
|
final payload = MoveItemPayload.create()
|
||||||
..gridId = gridId
|
..gridId = gridId
|
||||||
|
@ -128,7 +119,7 @@ class FieldService {
|
||||||
return GridEventDuplicateField(payload).send();
|
return GridEventDuplicateField(payload).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Either<List<int>, FlowyError>> getTypeOptionData({
|
Future<Either<FieldTypeOptionData, FlowyError>> getFieldTypeOptionData({
|
||||||
required FieldType fieldType,
|
required FieldType fieldType,
|
||||||
}) {
|
}) {
|
||||||
final payload = EditFieldPayload.create()
|
final payload = EditFieldPayload.create()
|
||||||
|
@ -137,7 +128,7 @@ class FieldService {
|
||||||
..fieldType = fieldType;
|
..fieldType = fieldType;
|
||||||
return GridEventGetFieldTypeOption(payload).send().then((result) {
|
return GridEventGetFieldTypeOption(payload).send().then((result) {
|
||||||
return result.fold(
|
return result.fold(
|
||||||
(data) => left(data.typeOptionData),
|
(data) => left(data),
|
||||||
(err) => right(err),
|
(err) => right(err),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -152,58 +143,58 @@ class GridFieldCellContext with _$GridFieldCellContext {
|
||||||
}) = _GridFieldCellContext;
|
}) = _GridFieldCellContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class EditFieldContextLoader {
|
abstract class FieldContextLoader {
|
||||||
Future<Either<EditFieldContext, FlowyError>> load();
|
Future<Either<FieldTypeOptionData, FlowyError>> load();
|
||||||
|
|
||||||
Future<Either<EditFieldContext, FlowyError>> switchToField(String fieldId, FieldType fieldType);
|
Future<Either<FieldTypeOptionData, FlowyError>> switchToField(String fieldId, FieldType fieldType);
|
||||||
}
|
}
|
||||||
|
|
||||||
class NewFieldContextLoader extends EditFieldContextLoader {
|
class NewFieldContextLoader extends FieldContextLoader {
|
||||||
final String gridId;
|
final String gridId;
|
||||||
NewFieldContextLoader({
|
NewFieldContextLoader({
|
||||||
required this.gridId,
|
required this.gridId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<EditFieldContext, FlowyError>> load() {
|
Future<Either<FieldTypeOptionData, FlowyError>> load() {
|
||||||
final payload = EditFieldPayload.create()
|
final payload = EditFieldPayload.create()
|
||||||
..gridId = gridId
|
..gridId = gridId
|
||||||
..fieldType = FieldType.RichText;
|
..fieldType = FieldType.RichText;
|
||||||
|
|
||||||
return GridEventGetEditFieldContext(payload).send();
|
return GridEventGetFieldTypeOption(payload).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<EditFieldContext, FlowyError>> switchToField(String fieldId, FieldType fieldType) {
|
Future<Either<FieldTypeOptionData, FlowyError>> switchToField(String fieldId, FieldType fieldType) {
|
||||||
final payload = EditFieldPayload.create()
|
final payload = EditFieldPayload.create()
|
||||||
..gridId = gridId
|
..gridId = gridId
|
||||||
..fieldType = fieldType;
|
..fieldType = fieldType;
|
||||||
|
|
||||||
return GridEventGetEditFieldContext(payload).send();
|
return GridEventGetFieldTypeOption(payload).send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FieldContextLoaderAdaptor extends EditFieldContextLoader {
|
class DefaultFieldContextLoader extends FieldContextLoader {
|
||||||
final String gridId;
|
final String gridId;
|
||||||
final Field field;
|
final Field field;
|
||||||
|
|
||||||
FieldContextLoaderAdaptor({
|
DefaultFieldContextLoader({
|
||||||
required this.gridId,
|
required this.gridId,
|
||||||
required this.field,
|
required this.field,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<EditFieldContext, FlowyError>> load() {
|
Future<Either<FieldTypeOptionData, FlowyError>> load() {
|
||||||
final payload = EditFieldPayload.create()
|
final payload = EditFieldPayload.create()
|
||||||
..gridId = gridId
|
..gridId = gridId
|
||||||
..fieldId = field.id
|
..fieldId = field.id
|
||||||
..fieldType = field.fieldType;
|
..fieldType = field.fieldType;
|
||||||
|
|
||||||
return GridEventGetEditFieldContext(payload).send();
|
return GridEventGetFieldTypeOption(payload).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<EditFieldContext, FlowyError>> switchToField(String fieldId, FieldType fieldType) async {
|
Future<Either<FieldTypeOptionData, FlowyError>> switchToField(String fieldId, FieldType fieldType) async {
|
||||||
final fieldService = FieldService(gridId: gridId, fieldId: fieldId);
|
final fieldService = FieldService(gridId: gridId, fieldId: fieldId);
|
||||||
return fieldService.switchToField(fieldType);
|
return fieldService.switchToField(fieldType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,18 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
part 'field_option_pannel_bloc.freezed.dart';
|
part 'select_option_type_option_bloc.freezed.dart';
|
||||||
|
|
||||||
class FieldOptionPannelBloc extends Bloc<FieldOptionPannelEvent, FieldOptionPannelState> {
|
class SelectOptionTypeOptionBloc extends Bloc<SelectOptionTypeOptionEvent, SelectOptionTyepOptionState> {
|
||||||
FieldOptionPannelBloc({required List<SelectOption> options}) : super(FieldOptionPannelState.initial(options)) {
|
SelectOptionTypeOptionBloc({required List<SelectOption> options})
|
||||||
on<FieldOptionPannelEvent>(
|
: super(SelectOptionTyepOptionState.initial(options)) {
|
||||||
|
on<SelectOptionTypeOptionEvent>(
|
||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
await event.map(
|
await event.map(
|
||||||
createOption: (_CreateOption value) async {
|
createOption: (_CreateOption value) async {
|
||||||
emit(state.copyWith(isEditingOption: false, newOptionName: Some(value.optionName)));
|
emit(state.copyWith(isEditingOption: true, newOptionName: Some(value.optionName)));
|
||||||
},
|
},
|
||||||
beginAddingOption: (_BeginAddingOption value) {
|
addingOption: (_AddingOption value) {
|
||||||
emit(state.copyWith(isEditingOption: true, newOptionName: none()));
|
emit(state.copyWith(isEditingOption: true, newOptionName: none()));
|
||||||
},
|
},
|
||||||
endAddingOption: (_EndAddingOption value) {
|
endAddingOption: (_EndAddingOption value) {
|
||||||
|
@ -37,25 +38,25 @@ class FieldOptionPannelBloc extends Bloc<FieldOptionPannelEvent, FieldOptionPann
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class FieldOptionPannelEvent with _$FieldOptionPannelEvent {
|
class SelectOptionTypeOptionEvent with _$SelectOptionTypeOptionEvent {
|
||||||
const factory FieldOptionPannelEvent.createOption(String optionName) = _CreateOption;
|
const factory SelectOptionTypeOptionEvent.createOption(String optionName) = _CreateOption;
|
||||||
const factory FieldOptionPannelEvent.beginAddingOption() = _BeginAddingOption;
|
const factory SelectOptionTypeOptionEvent.addingOption() = _AddingOption;
|
||||||
const factory FieldOptionPannelEvent.endAddingOption() = _EndAddingOption;
|
const factory SelectOptionTypeOptionEvent.endAddingOption() = _EndAddingOption;
|
||||||
const factory FieldOptionPannelEvent.updateOption(SelectOption option) = _UpdateOption;
|
const factory SelectOptionTypeOptionEvent.updateOption(SelectOption option) = _UpdateOption;
|
||||||
const factory FieldOptionPannelEvent.deleteOption(SelectOption option) = _DeleteOption;
|
const factory SelectOptionTypeOptionEvent.deleteOption(SelectOption option) = _DeleteOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class FieldOptionPannelState with _$FieldOptionPannelState {
|
class SelectOptionTyepOptionState with _$SelectOptionTyepOptionState {
|
||||||
const factory FieldOptionPannelState({
|
const factory SelectOptionTyepOptionState({
|
||||||
required List<SelectOption> options,
|
required List<SelectOption> options,
|
||||||
required bool isEditingOption,
|
required bool isEditingOption,
|
||||||
required Option<String> newOptionName,
|
required Option<String> newOptionName,
|
||||||
required Option<SelectOption> updateOption,
|
required Option<SelectOption> updateOption,
|
||||||
required Option<SelectOption> deleteOption,
|
required Option<SelectOption> deleteOption,
|
||||||
}) = _FieldOptionPannelState;
|
}) = _SelectOptionTyepOptionState;
|
||||||
|
|
||||||
factory FieldOptionPannelState.initial(List<SelectOption> options) => FieldOptionPannelState(
|
factory SelectOptionTyepOptionState.initial(List<SelectOption> options) => SelectOptionTyepOptionState(
|
||||||
options: options,
|
options: options,
|
||||||
isEditingOption: false,
|
isEditingOption: false,
|
||||||
newOptionName: none(),
|
newOptionName: none(),
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:app_flowy/workspace/application/grid/field/field_service.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
||||||
|
@ -32,13 +33,58 @@ class TypeOptionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class TypeOptionDataBuilder<T> {
|
||||||
|
T fromBuffer(List<int> buffer);
|
||||||
|
}
|
||||||
|
|
||||||
class TypeOptionContext {
|
class TypeOptionContext {
|
||||||
final String gridId;
|
final String gridId;
|
||||||
final Field field;
|
final Field field;
|
||||||
final Uint8List data;
|
final Uint8List data;
|
||||||
const TypeOptionContext({
|
|
||||||
|
TypeOptionContext({
|
||||||
required this.gridId,
|
required this.gridId,
|
||||||
required this.field,
|
required this.field,
|
||||||
required this.data,
|
required this.data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class TypeOptionFieldDelegate {
|
||||||
|
void onFieldChanged(void Function(String) callback);
|
||||||
|
void dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
class TypeOptionContext2<T> {
|
||||||
|
final String gridId;
|
||||||
|
final Field field;
|
||||||
|
final FieldService _fieldService;
|
||||||
|
T? _data;
|
||||||
|
final TypeOptionDataBuilder dataBuilder;
|
||||||
|
|
||||||
|
TypeOptionContext2({
|
||||||
|
required this.gridId,
|
||||||
|
required this.field,
|
||||||
|
required this.dataBuilder,
|
||||||
|
Uint8List? data,
|
||||||
|
}) : _fieldService = FieldService(gridId: gridId, fieldId: field.id) {
|
||||||
|
if (data != null) {
|
||||||
|
_data = dataBuilder.fromBuffer(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Either<T, FlowyError>> typeOptionData() {
|
||||||
|
if (_data != null) {
|
||||||
|
return Future(() => left(_data!));
|
||||||
|
}
|
||||||
|
|
||||||
|
return _fieldService.getFieldTypeOptionData(fieldType: field.fieldType).then((result) {
|
||||||
|
return result.fold(
|
||||||
|
(data) {
|
||||||
|
_data = dataBuilder.fromBuffer(data.typeOptionData);
|
||||||
|
return left(_data!);
|
||||||
|
},
|
||||||
|
(err) => right(err),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class DateCellEditor with FlowyOverlayDelegate {
|
||||||
(data) {
|
(data) {
|
||||||
final calendar = _CellCalendarWidget(
|
final calendar = _CellCalendarWidget(
|
||||||
cellContext: cellContext,
|
cellContext: cellContext,
|
||||||
dateTypeOption: DateTypeOption.fromBuffer(data),
|
dateTypeOption: DateTypeOption.fromBuffer(data.typeOptionData),
|
||||||
);
|
);
|
||||||
|
|
||||||
FlowyOverlay.of(context).insertWithAnchor(
|
FlowyOverlay.of(context).insertWithAnchor(
|
||||||
|
|
|
@ -37,7 +37,7 @@ class GridFieldCell extends StatelessWidget {
|
||||||
child: _DragToExpandLine(),
|
child: _DragToExpandLine(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return _CellContainer(
|
return _GridHeaderCellContainer(
|
||||||
width: state.field.width.toDouble(),
|
width: state.field.width.toDouble(),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
|
@ -63,7 +63,7 @@ class GridFieldCell extends StatelessWidget {
|
||||||
|
|
||||||
FieldEditor(
|
FieldEditor(
|
||||||
gridId: state.gridId,
|
gridId: state.gridId,
|
||||||
fieldContextLoader: FieldContextLoaderAdaptor(
|
contextLoader: DefaultFieldContextLoader(
|
||||||
gridId: state.gridId,
|
gridId: state.gridId,
|
||||||
field: state.field,
|
field: state.field,
|
||||||
),
|
),
|
||||||
|
@ -71,10 +71,10 @@ class GridFieldCell extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CellContainer extends StatelessWidget {
|
class _GridHeaderCellContainer extends StatelessWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final double width;
|
final double width;
|
||||||
const _CellContainer({
|
const _GridHeaderCellContainer({
|
||||||
required this.child,
|
required this.child,
|
||||||
required this.width,
|
required this.width,
|
||||||
Key? key,
|
Key? key,
|
||||||
|
|
|
@ -14,12 +14,12 @@ import 'field_editor_pannel.dart';
|
||||||
class FieldEditor extends FlowyOverlayDelegate {
|
class FieldEditor extends FlowyOverlayDelegate {
|
||||||
final String gridId;
|
final String gridId;
|
||||||
final FieldEditorBloc _fieldEditorBloc;
|
final FieldEditorBloc _fieldEditorBloc;
|
||||||
final EditFieldContextLoader fieldContextLoader;
|
final FieldContextLoader contextLoader;
|
||||||
FieldEditor({
|
FieldEditor({
|
||||||
required this.gridId,
|
required this.gridId,
|
||||||
required this.fieldContextLoader,
|
required this.contextLoader,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : _fieldEditorBloc = getIt<FieldEditorBloc>(param1: gridId, param2: fieldContextLoader) {
|
}) : _fieldEditorBloc = getIt<FieldEditorBloc>(param1: gridId, param2: contextLoader) {
|
||||||
_fieldEditorBloc.add(const FieldEditorEvent.initial());
|
_fieldEditorBloc.add(const FieldEditorEvent.initial());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,10 @@ class FieldEditor extends FlowyOverlayDelegate {
|
||||||
AnchorDirection anchorDirection = AnchorDirection.bottomWithLeftAligned,
|
AnchorDirection anchorDirection = AnchorDirection.bottomWithLeftAligned,
|
||||||
}) {
|
}) {
|
||||||
FlowyOverlay.of(context).remove(identifier());
|
FlowyOverlay.of(context).remove(identifier());
|
||||||
|
final child = _FieldEditorPage(_fieldEditorBloc, contextLoader);
|
||||||
FlowyOverlay.of(context).insertWithAnchor(
|
FlowyOverlay.of(context).insertWithAnchor(
|
||||||
widget: OverlayContainer(
|
widget: OverlayContainer(
|
||||||
child: _FieldEditorWidget(_fieldEditorBloc, fieldContextLoader),
|
child: child,
|
||||||
constraints: BoxConstraints.loose(const Size(280, 400)),
|
constraints: BoxConstraints.loose(const Size(280, 400)),
|
||||||
),
|
),
|
||||||
identifier: identifier(),
|
identifier: identifier(),
|
||||||
|
@ -54,10 +55,10 @@ class FieldEditor extends FlowyOverlayDelegate {
|
||||||
bool asBarrier() => true;
|
bool asBarrier() => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FieldEditorWidget extends StatelessWidget {
|
class _FieldEditorPage extends StatelessWidget {
|
||||||
final FieldEditorBloc editorBloc;
|
final FieldEditorBloc editorBloc;
|
||||||
final EditFieldContextLoader fieldContextLoader;
|
final FieldContextLoader contextLoader;
|
||||||
const _FieldEditorWidget(this.editorBloc, this.fieldContextLoader, {Key? key}) : super(key: key);
|
const _FieldEditorPage(this.editorBloc, this.contextLoader, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -65,9 +66,9 @@ class _FieldEditorWidget extends StatelessWidget {
|
||||||
value: editorBloc,
|
value: editorBloc,
|
||||||
child: BlocBuilder<FieldEditorBloc, FieldEditorState>(
|
child: BlocBuilder<FieldEditorBloc, FieldEditorState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return state.editFieldContext.fold(
|
return state.fieldTypeOptionData.fold(
|
||||||
() => const SizedBox(),
|
() => const SizedBox(),
|
||||||
(editFieldContext) => ListView(
|
(fieldTypeOptionContext) => ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
children: [
|
children: [
|
||||||
FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), fontSize: 12),
|
FlowyText.medium(LocaleKeys.grid_field_editProperty.tr(), fontSize: 12),
|
||||||
|
@ -75,9 +76,9 @@ class _FieldEditorWidget extends StatelessWidget {
|
||||||
const _FieldNameTextField(),
|
const _FieldNameTextField(),
|
||||||
const VSpace(10),
|
const VSpace(10),
|
||||||
FieldEditorPannel(
|
FieldEditorPannel(
|
||||||
editFieldContext: editFieldContext,
|
fieldTypeOptionData: fieldTypeOptionContext,
|
||||||
onSwitchToField: (fieldId, fieldType) {
|
onSwitchToField: (fieldId, fieldType) {
|
||||||
return fieldContextLoader.switchToField(fieldId, fieldType);
|
return contextLoader.switchToField(fieldId, fieldType);
|
||||||
},
|
},
|
||||||
onUpdated: (field, typeOptionData) {
|
onUpdated: (field, typeOptionData) {
|
||||||
context.read<FieldEditorBloc>().add(FieldEditorEvent.updateField(field, typeOptionData));
|
context.read<FieldEditorBloc>().add(FieldEditorEvent.updateField(field, typeOptionData));
|
||||||
|
@ -99,9 +100,9 @@ class _FieldNameTextField extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocSelector<FieldEditorBloc, FieldEditorState, String>(
|
return BlocSelector<FieldEditorBloc, FieldEditorState, String>(
|
||||||
selector: (state) {
|
selector: (state) {
|
||||||
return state.editFieldContext.fold(
|
return state.fieldTypeOptionData.fold(
|
||||||
() => "",
|
() => "",
|
||||||
(editFieldContext) => editFieldContext.gridField.name,
|
(fieldTypeOptionContext) => fieldTypeOptionContext.field_2.name,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
builder: (context, name) {
|
builder: (context, name) {
|
||||||
|
|
|
@ -25,18 +25,18 @@ import 'type_option/number.dart';
|
||||||
import 'type_option/single_select.dart';
|
import 'type_option/single_select.dart';
|
||||||
|
|
||||||
typedef UpdateFieldCallback = void Function(Field, Uint8List);
|
typedef UpdateFieldCallback = void Function(Field, Uint8List);
|
||||||
typedef SwitchToFieldCallback = Future<Either<EditFieldContext, FlowyError>> Function(
|
typedef SwitchToFieldCallback = Future<Either<FieldTypeOptionData, FlowyError>> Function(
|
||||||
String fieldId,
|
String fieldId,
|
||||||
FieldType fieldType,
|
FieldType fieldType,
|
||||||
);
|
);
|
||||||
|
|
||||||
class FieldEditorPannel extends StatefulWidget {
|
class FieldEditorPannel extends StatefulWidget {
|
||||||
final EditFieldContext editFieldContext;
|
final FieldTypeOptionData fieldTypeOptionData;
|
||||||
final UpdateFieldCallback onUpdated;
|
final UpdateFieldCallback onUpdated;
|
||||||
final SwitchToFieldCallback onSwitchToField;
|
final SwitchToFieldCallback onSwitchToField;
|
||||||
|
|
||||||
const FieldEditorPannel({
|
const FieldEditorPannel({
|
||||||
required this.editFieldContext,
|
required this.fieldTypeOptionData,
|
||||||
required this.onUpdated,
|
required this.onUpdated,
|
||||||
required this.onSwitchToField,
|
required this.onSwitchToField,
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -52,7 +52,7 @@ class _FieldEditorPannelState extends State<FieldEditorPannel> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => getIt<FieldEditorPannelBloc>(param1: widget.editFieldContext),
|
create: (context) => getIt<FieldEditorPannelBloc>(param1: widget.fieldTypeOptionData),
|
||||||
child: BlocConsumer<FieldEditorPannelBloc, FieldEditorPannelState>(
|
child: BlocConsumer<FieldEditorPannelBloc, FieldEditorPannelState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
widget.onUpdated(state.field, state.typeOptionData);
|
widget.onUpdated(state.field, state.typeOptionData);
|
||||||
|
@ -86,11 +86,11 @@ class _FieldEditorPannelState extends State<FieldEditorPannel> {
|
||||||
final list = FieldTypeList(onSelectField: (newFieldType) {
|
final list = FieldTypeList(onSelectField: (newFieldType) {
|
||||||
widget.onSwitchToField(field.id, newFieldType).then((result) {
|
widget.onSwitchToField(field.id, newFieldType).then((result) {
|
||||||
result.fold(
|
result.fold(
|
||||||
(editFieldContext) {
|
(fieldTypeOptionContext) {
|
||||||
context.read<FieldEditorPannelBloc>().add(
|
context.read<FieldEditorPannelBloc>().add(
|
||||||
FieldEditorPannelEvent.toFieldType(
|
FieldEditorPannelEvent.toFieldType(
|
||||||
editFieldContext.gridField,
|
fieldTypeOptionContext.field_2,
|
||||||
editFieldContext.typeOptionData,
|
fieldTypeOptionContext.typeOptionData,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -150,7 +150,7 @@ class CreateFieldButton extends StatelessWidget {
|
||||||
hoverColor: theme.hover,
|
hoverColor: theme.hover,
|
||||||
onTap: () => FieldEditor(
|
onTap: () => FieldEditor(
|
||||||
gridId: gridId,
|
gridId: gridId,
|
||||||
fieldContextLoader: NewFieldContextLoader(gridId: gridId),
|
contextLoader: NewFieldContextLoader(gridId: gridId),
|
||||||
).show(context),
|
).show(context),
|
||||||
leftIcon: svgWidget("home/add"),
|
leftIcon: svgWidget("home/add"),
|
||||||
);
|
);
|
||||||
|
|
|
@ -58,7 +58,7 @@ class MultiSelectTypeOptionWidget extends TypeOptionWidget {
|
||||||
context.read<MultiSelectTypeOptionBloc>().add(MultiSelectTypeOptionEvent.deleteOption(deleteOption));
|
context.read<MultiSelectTypeOptionBloc>().add(MultiSelectTypeOptionEvent.deleteOption(deleteOption));
|
||||||
},
|
},
|
||||||
overlayDelegate: overlayDelegate,
|
overlayDelegate: overlayDelegate,
|
||||||
key: ValueKey(state.typeOption.hashCode),
|
// key: ValueKey(state.typeOption.hashCode),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:app_flowy/workspace/application/grid/field/type_option/field_option_pannel_bloc.dart';
|
import 'package:app_flowy/workspace/application/grid/field/type_option/select_option_type_option_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart';
|
import 'package:app_flowy/workspace/presentation/plugins/grid/src/layout/sizes.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart';
|
import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/common/text_field.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_editor_pannel.dart';
|
import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header/field_editor_pannel.dart';
|
||||||
|
@ -36,8 +36,8 @@ class SelectOptionTypeOptionWidget extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => FieldOptionPannelBloc(options: options),
|
create: (context) => SelectOptionTypeOptionBloc(options: options),
|
||||||
child: BlocConsumer<FieldOptionPannelBloc, FieldOptionPannelState>(
|
child: BlocConsumer<SelectOptionTypeOptionBloc, SelectOptionTyepOptionState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state.isEditingOption) {
|
if (state.isEditingOption) {
|
||||||
beginEdit();
|
beginEdit();
|
||||||
|
@ -61,18 +61,10 @@ class SelectOptionTypeOptionWidget extends StatelessWidget {
|
||||||
List<Widget> children = [
|
List<Widget> children = [
|
||||||
const TypeOptionSeparator(),
|
const TypeOptionSeparator(),
|
||||||
const OptionTitle(),
|
const OptionTitle(),
|
||||||
|
if (state.isEditingOption) const _CreateOptionTextField(),
|
||||||
|
if (state.options.isEmpty && !state.isEditingOption) const _AddOptionButton(),
|
||||||
|
_OptionList(overlayDelegate)
|
||||||
];
|
];
|
||||||
if (state.isEditingOption) {
|
|
||||||
children.add(const _OptionNameTextField());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.options.isEmpty && !state.isEditingOption) {
|
|
||||||
children.add(const _AddOptionButton());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.options.isNotEmpty) {
|
|
||||||
children.add(_OptionList(overlayDelegate));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Column(children: children);
|
return Column(children: children);
|
||||||
},
|
},
|
||||||
|
@ -86,12 +78,12 @@ class OptionTitle extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<FieldOptionPannelBloc, FieldOptionPannelState>(
|
return BlocBuilder<SelectOptionTypeOptionBloc, SelectOptionTyepOptionState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
List<Widget> children = [FlowyText.medium(LocaleKeys.grid_field_optionTitle.tr(), fontSize: 12)];
|
List<Widget> children = [FlowyText.medium(LocaleKeys.grid_field_optionTitle.tr(), fontSize: 12)];
|
||||||
if (state.options.isNotEmpty) {
|
if (state.options.isNotEmpty) {
|
||||||
children.add(const Spacer());
|
children.add(const Spacer());
|
||||||
children.add(const _OptionTitleAddOptionButton());
|
children.add(const _OptionTitleButton());
|
||||||
}
|
}
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
|
@ -103,8 +95,8 @@ class OptionTitle extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _OptionTitleAddOptionButton extends StatelessWidget {
|
class _OptionTitleButton extends StatelessWidget {
|
||||||
const _OptionTitleAddOptionButton({Key? key}) : super(key: key);
|
const _OptionTitleButton({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -120,7 +112,7 @@ class _OptionTitleAddOptionButton extends StatelessWidget {
|
||||||
),
|
),
|
||||||
hoverColor: theme.hover,
|
hoverColor: theme.hover,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<FieldOptionPannelBloc>().add(const FieldOptionPannelEvent.beginAddingOption());
|
context.read<SelectOptionTypeOptionBloc>().add(const SelectOptionTypeOptionEvent.addingOption());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -133,7 +125,7 @@ class _OptionList extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<FieldOptionPannelBloc, FieldOptionPannelState>(
|
return BlocBuilder<SelectOptionTypeOptionBloc, SelectOptionTyepOptionState>(
|
||||||
buildWhen: (previous, current) {
|
buildWhen: (previous, current) {
|
||||||
return previous.options != current.options;
|
return previous.options != current.options;
|
||||||
},
|
},
|
||||||
|
@ -160,16 +152,16 @@ class _OptionList extends StatelessWidget {
|
||||||
_OptionCell _makeOptionCell(BuildContext context, SelectOption option) {
|
_OptionCell _makeOptionCell(BuildContext context, SelectOption option) {
|
||||||
return _OptionCell(
|
return _OptionCell(
|
||||||
option: option,
|
option: option,
|
||||||
onEdited: (option) {
|
onSelected: (option) {
|
||||||
final pannel = SelectOptionTypeOptionEditor(
|
final pannel = SelectOptionTypeOptionEditor(
|
||||||
option: option,
|
option: option,
|
||||||
onDeleted: () {
|
onDeleted: () {
|
||||||
delegate.hideOverlay(context);
|
delegate.hideOverlay(context);
|
||||||
context.read<FieldOptionPannelBloc>().add(FieldOptionPannelEvent.deleteOption(option));
|
context.read<SelectOptionTypeOptionBloc>().add(SelectOptionTypeOptionEvent.deleteOption(option));
|
||||||
},
|
},
|
||||||
onUpdated: (updatedOption) {
|
onUpdated: (updatedOption) {
|
||||||
delegate.hideOverlay(context);
|
delegate.hideOverlay(context);
|
||||||
context.read<FieldOptionPannelBloc>().add(FieldOptionPannelEvent.updateOption(updatedOption));
|
context.read<SelectOptionTypeOptionBloc>().add(SelectOptionTypeOptionEvent.updateOption(updatedOption));
|
||||||
},
|
},
|
||||||
key: ValueKey(option.id),
|
key: ValueKey(option.id),
|
||||||
);
|
);
|
||||||
|
@ -181,10 +173,10 @@ class _OptionList extends StatelessWidget {
|
||||||
|
|
||||||
class _OptionCell extends StatelessWidget {
|
class _OptionCell extends StatelessWidget {
|
||||||
final SelectOption option;
|
final SelectOption option;
|
||||||
final Function(SelectOption) onEdited;
|
final Function(SelectOption) onSelected;
|
||||||
const _OptionCell({
|
const _OptionCell({
|
||||||
required this.option,
|
required this.option,
|
||||||
required this.onEdited,
|
required this.onSelected,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@ -196,7 +188,7 @@ class _OptionCell extends StatelessWidget {
|
||||||
child: FlowyButton(
|
child: FlowyButton(
|
||||||
text: FlowyText.medium(option.name, fontSize: 12),
|
text: FlowyText.medium(option.name, fontSize: 12),
|
||||||
hoverColor: theme.hover,
|
hoverColor: theme.hover,
|
||||||
onTap: () => onEdited(option),
|
onTap: () => onSelected(option),
|
||||||
rightIcon: svgWidget("grid/details", color: theme.iconColor),
|
rightIcon: svgWidget("grid/details", color: theme.iconColor),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -215,7 +207,7 @@ class _AddOptionButton extends StatelessWidget {
|
||||||
text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr(), fontSize: 12),
|
text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr(), fontSize: 12),
|
||||||
hoverColor: theme.hover,
|
hoverColor: theme.hover,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<FieldOptionPannelBloc>().add(const FieldOptionPannelEvent.beginAddingOption());
|
context.read<SelectOptionTypeOptionBloc>().add(const SelectOptionTypeOptionEvent.addingOption());
|
||||||
},
|
},
|
||||||
leftIcon: svgWidget("home/add", color: theme.iconColor),
|
leftIcon: svgWidget("home/add", color: theme.iconColor),
|
||||||
),
|
),
|
||||||
|
@ -223,18 +215,18 @@ class _AddOptionButton extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _OptionNameTextField extends StatelessWidget {
|
class _CreateOptionTextField extends StatelessWidget {
|
||||||
const _OptionNameTextField({Key? key}) : super(key: key);
|
const _CreateOptionTextField({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InputTextField(
|
return InputTextField(
|
||||||
text: "",
|
text: "",
|
||||||
onCanceled: () {
|
onCanceled: () {
|
||||||
context.read<FieldOptionPannelBloc>().add(const FieldOptionPannelEvent.endAddingOption());
|
context.read<SelectOptionTypeOptionBloc>().add(const SelectOptionTypeOptionEvent.endAddingOption());
|
||||||
},
|
},
|
||||||
onDone: (optionName) {
|
onDone: (optionName) {
|
||||||
context.read<FieldOptionPannelBloc>().add(FieldOptionPannelEvent.createOption(optionName));
|
context.read<SelectOptionTypeOptionBloc>().add(SelectOptionTypeOptionEvent.createOption(optionName));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ class SingleSelectTypeOptionWidget extends TypeOptionWidget {
|
||||||
context.read<SingleSelectTypeOptionBloc>().add(SingleSelectTypeOptionEvent.deleteOption(deleteOption));
|
context.read<SingleSelectTypeOptionBloc>().add(SingleSelectTypeOptionEvent.deleteOption(deleteOption));
|
||||||
},
|
},
|
||||||
overlayDelegate: overlayDelegate,
|
overlayDelegate: overlayDelegate,
|
||||||
key: ValueKey(state.typeOption.hashCode),
|
// key: ValueKey(state.typeOption.hashCode),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -178,7 +178,7 @@ class _RowDetailCell extends StatelessWidget {
|
||||||
void _showFieldEditor(BuildContext context) {
|
void _showFieldEditor(BuildContext context) {
|
||||||
FieldEditor(
|
FieldEditor(
|
||||||
gridId: gridCell.gridId,
|
gridId: gridCell.gridId,
|
||||||
fieldContextLoader: FieldContextLoaderAdaptor(
|
contextLoader: DefaultFieldContextLoader(
|
||||||
gridId: gridCell.gridId,
|
gridId: gridCell.gridId,
|
||||||
field: gridCell.field,
|
field: gridCell.field,
|
||||||
),
|
),
|
||||||
|
|
|
@ -115,7 +115,7 @@ class _GridPropertyCell extends StatelessWidget {
|
||||||
onTap: () {
|
onTap: () {
|
||||||
FieldEditor(
|
FieldEditor(
|
||||||
gridId: gridId,
|
gridId: gridId,
|
||||||
fieldContextLoader: FieldContextLoaderAdaptor(gridId: gridId, field: field),
|
contextLoader: DefaultFieldContextLoader(gridId: gridId, field: field),
|
||||||
).show(context, anchorDirection: AnchorDirection.bottomRight);
|
).show(context, anchorDirection: AnchorDirection.bottomRight);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -124,14 +124,14 @@ class GridEventSwitchToField {
|
||||||
EditFieldPayload request;
|
EditFieldPayload request;
|
||||||
GridEventSwitchToField(this.request);
|
GridEventSwitchToField(this.request);
|
||||||
|
|
||||||
Future<Either<EditFieldContext, FlowyError>> send() {
|
Future<Either<FieldTypeOptionData, FlowyError>> send() {
|
||||||
final request = FFIRequest.create()
|
final request = FFIRequest.create()
|
||||||
..event = GridEvent.SwitchToField.toString()
|
..event = GridEvent.SwitchToField.toString()
|
||||||
..payload = requestToBytes(this.request);
|
..payload = requestToBytes(this.request);
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
return Dispatch.asyncRequest(request)
|
||||||
.then((bytesResult) => bytesResult.fold(
|
.then((bytesResult) => bytesResult.fold(
|
||||||
(okBytes) => left(EditFieldContext.fromBuffer(okBytes)),
|
(okBytes) => left(FieldTypeOptionData.fromBuffer(okBytes)),
|
||||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -154,23 +154,6 @@ class GridEventDuplicateField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GridEventGetEditFieldContext {
|
|
||||||
EditFieldPayload request;
|
|
||||||
GridEventGetEditFieldContext(this.request);
|
|
||||||
|
|
||||||
Future<Either<EditFieldContext, FlowyError>> send() {
|
|
||||||
final request = FFIRequest.create()
|
|
||||||
..event = GridEvent.GetEditFieldContext.toString()
|
|
||||||
..payload = requestToBytes(this.request);
|
|
||||||
|
|
||||||
return Dispatch.asyncRequest(request)
|
|
||||||
.then((bytesResult) => bytesResult.fold(
|
|
||||||
(okBytes) => left(EditFieldContext.fromBuffer(okBytes)),
|
|
||||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GridEventMoveItem {
|
class GridEventMoveItem {
|
||||||
MoveItemPayload request;
|
MoveItemPayload request;
|
||||||
GridEventMoveItem(this.request);
|
GridEventMoveItem(this.request);
|
||||||
|
|
|
@ -578,16 +578,16 @@ class EditFieldPayload extends $pb.GeneratedMessage {
|
||||||
void clearFieldType() => clearField(3);
|
void clearFieldType() => clearField(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditFieldContext extends $pb.GeneratedMessage {
|
class FieldTypeOptionContext extends $pb.GeneratedMessage {
|
||||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'EditFieldContext', createEmptyInstance: create)
|
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FieldTypeOptionContext', createEmptyInstance: create)
|
||||||
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'gridId')
|
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'gridId')
|
||||||
..aOM<Field>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'gridField', subBuilder: Field.create)
|
..aOM<Field>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'gridField', subBuilder: Field.create)
|
||||||
..a<$core.List<$core.int>>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'typeOptionData', $pb.PbFieldType.OY)
|
..a<$core.List<$core.int>>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'typeOptionData', $pb.PbFieldType.OY)
|
||||||
..hasRequiredFields = false
|
..hasRequiredFields = false
|
||||||
;
|
;
|
||||||
|
|
||||||
EditFieldContext._() : super();
|
FieldTypeOptionContext._() : super();
|
||||||
factory EditFieldContext({
|
factory FieldTypeOptionContext({
|
||||||
$core.String? gridId,
|
$core.String? gridId,
|
||||||
Field? gridField,
|
Field? gridField,
|
||||||
$core.List<$core.int>? typeOptionData,
|
$core.List<$core.int>? typeOptionData,
|
||||||
|
@ -604,26 +604,26 @@ class EditFieldContext extends $pb.GeneratedMessage {
|
||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
}
|
}
|
||||||
factory EditFieldContext.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
factory FieldTypeOptionContext.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||||
factory EditFieldContext.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
factory FieldTypeOptionContext.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||||
@$core.Deprecated(
|
@$core.Deprecated(
|
||||||
'Using this can add significant overhead to your binary. '
|
'Using this can add significant overhead to your binary. '
|
||||||
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
|
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
|
||||||
'Will be removed in next major version')
|
'Will be removed in next major version')
|
||||||
EditFieldContext clone() => EditFieldContext()..mergeFromMessage(this);
|
FieldTypeOptionContext clone() => FieldTypeOptionContext()..mergeFromMessage(this);
|
||||||
@$core.Deprecated(
|
@$core.Deprecated(
|
||||||
'Using this can add significant overhead to your binary. '
|
'Using this can add significant overhead to your binary. '
|
||||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||||
'Will be removed in next major version')
|
'Will be removed in next major version')
|
||||||
EditFieldContext copyWith(void Function(EditFieldContext) updates) => super.copyWith((message) => updates(message as EditFieldContext)) as EditFieldContext; // ignore: deprecated_member_use
|
FieldTypeOptionContext copyWith(void Function(FieldTypeOptionContext) updates) => super.copyWith((message) => updates(message as FieldTypeOptionContext)) as FieldTypeOptionContext; // ignore: deprecated_member_use
|
||||||
$pb.BuilderInfo get info_ => _i;
|
$pb.BuilderInfo get info_ => _i;
|
||||||
@$core.pragma('dart2js:noInline')
|
@$core.pragma('dart2js:noInline')
|
||||||
static EditFieldContext create() => EditFieldContext._();
|
static FieldTypeOptionContext create() => FieldTypeOptionContext._();
|
||||||
EditFieldContext createEmptyInstance() => create();
|
FieldTypeOptionContext createEmptyInstance() => create();
|
||||||
static $pb.PbList<EditFieldContext> createRepeated() => $pb.PbList<EditFieldContext>();
|
static $pb.PbList<FieldTypeOptionContext> createRepeated() => $pb.PbList<FieldTypeOptionContext>();
|
||||||
@$core.pragma('dart2js:noInline')
|
@$core.pragma('dart2js:noInline')
|
||||||
static EditFieldContext getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<EditFieldContext>(create);
|
static FieldTypeOptionContext getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<FieldTypeOptionContext>(create);
|
||||||
static EditFieldContext? _defaultInstance;
|
static FieldTypeOptionContext? _defaultInstance;
|
||||||
|
|
||||||
@$pb.TagNumber(1)
|
@$pb.TagNumber(1)
|
||||||
$core.String get gridId => $_getSZ(0);
|
$core.String get gridId => $_getSZ(0);
|
||||||
|
@ -657,19 +657,24 @@ class EditFieldContext extends $pb.GeneratedMessage {
|
||||||
|
|
||||||
class FieldTypeOptionData extends $pb.GeneratedMessage {
|
class FieldTypeOptionData extends $pb.GeneratedMessage {
|
||||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FieldTypeOptionData', createEmptyInstance: create)
|
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FieldTypeOptionData', createEmptyInstance: create)
|
||||||
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'fieldId')
|
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'gridId')
|
||||||
..a<$core.List<$core.int>>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'typeOptionData', $pb.PbFieldType.OY)
|
..aOM<Field>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'field', subBuilder: Field.create)
|
||||||
|
..a<$core.List<$core.int>>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'typeOptionData', $pb.PbFieldType.OY)
|
||||||
..hasRequiredFields = false
|
..hasRequiredFields = false
|
||||||
;
|
;
|
||||||
|
|
||||||
FieldTypeOptionData._() : super();
|
FieldTypeOptionData._() : super();
|
||||||
factory FieldTypeOptionData({
|
factory FieldTypeOptionData({
|
||||||
$core.String? fieldId,
|
$core.String? gridId,
|
||||||
|
Field? field_2,
|
||||||
$core.List<$core.int>? typeOptionData,
|
$core.List<$core.int>? typeOptionData,
|
||||||
}) {
|
}) {
|
||||||
final _result = create();
|
final _result = create();
|
||||||
if (fieldId != null) {
|
if (gridId != null) {
|
||||||
_result.fieldId = fieldId;
|
_result.gridId = gridId;
|
||||||
|
}
|
||||||
|
if (field_2 != null) {
|
||||||
|
_result.field_2 = field_2;
|
||||||
}
|
}
|
||||||
if (typeOptionData != null) {
|
if (typeOptionData != null) {
|
||||||
_result.typeOptionData = typeOptionData;
|
_result.typeOptionData = typeOptionData;
|
||||||
|
@ -698,22 +703,33 @@ class FieldTypeOptionData extends $pb.GeneratedMessage {
|
||||||
static FieldTypeOptionData? _defaultInstance;
|
static FieldTypeOptionData? _defaultInstance;
|
||||||
|
|
||||||
@$pb.TagNumber(1)
|
@$pb.TagNumber(1)
|
||||||
$core.String get fieldId => $_getSZ(0);
|
$core.String get gridId => $_getSZ(0);
|
||||||
@$pb.TagNumber(1)
|
@$pb.TagNumber(1)
|
||||||
set fieldId($core.String v) { $_setString(0, v); }
|
set gridId($core.String v) { $_setString(0, v); }
|
||||||
@$pb.TagNumber(1)
|
@$pb.TagNumber(1)
|
||||||
$core.bool hasFieldId() => $_has(0);
|
$core.bool hasGridId() => $_has(0);
|
||||||
@$pb.TagNumber(1)
|
@$pb.TagNumber(1)
|
||||||
void clearFieldId() => clearField(1);
|
void clearGridId() => clearField(1);
|
||||||
|
|
||||||
@$pb.TagNumber(2)
|
@$pb.TagNumber(2)
|
||||||
$core.List<$core.int> get typeOptionData => $_getN(1);
|
Field get field_2 => $_getN(1);
|
||||||
@$pb.TagNumber(2)
|
@$pb.TagNumber(2)
|
||||||
set typeOptionData($core.List<$core.int> v) { $_setBytes(1, v); }
|
set field_2(Field v) { setField(2, v); }
|
||||||
@$pb.TagNumber(2)
|
@$pb.TagNumber(2)
|
||||||
$core.bool hasTypeOptionData() => $_has(1);
|
$core.bool hasField_2() => $_has(1);
|
||||||
@$pb.TagNumber(2)
|
@$pb.TagNumber(2)
|
||||||
void clearTypeOptionData() => clearField(2);
|
void clearField_2() => clearField(2);
|
||||||
|
@$pb.TagNumber(2)
|
||||||
|
Field ensureField_2() => $_ensure(1);
|
||||||
|
|
||||||
|
@$pb.TagNumber(3)
|
||||||
|
$core.List<$core.int> get typeOptionData => $_getN(2);
|
||||||
|
@$pb.TagNumber(3)
|
||||||
|
set typeOptionData($core.List<$core.int> v) { $_setBytes(2, v); }
|
||||||
|
@$pb.TagNumber(3)
|
||||||
|
$core.bool hasTypeOptionData() => $_has(2);
|
||||||
|
@$pb.TagNumber(3)
|
||||||
|
void clearTypeOptionData() => clearField(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RepeatedField extends $pb.GeneratedMessage {
|
class RepeatedField extends $pb.GeneratedMessage {
|
||||||
|
|
|
@ -127,9 +127,9 @@ const EditFieldPayload$json = const {
|
||||||
|
|
||||||
/// Descriptor for `EditFieldPayload`. Decode as a `google.protobuf.DescriptorProto`.
|
/// Descriptor for `EditFieldPayload`. Decode as a `google.protobuf.DescriptorProto`.
|
||||||
final $typed_data.Uint8List editFieldPayloadDescriptor = $convert.base64Decode('ChBFZGl0RmllbGRQYXlsb2FkEhcKB2dyaWRfaWQYASABKAlSBmdyaWRJZBIbCghmaWVsZF9pZBgCIAEoCUgAUgdmaWVsZElkEikKCmZpZWxkX3R5cGUYAyABKA4yCi5GaWVsZFR5cGVSCWZpZWxkVHlwZUIRCg9vbmVfb2ZfZmllbGRfaWQ=');
|
final $typed_data.Uint8List editFieldPayloadDescriptor = $convert.base64Decode('ChBFZGl0RmllbGRQYXlsb2FkEhcKB2dyaWRfaWQYASABKAlSBmdyaWRJZBIbCghmaWVsZF9pZBgCIAEoCUgAUgdmaWVsZElkEikKCmZpZWxkX3R5cGUYAyABKA4yCi5GaWVsZFR5cGVSCWZpZWxkVHlwZUIRCg9vbmVfb2ZfZmllbGRfaWQ=');
|
||||||
@$core.Deprecated('Use editFieldContextDescriptor instead')
|
@$core.Deprecated('Use fieldTypeOptionContextDescriptor instead')
|
||||||
const EditFieldContext$json = const {
|
const FieldTypeOptionContext$json = const {
|
||||||
'1': 'EditFieldContext',
|
'1': 'FieldTypeOptionContext',
|
||||||
'2': const [
|
'2': const [
|
||||||
const {'1': 'grid_id', '3': 1, '4': 1, '5': 9, '10': 'gridId'},
|
const {'1': 'grid_id', '3': 1, '4': 1, '5': 9, '10': 'gridId'},
|
||||||
const {'1': 'grid_field', '3': 2, '4': 1, '5': 11, '6': '.Field', '10': 'gridField'},
|
const {'1': 'grid_field', '3': 2, '4': 1, '5': 11, '6': '.Field', '10': 'gridField'},
|
||||||
|
@ -137,19 +137,20 @@ const EditFieldContext$json = const {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Descriptor for `EditFieldContext`. Decode as a `google.protobuf.DescriptorProto`.
|
/// Descriptor for `FieldTypeOptionContext`. Decode as a `google.protobuf.DescriptorProto`.
|
||||||
final $typed_data.Uint8List editFieldContextDescriptor = $convert.base64Decode('ChBFZGl0RmllbGRDb250ZXh0EhcKB2dyaWRfaWQYASABKAlSBmdyaWRJZBIlCgpncmlkX2ZpZWxkGAIgASgLMgYuRmllbGRSCWdyaWRGaWVsZBIoChB0eXBlX29wdGlvbl9kYXRhGAMgASgMUg50eXBlT3B0aW9uRGF0YQ==');
|
final $typed_data.Uint8List fieldTypeOptionContextDescriptor = $convert.base64Decode('ChZGaWVsZFR5cGVPcHRpb25Db250ZXh0EhcKB2dyaWRfaWQYASABKAlSBmdyaWRJZBIlCgpncmlkX2ZpZWxkGAIgASgLMgYuRmllbGRSCWdyaWRGaWVsZBIoChB0eXBlX29wdGlvbl9kYXRhGAMgASgMUg50eXBlT3B0aW9uRGF0YQ==');
|
||||||
@$core.Deprecated('Use fieldTypeOptionDataDescriptor instead')
|
@$core.Deprecated('Use fieldTypeOptionDataDescriptor instead')
|
||||||
const FieldTypeOptionData$json = const {
|
const FieldTypeOptionData$json = const {
|
||||||
'1': 'FieldTypeOptionData',
|
'1': 'FieldTypeOptionData',
|
||||||
'2': const [
|
'2': const [
|
||||||
const {'1': 'field_id', '3': 1, '4': 1, '5': 9, '10': 'fieldId'},
|
const {'1': 'grid_id', '3': 1, '4': 1, '5': 9, '10': 'gridId'},
|
||||||
const {'1': 'type_option_data', '3': 2, '4': 1, '5': 12, '10': 'typeOptionData'},
|
const {'1': 'field', '3': 2, '4': 1, '5': 11, '6': '.Field', '10': 'field'},
|
||||||
|
const {'1': 'type_option_data', '3': 3, '4': 1, '5': 12, '10': 'typeOptionData'},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Descriptor for `FieldTypeOptionData`. Decode as a `google.protobuf.DescriptorProto`.
|
/// Descriptor for `FieldTypeOptionData`. Decode as a `google.protobuf.DescriptorProto`.
|
||||||
final $typed_data.Uint8List fieldTypeOptionDataDescriptor = $convert.base64Decode('ChNGaWVsZFR5cGVPcHRpb25EYXRhEhkKCGZpZWxkX2lkGAEgASgJUgdmaWVsZElkEigKEHR5cGVfb3B0aW9uX2RhdGEYAiABKAxSDnR5cGVPcHRpb25EYXRh');
|
final $typed_data.Uint8List fieldTypeOptionDataDescriptor = $convert.base64Decode('ChNGaWVsZFR5cGVPcHRpb25EYXRhEhcKB2dyaWRfaWQYASABKAlSBmdyaWRJZBIcCgVmaWVsZBgCIAEoCzIGLkZpZWxkUgVmaWVsZBIoChB0eXBlX29wdGlvbl9kYXRhGAMgASgMUg50eXBlT3B0aW9uRGF0YQ==');
|
||||||
@$core.Deprecated('Use repeatedFieldDescriptor instead')
|
@$core.Deprecated('Use repeatedFieldDescriptor instead')
|
||||||
const RepeatedField$json = const {
|
const RepeatedField$json = const {
|
||||||
'1': 'RepeatedField',
|
'1': 'RepeatedField',
|
||||||
|
|
|
@ -19,9 +19,8 @@ class GridEvent extends $pb.ProtobufEnum {
|
||||||
static const GridEvent DeleteField = GridEvent._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DeleteField');
|
static const GridEvent DeleteField = GridEvent._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DeleteField');
|
||||||
static const GridEvent SwitchToField = GridEvent._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SwitchToField');
|
static const GridEvent SwitchToField = GridEvent._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SwitchToField');
|
||||||
static const GridEvent DuplicateField = GridEvent._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DuplicateField');
|
static const GridEvent DuplicateField = GridEvent._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DuplicateField');
|
||||||
static const GridEvent GetEditFieldContext = GridEvent._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetEditFieldContext');
|
static const GridEvent MoveItem = GridEvent._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'MoveItem');
|
||||||
static const GridEvent MoveItem = GridEvent._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'MoveItem');
|
static const GridEvent GetFieldTypeOption = GridEvent._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetFieldTypeOption');
|
||||||
static const GridEvent GetFieldTypeOption = GridEvent._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetFieldTypeOption');
|
|
||||||
static const GridEvent NewSelectOption = GridEvent._(30, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'NewSelectOption');
|
static const GridEvent NewSelectOption = GridEvent._(30, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'NewSelectOption');
|
||||||
static const GridEvent GetSelectOptionCellData = GridEvent._(31, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetSelectOptionCellData');
|
static const GridEvent GetSelectOptionCellData = GridEvent._(31, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetSelectOptionCellData');
|
||||||
static const GridEvent UpdateSelectOption = GridEvent._(32, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UpdateSelectOption');
|
static const GridEvent UpdateSelectOption = GridEvent._(32, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UpdateSelectOption');
|
||||||
|
@ -45,7 +44,6 @@ class GridEvent extends $pb.ProtobufEnum {
|
||||||
DeleteField,
|
DeleteField,
|
||||||
SwitchToField,
|
SwitchToField,
|
||||||
DuplicateField,
|
DuplicateField,
|
||||||
GetEditFieldContext,
|
|
||||||
MoveItem,
|
MoveItem,
|
||||||
GetFieldTypeOption,
|
GetFieldTypeOption,
|
||||||
NewSelectOption,
|
NewSelectOption,
|
||||||
|
|
|
@ -21,9 +21,8 @@ const GridEvent$json = const {
|
||||||
const {'1': 'DeleteField', '2': 14},
|
const {'1': 'DeleteField', '2': 14},
|
||||||
const {'1': 'SwitchToField', '2': 20},
|
const {'1': 'SwitchToField', '2': 20},
|
||||||
const {'1': 'DuplicateField', '2': 21},
|
const {'1': 'DuplicateField', '2': 21},
|
||||||
const {'1': 'GetEditFieldContext', '2': 22},
|
const {'1': 'MoveItem', '2': 22},
|
||||||
const {'1': 'MoveItem', '2': 23},
|
const {'1': 'GetFieldTypeOption', '2': 23},
|
||||||
const {'1': 'GetFieldTypeOption', '2': 24},
|
|
||||||
const {'1': 'NewSelectOption', '2': 30},
|
const {'1': 'NewSelectOption', '2': 30},
|
||||||
const {'1': 'GetSelectOptionCellData', '2': 31},
|
const {'1': 'GetSelectOptionCellData', '2': 31},
|
||||||
const {'1': 'UpdateSelectOption', '2': 32},
|
const {'1': 'UpdateSelectOption', '2': 32},
|
||||||
|
@ -40,4 +39,4 @@ const GridEvent$json = const {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Descriptor for `GridEvent`. Decode as a `google.protobuf.EnumDescriptorProto`.
|
/// Descriptor for `GridEvent`. Decode as a `google.protobuf.EnumDescriptorProto`.
|
||||||
final $typed_data.Uint8List gridEventDescriptor = $convert.base64Decode('CglHcmlkRXZlbnQSDwoLR2V0R3JpZERhdGEQABIRCg1HZXRHcmlkQmxvY2tzEAESDQoJR2V0RmllbGRzEAoSDwoLVXBkYXRlRmllbGQQCxIZChVVcGRhdGVGaWVsZFR5cGVPcHRpb24QDBIPCgtJbnNlcnRGaWVsZBANEg8KC0RlbGV0ZUZpZWxkEA4SEQoNU3dpdGNoVG9GaWVsZBAUEhIKDkR1cGxpY2F0ZUZpZWxkEBUSFwoTR2V0RWRpdEZpZWxkQ29udGV4dBAWEgwKCE1vdmVJdGVtEBcSFgoSR2V0RmllbGRUeXBlT3B0aW9uEBgSEwoPTmV3U2VsZWN0T3B0aW9uEB4SGwoXR2V0U2VsZWN0T3B0aW9uQ2VsbERhdGEQHxIWChJVcGRhdGVTZWxlY3RPcHRpb24QIBINCglDcmVhdGVSb3cQMhIKCgZHZXRSb3cQMxINCglEZWxldGVSb3cQNBIQCgxEdXBsaWNhdGVSb3cQNRILCgdHZXRDZWxsEEYSDgoKVXBkYXRlQ2VsbBBHEhoKFlVwZGF0ZVNlbGVjdE9wdGlvbkNlbGwQSBISCg5VcGRhdGVEYXRlQ2VsbBBQEhMKD0dldERhdGVDZWxsRGF0YRBa');
|
final $typed_data.Uint8List gridEventDescriptor = $convert.base64Decode('CglHcmlkRXZlbnQSDwoLR2V0R3JpZERhdGEQABIRCg1HZXRHcmlkQmxvY2tzEAESDQoJR2V0RmllbGRzEAoSDwoLVXBkYXRlRmllbGQQCxIZChVVcGRhdGVGaWVsZFR5cGVPcHRpb24QDBIPCgtJbnNlcnRGaWVsZBANEg8KC0RlbGV0ZUZpZWxkEA4SEQoNU3dpdGNoVG9GaWVsZBAUEhIKDkR1cGxpY2F0ZUZpZWxkEBUSDAoITW92ZUl0ZW0QFhIWChJHZXRGaWVsZFR5cGVPcHRpb24QFxITCg9OZXdTZWxlY3RPcHRpb24QHhIbChdHZXRTZWxlY3RPcHRpb25DZWxsRGF0YRAfEhYKElVwZGF0ZVNlbGVjdE9wdGlvbhAgEg0KCUNyZWF0ZVJvdxAyEgoKBkdldFJvdxAzEg0KCURlbGV0ZVJvdxA0EhAKDER1cGxpY2F0ZVJvdxA1EgsKB0dldENlbGwQRhIOCgpVcGRhdGVDZWxsEEcSGgoWVXBkYXRlU2VsZWN0T3B0aW9uQ2VsbBBIEhIKDlVwZGF0ZURhdGVDZWxsEFASEwoPR2V0RGF0ZUNlbGxEYXRhEFo=');
|
||||||
|
|
|
@ -98,7 +98,7 @@ pub(crate) async fn delete_field_handler(
|
||||||
pub(crate) async fn switch_to_field_handler(
|
pub(crate) async fn switch_to_field_handler(
|
||||||
data: Data<EditFieldPayload>,
|
data: Data<EditFieldPayload>,
|
||||||
manager: AppData<Arc<GridManager>>,
|
manager: AppData<Arc<GridManager>>,
|
||||||
) -> DataResult<EditFieldContext, FlowyError> {
|
) -> DataResult<FieldTypeOptionData, FlowyError> {
|
||||||
let params: EditFieldParams = data.into_inner().try_into()?;
|
let params: EditFieldParams = data.into_inner().try_into()?;
|
||||||
if params.field_id.is_none() {
|
if params.field_id.is_none() {
|
||||||
return Err(ErrorCode::FieldIdIsEmpty.into());
|
return Err(ErrorCode::FieldIdIsEmpty.into());
|
||||||
|
@ -107,9 +107,9 @@ pub(crate) async fn switch_to_field_handler(
|
||||||
let editor = manager.get_grid_editor(¶ms.grid_id)?;
|
let editor = manager.get_grid_editor(¶ms.grid_id)?;
|
||||||
editor.switch_to_field_type(&field_id, ¶ms.field_type).await?;
|
editor.switch_to_field_type(&field_id, ¶ms.field_type).await?;
|
||||||
let field_meta = editor.get_field_meta(&field_id).await;
|
let field_meta = editor.get_field_meta(&field_id).await;
|
||||||
let edit_context =
|
let data =
|
||||||
make_edit_field_context(¶ms.grid_id, Some(field_id), params.field_type, editor, field_meta).await?;
|
make_field_type_option_data(¶ms.grid_id, Some(field_id), params.field_type, editor, field_meta).await?;
|
||||||
data_result(edit_context)
|
data_result(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||||
|
@ -123,19 +123,6 @@ pub(crate) async fn duplicate_field_handler(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
|
||||||
pub(crate) async fn get_field_context_handler(
|
|
||||||
data: Data<EditFieldPayload>,
|
|
||||||
manager: AppData<Arc<GridManager>>,
|
|
||||||
) -> DataResult<EditFieldContext, FlowyError> {
|
|
||||||
let params: EditFieldParams = data.into_inner().try_into()?;
|
|
||||||
let editor = manager.get_grid_editor(¶ms.grid_id)?;
|
|
||||||
let edit_context =
|
|
||||||
make_edit_field_context(¶ms.grid_id, params.field_id, params.field_type, editor, None).await?;
|
|
||||||
|
|
||||||
data_result(edit_context)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||||
pub(crate) async fn get_field_type_option_data_handler(
|
pub(crate) async fn get_field_type_option_data_handler(
|
||||||
data: Data<EditFieldPayload>,
|
data: Data<EditFieldPayload>,
|
||||||
|
@ -147,7 +134,8 @@ pub(crate) async fn get_field_type_option_data_handler(
|
||||||
let type_option_data = get_type_option_data(&field_meta, &field_meta.field_type).await?;
|
let type_option_data = get_type_option_data(&field_meta, &field_meta.field_type).await?;
|
||||||
|
|
||||||
data_result(FieldTypeOptionData {
|
data_result(FieldTypeOptionData {
|
||||||
field_id: field_meta.id.clone(),
|
grid_id: params.grid_id,
|
||||||
|
field: field_meta.into(),
|
||||||
type_option_data,
|
type_option_data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -163,23 +151,24 @@ pub(crate) async fn move_item_handler(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn make_edit_field_context(
|
async fn make_field_type_option_data(
|
||||||
grid_id: &str,
|
grid_id: &str,
|
||||||
field_id: Option<String>,
|
field_id: Option<String>,
|
||||||
field_type: FieldType,
|
field_type: FieldType,
|
||||||
editor: Arc<ClientGridEditor>,
|
editor: Arc<ClientGridEditor>,
|
||||||
field_meta: Option<FieldMeta>,
|
field_meta: Option<FieldMeta>,
|
||||||
) -> FlowyResult<EditFieldContext> {
|
) -> FlowyResult<FieldTypeOptionData> {
|
||||||
let field_meta = field_meta.unwrap_or(get_or_create_field_meta(field_id, &field_type, editor).await?);
|
let field_meta = field_meta.unwrap_or(get_or_create_field_meta(field_id, &field_type, editor).await?);
|
||||||
let type_option_data = get_type_option_data(&field_meta, &field_type).await?;
|
let type_option_data = get_type_option_data(&field_meta, &field_type).await?;
|
||||||
let field: Field = field_meta.into();
|
|
||||||
Ok(EditFieldContext {
|
Ok(FieldTypeOptionData {
|
||||||
grid_id: grid_id.to_string(),
|
grid_id: grid_id.to_string(),
|
||||||
grid_field: field,
|
field: field_meta.into(),
|
||||||
type_option_data,
|
type_option_data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The FieldMeta contains multiple data, each of them belongs to a specific FieldType.
|
||||||
async fn get_type_option_data(field_meta: &FieldMeta, field_type: &FieldType) -> FlowyResult<Vec<u8>> {
|
async fn get_type_option_data(field_meta: &FieldMeta, field_type: &FieldType) -> FlowyResult<Vec<u8>> {
|
||||||
let s = field_meta
|
let s = field_meta
|
||||||
.get_type_option_str(field_type)
|
.get_type_option_str(field_type)
|
||||||
|
|
|
@ -18,7 +18,6 @@ pub fn create(grid_manager: Arc<GridManager>) -> Module {
|
||||||
.event(GridEvent::DeleteField, delete_field_handler)
|
.event(GridEvent::DeleteField, delete_field_handler)
|
||||||
.event(GridEvent::SwitchToField, switch_to_field_handler)
|
.event(GridEvent::SwitchToField, switch_to_field_handler)
|
||||||
.event(GridEvent::DuplicateField, duplicate_field_handler)
|
.event(GridEvent::DuplicateField, duplicate_field_handler)
|
||||||
.event(GridEvent::GetEditFieldContext, get_field_context_handler)
|
|
||||||
.event(GridEvent::MoveItem, move_item_handler)
|
.event(GridEvent::MoveItem, move_item_handler)
|
||||||
.event(GridEvent::GetFieldTypeOption, get_field_type_option_data_handler)
|
.event(GridEvent::GetFieldTypeOption, get_field_type_option_data_handler)
|
||||||
// Row
|
// Row
|
||||||
|
@ -65,20 +64,17 @@ pub enum GridEvent {
|
||||||
#[event(input = "FieldIdentifierPayload")]
|
#[event(input = "FieldIdentifierPayload")]
|
||||||
DeleteField = 14,
|
DeleteField = 14,
|
||||||
|
|
||||||
#[event(input = "EditFieldPayload", output = "EditFieldContext")]
|
#[event(input = "EditFieldPayload", output = "FieldTypeOptionData")]
|
||||||
SwitchToField = 20,
|
SwitchToField = 20,
|
||||||
|
|
||||||
#[event(input = "FieldIdentifierPayload")]
|
#[event(input = "FieldIdentifierPayload")]
|
||||||
DuplicateField = 21,
|
DuplicateField = 21,
|
||||||
|
|
||||||
#[event(input = "EditFieldPayload", output = "EditFieldContext")]
|
|
||||||
GetEditFieldContext = 22,
|
|
||||||
|
|
||||||
#[event(input = "MoveItemPayload")]
|
#[event(input = "MoveItemPayload")]
|
||||||
MoveItem = 23,
|
MoveItem = 22,
|
||||||
|
|
||||||
#[event(input = "EditFieldPayload", output = "FieldTypeOptionData")]
|
#[event(input = "EditFieldPayload", output = "FieldTypeOptionData")]
|
||||||
GetFieldTypeOption = 24,
|
GetFieldTypeOption = 23,
|
||||||
|
|
||||||
#[event(input = "CreateSelectOptionPayload", output = "SelectOption")]
|
#[event(input = "CreateSelectOptionPayload", output = "SelectOption")]
|
||||||
NewSelectOption = 30,
|
NewSelectOption = 30,
|
||||||
|
|
|
@ -34,9 +34,8 @@ pub enum GridEvent {
|
||||||
DeleteField = 14,
|
DeleteField = 14,
|
||||||
SwitchToField = 20,
|
SwitchToField = 20,
|
||||||
DuplicateField = 21,
|
DuplicateField = 21,
|
||||||
GetEditFieldContext = 22,
|
MoveItem = 22,
|
||||||
MoveItem = 23,
|
GetFieldTypeOption = 23,
|
||||||
GetFieldTypeOption = 24,
|
|
||||||
NewSelectOption = 30,
|
NewSelectOption = 30,
|
||||||
GetSelectOptionCellData = 31,
|
GetSelectOptionCellData = 31,
|
||||||
UpdateSelectOption = 32,
|
UpdateSelectOption = 32,
|
||||||
|
@ -67,9 +66,8 @@ impl ::protobuf::ProtobufEnum for GridEvent {
|
||||||
14 => ::std::option::Option::Some(GridEvent::DeleteField),
|
14 => ::std::option::Option::Some(GridEvent::DeleteField),
|
||||||
20 => ::std::option::Option::Some(GridEvent::SwitchToField),
|
20 => ::std::option::Option::Some(GridEvent::SwitchToField),
|
||||||
21 => ::std::option::Option::Some(GridEvent::DuplicateField),
|
21 => ::std::option::Option::Some(GridEvent::DuplicateField),
|
||||||
22 => ::std::option::Option::Some(GridEvent::GetEditFieldContext),
|
22 => ::std::option::Option::Some(GridEvent::MoveItem),
|
||||||
23 => ::std::option::Option::Some(GridEvent::MoveItem),
|
23 => ::std::option::Option::Some(GridEvent::GetFieldTypeOption),
|
||||||
24 => ::std::option::Option::Some(GridEvent::GetFieldTypeOption),
|
|
||||||
30 => ::std::option::Option::Some(GridEvent::NewSelectOption),
|
30 => ::std::option::Option::Some(GridEvent::NewSelectOption),
|
||||||
31 => ::std::option::Option::Some(GridEvent::GetSelectOptionCellData),
|
31 => ::std::option::Option::Some(GridEvent::GetSelectOptionCellData),
|
||||||
32 => ::std::option::Option::Some(GridEvent::UpdateSelectOption),
|
32 => ::std::option::Option::Some(GridEvent::UpdateSelectOption),
|
||||||
|
@ -97,7 +95,6 @@ impl ::protobuf::ProtobufEnum for GridEvent {
|
||||||
GridEvent::DeleteField,
|
GridEvent::DeleteField,
|
||||||
GridEvent::SwitchToField,
|
GridEvent::SwitchToField,
|
||||||
GridEvent::DuplicateField,
|
GridEvent::DuplicateField,
|
||||||
GridEvent::GetEditFieldContext,
|
|
||||||
GridEvent::MoveItem,
|
GridEvent::MoveItem,
|
||||||
GridEvent::GetFieldTypeOption,
|
GridEvent::GetFieldTypeOption,
|
||||||
GridEvent::NewSelectOption,
|
GridEvent::NewSelectOption,
|
||||||
|
@ -140,18 +137,18 @@ impl ::protobuf::reflect::ProtobufValue for GridEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||||
\n\x0fevent_map.proto*\xda\x03\n\tGridEvent\x12\x0f\n\x0bGetGridData\x10\
|
\n\x0fevent_map.proto*\xc1\x03\n\tGridEvent\x12\x0f\n\x0bGetGridData\x10\
|
||||||
\0\x12\x11\n\rGetGridBlocks\x10\x01\x12\r\n\tGetFields\x10\n\x12\x0f\n\
|
\0\x12\x11\n\rGetGridBlocks\x10\x01\x12\r\n\tGetFields\x10\n\x12\x0f\n\
|
||||||
\x0bUpdateField\x10\x0b\x12\x19\n\x15UpdateFieldTypeOption\x10\x0c\x12\
|
\x0bUpdateField\x10\x0b\x12\x19\n\x15UpdateFieldTypeOption\x10\x0c\x12\
|
||||||
\x0f\n\x0bInsertField\x10\r\x12\x0f\n\x0bDeleteField\x10\x0e\x12\x11\n\r\
|
\x0f\n\x0bInsertField\x10\r\x12\x0f\n\x0bDeleteField\x10\x0e\x12\x11\n\r\
|
||||||
SwitchToField\x10\x14\x12\x12\n\x0eDuplicateField\x10\x15\x12\x17\n\x13G\
|
SwitchToField\x10\x14\x12\x12\n\x0eDuplicateField\x10\x15\x12\x0c\n\x08M\
|
||||||
etEditFieldContext\x10\x16\x12\x0c\n\x08MoveItem\x10\x17\x12\x16\n\x12Ge\
|
oveItem\x10\x16\x12\x16\n\x12GetFieldTypeOption\x10\x17\x12\x13\n\x0fNew\
|
||||||
tFieldTypeOption\x10\x18\x12\x13\n\x0fNewSelectOption\x10\x1e\x12\x1b\n\
|
SelectOption\x10\x1e\x12\x1b\n\x17GetSelectOptionCellData\x10\x1f\x12\
|
||||||
\x17GetSelectOptionCellData\x10\x1f\x12\x16\n\x12UpdateSelectOption\x10\
|
\x16\n\x12UpdateSelectOption\x10\x20\x12\r\n\tCreateRow\x102\x12\n\n\x06\
|
||||||
\x20\x12\r\n\tCreateRow\x102\x12\n\n\x06GetRow\x103\x12\r\n\tDeleteRow\
|
GetRow\x103\x12\r\n\tDeleteRow\x104\x12\x10\n\x0cDuplicateRow\x105\x12\
|
||||||
\x104\x12\x10\n\x0cDuplicateRow\x105\x12\x0b\n\x07GetCell\x10F\x12\x0e\n\
|
\x0b\n\x07GetCell\x10F\x12\x0e\n\nUpdateCell\x10G\x12\x1a\n\x16UpdateSel\
|
||||||
\nUpdateCell\x10G\x12\x1a\n\x16UpdateSelectOptionCell\x10H\x12\x12\n\x0e\
|
ectOptionCell\x10H\x12\x12\n\x0eUpdateDateCell\x10P\x12\x13\n\x0fGetDate\
|
||||||
UpdateDateCell\x10P\x12\x13\n\x0fGetDateCellData\x10Zb\x06proto3\
|
CellData\x10Zb\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;
|
||||||
|
|
|
@ -10,9 +10,8 @@ enum GridEvent {
|
||||||
DeleteField = 14;
|
DeleteField = 14;
|
||||||
SwitchToField = 20;
|
SwitchToField = 20;
|
||||||
DuplicateField = 21;
|
DuplicateField = 21;
|
||||||
GetEditFieldContext = 22;
|
MoveItem = 22;
|
||||||
MoveItem = 23;
|
GetFieldTypeOption = 23;
|
||||||
GetFieldTypeOption = 24;
|
|
||||||
NewSelectOption = 30;
|
NewSelectOption = 30;
|
||||||
GetSelectOptionCellData = 31;
|
GetSelectOptionCellData = 31;
|
||||||
UpdateSelectOption = 32;
|
UpdateSelectOption = 32;
|
||||||
|
|
|
@ -195,7 +195,7 @@ impl TryInto<EditFieldParams> for EditFieldPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, ProtoBuf)]
|
#[derive(Debug, Default, ProtoBuf)]
|
||||||
pub struct EditFieldContext {
|
pub struct FieldTypeOptionContext {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
pub grid_id: String,
|
pub grid_id: String,
|
||||||
|
|
||||||
|
@ -209,9 +209,12 @@ pub struct EditFieldContext {
|
||||||
#[derive(Debug, Default, ProtoBuf)]
|
#[derive(Debug, Default, ProtoBuf)]
|
||||||
pub struct FieldTypeOptionData {
|
pub struct FieldTypeOptionData {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
pub field_id: String,
|
pub grid_id: String,
|
||||||
|
|
||||||
#[pb(index = 2)]
|
#[pb(index = 2)]
|
||||||
|
pub field_id: String,
|
||||||
|
|
||||||
|
#[pb(index = 3)]
|
||||||
pub type_option_data: Vec<u8>,
|
pub type_option_data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1913,7 +1913,7 @@ impl ::protobuf::reflect::ProtobufValue for EditFieldPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq,Clone,Default)]
|
#[derive(PartialEq,Clone,Default)]
|
||||||
pub struct EditFieldContext {
|
pub struct FieldTypeOptionContext {
|
||||||
// message fields
|
// message fields
|
||||||
pub grid_id: ::std::string::String,
|
pub grid_id: ::std::string::String,
|
||||||
pub grid_field: ::protobuf::SingularPtrField<Field>,
|
pub grid_field: ::protobuf::SingularPtrField<Field>,
|
||||||
|
@ -1923,14 +1923,14 @@ pub struct EditFieldContext {
|
||||||
pub cached_size: ::protobuf::CachedSize,
|
pub cached_size: ::protobuf::CachedSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::std::default::Default for &'a EditFieldContext {
|
impl<'a> ::std::default::Default for &'a FieldTypeOptionContext {
|
||||||
fn default() -> &'a EditFieldContext {
|
fn default() -> &'a FieldTypeOptionContext {
|
||||||
<EditFieldContext as ::protobuf::Message>::default_instance()
|
<FieldTypeOptionContext as ::protobuf::Message>::default_instance()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EditFieldContext {
|
impl FieldTypeOptionContext {
|
||||||
pub fn new() -> EditFieldContext {
|
pub fn new() -> FieldTypeOptionContext {
|
||||||
::std::default::Default::default()
|
::std::default::Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2020,7 +2020,7 @@ impl EditFieldContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::protobuf::Message for EditFieldContext {
|
impl ::protobuf::Message for FieldTypeOptionContext {
|
||||||
fn is_initialized(&self) -> bool {
|
fn is_initialized(&self) -> bool {
|
||||||
for v in &self.grid_field {
|
for v in &self.grid_field {
|
||||||
if !v.is_initialized() {
|
if !v.is_initialized() {
|
||||||
|
@ -2112,8 +2112,8 @@ impl ::protobuf::Message for EditFieldContext {
|
||||||
Self::descriptor_static()
|
Self::descriptor_static()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new() -> EditFieldContext {
|
fn new() -> FieldTypeOptionContext {
|
||||||
EditFieldContext::new()
|
FieldTypeOptionContext::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||||
|
@ -2122,34 +2122,34 @@ impl ::protobuf::Message for EditFieldContext {
|
||||||
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>(
|
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||||
"grid_id",
|
"grid_id",
|
||||||
|m: &EditFieldContext| { &m.grid_id },
|
|m: &FieldTypeOptionContext| { &m.grid_id },
|
||||||
|m: &mut EditFieldContext| { &mut m.grid_id },
|
|m: &mut FieldTypeOptionContext| { &mut m.grid_id },
|
||||||
));
|
));
|
||||||
fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<Field>>(
|
fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<Field>>(
|
||||||
"grid_field",
|
"grid_field",
|
||||||
|m: &EditFieldContext| { &m.grid_field },
|
|m: &FieldTypeOptionContext| { &m.grid_field },
|
||||||
|m: &mut EditFieldContext| { &mut m.grid_field },
|
|m: &mut FieldTypeOptionContext| { &mut m.grid_field },
|
||||||
));
|
));
|
||||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>(
|
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>(
|
||||||
"type_option_data",
|
"type_option_data",
|
||||||
|m: &EditFieldContext| { &m.type_option_data },
|
|m: &FieldTypeOptionContext| { &m.type_option_data },
|
||||||
|m: &mut EditFieldContext| { &mut m.type_option_data },
|
|m: &mut FieldTypeOptionContext| { &mut m.type_option_data },
|
||||||
));
|
));
|
||||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<EditFieldContext>(
|
::protobuf::reflect::MessageDescriptor::new_pb_name::<FieldTypeOptionContext>(
|
||||||
"EditFieldContext",
|
"FieldTypeOptionContext",
|
||||||
fields,
|
fields,
|
||||||
file_descriptor_proto()
|
file_descriptor_proto()
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_instance() -> &'static EditFieldContext {
|
fn default_instance() -> &'static FieldTypeOptionContext {
|
||||||
static instance: ::protobuf::rt::LazyV2<EditFieldContext> = ::protobuf::rt::LazyV2::INIT;
|
static instance: ::protobuf::rt::LazyV2<FieldTypeOptionContext> = ::protobuf::rt::LazyV2::INIT;
|
||||||
instance.get(EditFieldContext::new)
|
instance.get(FieldTypeOptionContext::new)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::protobuf::Clear for EditFieldContext {
|
impl ::protobuf::Clear for FieldTypeOptionContext {
|
||||||
fn clear(&mut self) {
|
fn clear(&mut self) {
|
||||||
self.grid_id.clear();
|
self.grid_id.clear();
|
||||||
self.grid_field.clear();
|
self.grid_field.clear();
|
||||||
|
@ -2158,13 +2158,13 @@ impl ::protobuf::Clear for EditFieldContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Debug for EditFieldContext {
|
impl ::std::fmt::Debug for FieldTypeOptionContext {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
::protobuf::text_format::fmt(self, f)
|
::protobuf::text_format::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::protobuf::reflect::ProtobufValue for EditFieldContext {
|
impl ::protobuf::reflect::ProtobufValue for FieldTypeOptionContext {
|
||||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||||
}
|
}
|
||||||
|
@ -2173,6 +2173,7 @@ impl ::protobuf::reflect::ProtobufValue for EditFieldContext {
|
||||||
#[derive(PartialEq,Clone,Default)]
|
#[derive(PartialEq,Clone,Default)]
|
||||||
pub struct FieldTypeOptionData {
|
pub struct FieldTypeOptionData {
|
||||||
// message fields
|
// message fields
|
||||||
|
pub grid_id: ::std::string::String,
|
||||||
pub field_id: ::std::string::String,
|
pub field_id: ::std::string::String,
|
||||||
pub type_option_data: ::std::vec::Vec<u8>,
|
pub type_option_data: ::std::vec::Vec<u8>,
|
||||||
// special fields
|
// special fields
|
||||||
|
@ -2191,7 +2192,33 @@ impl FieldTypeOptionData {
|
||||||
::std::default::Default::default()
|
::std::default::Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
// string field_id = 1;
|
// string grid_id = 1;
|
||||||
|
|
||||||
|
|
||||||
|
pub fn get_grid_id(&self) -> &str {
|
||||||
|
&self.grid_id
|
||||||
|
}
|
||||||
|
pub fn clear_grid_id(&mut self) {
|
||||||
|
self.grid_id.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Param is passed by value, moved
|
||||||
|
pub fn set_grid_id(&mut self, v: ::std::string::String) {
|
||||||
|
self.grid_id = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutable pointer to the field.
|
||||||
|
// If field is not initialized, it is initialized with default value first.
|
||||||
|
pub fn mut_grid_id(&mut self) -> &mut ::std::string::String {
|
||||||
|
&mut self.grid_id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Take field
|
||||||
|
pub fn take_grid_id(&mut self) -> ::std::string::String {
|
||||||
|
::std::mem::replace(&mut self.grid_id, ::std::string::String::new())
|
||||||
|
}
|
||||||
|
|
||||||
|
// string field_id = 2;
|
||||||
|
|
||||||
|
|
||||||
pub fn get_field_id(&self) -> &str {
|
pub fn get_field_id(&self) -> &str {
|
||||||
|
@ -2217,7 +2244,7 @@ impl FieldTypeOptionData {
|
||||||
::std::mem::replace(&mut self.field_id, ::std::string::String::new())
|
::std::mem::replace(&mut self.field_id, ::std::string::String::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
// bytes type_option_data = 2;
|
// bytes type_option_data = 3;
|
||||||
|
|
||||||
|
|
||||||
pub fn get_type_option_data(&self) -> &[u8] {
|
pub fn get_type_option_data(&self) -> &[u8] {
|
||||||
|
@ -2254,9 +2281,12 @@ impl ::protobuf::Message for FieldTypeOptionData {
|
||||||
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)?;
|
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.grid_id)?;
|
||||||
},
|
},
|
||||||
2 => {
|
2 => {
|
||||||
|
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.field_id)?;
|
||||||
|
},
|
||||||
|
3 => {
|
||||||
::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.type_option_data)?;
|
::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.type_option_data)?;
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -2271,11 +2301,14 @@ impl ::protobuf::Message for FieldTypeOptionData {
|
||||||
#[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.grid_id.is_empty() {
|
||||||
|
my_size += ::protobuf::rt::string_size(1, &self.grid_id);
|
||||||
|
}
|
||||||
if !self.field_id.is_empty() {
|
if !self.field_id.is_empty() {
|
||||||
my_size += ::protobuf::rt::string_size(1, &self.field_id);
|
my_size += ::protobuf::rt::string_size(2, &self.field_id);
|
||||||
}
|
}
|
||||||
if !self.type_option_data.is_empty() {
|
if !self.type_option_data.is_empty() {
|
||||||
my_size += ::protobuf::rt::bytes_size(2, &self.type_option_data);
|
my_size += ::protobuf::rt::bytes_size(3, &self.type_option_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);
|
||||||
|
@ -2283,11 +2316,14 @@ impl ::protobuf::Message for FieldTypeOptionData {
|
||||||
}
|
}
|
||||||
|
|
||||||
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.grid_id.is_empty() {
|
||||||
|
os.write_string(1, &self.grid_id)?;
|
||||||
|
}
|
||||||
if !self.field_id.is_empty() {
|
if !self.field_id.is_empty() {
|
||||||
os.write_string(1, &self.field_id)?;
|
os.write_string(2, &self.field_id)?;
|
||||||
}
|
}
|
||||||
if !self.type_option_data.is_empty() {
|
if !self.type_option_data.is_empty() {
|
||||||
os.write_bytes(2, &self.type_option_data)?;
|
os.write_bytes(3, &self.type_option_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(())
|
||||||
|
@ -2327,6 +2363,11 @@ impl ::protobuf::Message for FieldTypeOptionData {
|
||||||
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>(
|
||||||
|
"grid_id",
|
||||||
|
|m: &FieldTypeOptionData| { &m.grid_id },
|
||||||
|
|m: &mut FieldTypeOptionData| { &mut m.grid_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>(
|
||||||
"field_id",
|
"field_id",
|
||||||
|m: &FieldTypeOptionData| { &m.field_id },
|
|m: &FieldTypeOptionData| { &m.field_id },
|
||||||
|
@ -2353,6 +2394,7 @@ impl ::protobuf::Message for FieldTypeOptionData {
|
||||||
|
|
||||||
impl ::protobuf::Clear for FieldTypeOptionData {
|
impl ::protobuf::Clear for FieldTypeOptionData {
|
||||||
fn clear(&mut self) {
|
fn clear(&mut self) {
|
||||||
|
self.grid_id.clear();
|
||||||
self.field_id.clear();
|
self.field_id.clear();
|
||||||
self.type_option_data.clear();
|
self.type_option_data.clear();
|
||||||
self.unknown_fields.clear();
|
self.unknown_fields.clear();
|
||||||
|
@ -8257,27 +8299,28 @@ static file_descriptor_proto_data: &'static [u8] = b"\
|
||||||
\x86\x01\n\x10EditFieldPayload\x12\x17\n\x07grid_id\x18\x01\x20\x01(\tR\
|
\x86\x01\n\x10EditFieldPayload\x12\x17\n\x07grid_id\x18\x01\x20\x01(\tR\
|
||||||
\x06gridId\x12\x1b\n\x08field_id\x18\x02\x20\x01(\tH\0R\x07fieldId\x12)\
|
\x06gridId\x12\x1b\n\x08field_id\x18\x02\x20\x01(\tH\0R\x07fieldId\x12)\
|
||||||
\n\nfield_type\x18\x03\x20\x01(\x0e2\n.FieldTypeR\tfieldTypeB\x11\n\x0fo\
|
\n\nfield_type\x18\x03\x20\x01(\x0e2\n.FieldTypeR\tfieldTypeB\x11\n\x0fo\
|
||||||
ne_of_field_id\"|\n\x10EditFieldContext\x12\x17\n\x07grid_id\x18\x01\x20\
|
ne_of_field_id\"\x82\x01\n\x16FieldTypeOptionContext\x12\x17\n\x07grid_i\
|
||||||
\x01(\tR\x06gridId\x12%\n\ngrid_field\x18\x02\x20\x01(\x0b2\x06.FieldR\t\
|
d\x18\x01\x20\x01(\tR\x06gridId\x12%\n\ngrid_field\x18\x02\x20\x01(\x0b2\
|
||||||
gridField\x12(\n\x10type_option_data\x18\x03\x20\x01(\x0cR\x0etypeOption\
|
\x06.FieldR\tgridField\x12(\n\x10type_option_data\x18\x03\x20\x01(\x0cR\
|
||||||
Data\"Z\n\x13FieldTypeOptionData\x12\x19\n\x08field_id\x18\x01\x20\x01(\
|
\x0etypeOptionData\"s\n\x13FieldTypeOptionData\x12\x17\n\x07grid_id\x18\
|
||||||
\tR\x07fieldId\x12(\n\x10type_option_data\x18\x02\x20\x01(\x0cR\x0etypeO\
|
\x01\x20\x01(\tR\x06gridId\x12\x19\n\x08field_id\x18\x02\x20\x01(\tR\x07\
|
||||||
ptionData\"-\n\rRepeatedField\x12\x1c\n\x05items\x18\x01\x20\x03(\x0b2\
|
fieldId\x12(\n\x10type_option_data\x18\x03\x20\x01(\x0cR\x0etypeOptionDa\
|
||||||
\x06.FieldR\x05items\"7\n\x12RepeatedFieldOrder\x12!\n\x05items\x18\x01\
|
ta\"-\n\rRepeatedField\x12\x1c\n\x05items\x18\x01\x20\x03(\x0b2\x06.Fiel\
|
||||||
\x20\x03(\x0b2\x0b.FieldOrderR\x05items\"T\n\x08RowOrder\x12\x15\n\x06ro\
|
dR\x05items\"7\n\x12RepeatedFieldOrder\x12!\n\x05items\x18\x01\x20\x03(\
|
||||||
w_id\x18\x01\x20\x01(\tR\x05rowId\x12\x19\n\x08block_id\x18\x02\x20\x01(\
|
\x0b2\x0b.FieldOrderR\x05items\"T\n\x08RowOrder\x12\x15\n\x06row_id\x18\
|
||||||
\tR\x07blockId\x12\x16\n\x06height\x18\x03\x20\x01(\x05R\x06height\"\xb8\
|
\x01\x20\x01(\tR\x05rowId\x12\x19\n\x08block_id\x18\x02\x20\x01(\tR\x07b\
|
||||||
\x01\n\x03Row\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12@\n\x10cell_b\
|
lockId\x12\x16\n\x06height\x18\x03\x20\x01(\x05R\x06height\"\xb8\x01\n\
|
||||||
y_field_id\x18\x02\x20\x03(\x0b2\x17.Row.CellByFieldIdEntryR\rcellByFiel\
|
\x03Row\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12@\n\x10cell_by_fiel\
|
||||||
dId\x12\x16\n\x06height\x18\x03\x20\x01(\x05R\x06height\x1aG\n\x12CellBy\
|
d_id\x18\x02\x20\x03(\x0b2\x17.Row.CellByFieldIdEntryR\rcellByFieldId\
|
||||||
FieldIdEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x1b\n\x05va\
|
\x12\x16\n\x06height\x18\x03\x20\x01(\x05R\x06height\x1aG\n\x12CellByFie\
|
||||||
lue\x18\x02\x20\x01(\x0b2\x05.CellR\x05value:\x028\x01\")\n\x0bRepeatedR\
|
ldIdEntry\x12\x10\n\x03key\x18\x01\x20\x01(\tR\x03key\x12\x1b\n\x05value\
|
||||||
ow\x12\x1a\n\x05items\x18\x01\x20\x03(\x0b2\x04.RowR\x05items\"5\n\x11Re\
|
\x18\x02\x20\x01(\x0b2\x05.CellR\x05value:\x028\x01\")\n\x0bRepeatedRow\
|
||||||
peatedGridBlock\x12\x20\n\x05items\x18\x01\x20\x03(\x0b2\n.GridBlockR\
|
\x12\x1a\n\x05items\x18\x01\x20\x03(\x0b2\x04.RowR\x05items\"5\n\x11Repe\
|
||||||
\x05items\"U\n\x0eGridBlockOrder\x12\x19\n\x08block_id\x18\x01\x20\x01(\
|
atedGridBlock\x12\x20\n\x05items\x18\x01\x20\x03(\x0b2\n.GridBlockR\x05i\
|
||||||
\tR\x07blockId\x12(\n\nrow_orders\x18\x02\x20\x03(\x0b2\t.RowOrderR\trow\
|
tems\"U\n\x0eGridBlockOrder\x12\x19\n\x08block_id\x18\x01\x20\x01(\tR\
|
||||||
Orders\"_\n\rIndexRowOrder\x12&\n\trow_order\x18\x01\x20\x01(\x0b2\t.Row\
|
\x07blockId\x12(\n\nrow_orders\x18\x02\x20\x03(\x0b2\t.RowOrderR\trowOrd\
|
||||||
OrderR\x08rowOrder\x12\x16\n\x05index\x18\x02\x20\x01(\x05H\0R\x05indexB\
|
ers\"_\n\rIndexRowOrder\x12&\n\trow_order\x18\x01\x20\x01(\x0b2\t.RowOrd\
|
||||||
|
erR\x08rowOrder\x12\x16\n\x05index\x18\x02\x20\x01(\x05H\0R\x05indexB\
|
||||||
\x0e\n\x0cone_of_index\"Q\n\x0fUpdatedRowOrder\x12&\n\trow_order\x18\x01\
|
\x0e\n\x0cone_of_index\"Q\n\x0fUpdatedRowOrder\x12&\n\trow_order\x18\x01\
|
||||||
\x20\x01(\x0b2\t.RowOrderR\x08rowOrder\x12\x16\n\x03row\x18\x02\x20\x01(\
|
\x20\x01(\x0b2\t.RowOrderR\x08rowOrder\x12\x16\n\x03row\x18\x02\x20\x01(\
|
||||||
\x0b2\x04.RowR\x03row\"\xc6\x01\n\x11GridRowsChangeset\x12\x19\n\x08bloc\
|
\x0b2\x04.RowR\x03row\"\xc6\x01\n\x11GridRowsChangeset\x12\x19\n\x08bloc\
|
||||||
|
|
|
@ -38,14 +38,15 @@ message EditFieldPayload {
|
||||||
oneof one_of_field_id { string field_id = 2; };
|
oneof one_of_field_id { string field_id = 2; };
|
||||||
FieldType field_type = 3;
|
FieldType field_type = 3;
|
||||||
}
|
}
|
||||||
message EditFieldContext {
|
message FieldTypeOptionContext {
|
||||||
string grid_id = 1;
|
string grid_id = 1;
|
||||||
Field grid_field = 2;
|
Field grid_field = 2;
|
||||||
bytes type_option_data = 3;
|
bytes type_option_data = 3;
|
||||||
}
|
}
|
||||||
message FieldTypeOptionData {
|
message FieldTypeOptionData {
|
||||||
string field_id = 1;
|
string grid_id = 1;
|
||||||
bytes type_option_data = 2;
|
string field_id = 2;
|
||||||
|
bytes type_option_data = 3;
|
||||||
}
|
}
|
||||||
message RepeatedField {
|
message RepeatedField {
|
||||||
repeated Field items = 1;
|
repeated Field items = 1;
|
||||||
|
|
|
@ -16,6 +16,7 @@ rand = "0.8.5"
|
||||||
serde = { version = "1.0", features = ["derive"]}
|
serde = { version = "1.0", features = ["derive"]}
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
|
|
||||||
cmd_lib = { version = "1", optional = true }
|
cmd_lib = { version = "1", optional = true }
|
||||||
protoc-rust = { version = "2", optional = true }
|
protoc-rust = { version = "2", optional = true }
|
||||||
walkdir = { version = "2", optional = true }
|
walkdir = { version = "2", optional = true }
|
||||||
|
|
|
@ -7,6 +7,7 @@ mod proto_info;
|
||||||
mod template;
|
mod template;
|
||||||
|
|
||||||
use crate::code_gen::util::path_string_with_component;
|
use crate::code_gen::util::path_string_with_component;
|
||||||
|
use itertools::Itertools;
|
||||||
use log::info;
|
use log::info;
|
||||||
pub use proto_gen::*;
|
pub use proto_gen::*;
|
||||||
pub use proto_info::*;
|
pub use proto_info::*;
|
||||||
|
@ -132,7 +133,7 @@ fn generate_dart_protobuf_files(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_pb_dart_plugin() {
|
pub fn check_pb_dart_plugin() {
|
||||||
if cfg!(target_os = "windows") {
|
if cfg!(target_os = "windows") {
|
||||||
//Command::new("cmd")
|
//Command::new("cmd")
|
||||||
// .arg("/C")
|
// .arg("/C")
|
||||||
|
@ -141,15 +142,39 @@ fn check_pb_dart_plugin() {
|
||||||
// .expect("failed to execute process");
|
// .expect("failed to execute process");
|
||||||
//panic!("{}", format!("\n❌ The protoc-gen-dart was not installed correctly."))
|
//panic!("{}", format!("\n❌ The protoc-gen-dart was not installed correctly."))
|
||||||
} else {
|
} else {
|
||||||
let is_success = Command::new("sh")
|
let exit_result = Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg("command -v protoc-gen-dart")
|
.arg("command -v protoc-gen-dart")
|
||||||
.status()
|
.status()
|
||||||
.expect("failed to execute process")
|
.expect("failed to execute process");
|
||||||
.success();
|
|
||||||
|
|
||||||
if !is_success {
|
if !exit_result.success() {
|
||||||
panic!("{}", format!("\n❌ The protoc-gen-dart was not installed correctly. \n✅ You can fix that by adding \"{}\" to your shell's config file.(.bashrc, .bash, etc.)", "dart pub global activate protoc_plugin"))
|
let mut msg = "\n❌ Can't find protoc-gen-dart in $PATH:\n".to_string();
|
||||||
|
let output = Command::new("sh").arg("-c").arg("echo $PATH").output();
|
||||||
|
let paths = String::from_utf8(output.unwrap().stdout)
|
||||||
|
.unwrap()
|
||||||
|
.split(":")
|
||||||
|
.map(|s| s.to_string())
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
|
paths.iter().for_each(|s| msg.push_str(&format!("{}\n", s)));
|
||||||
|
|
||||||
|
match Command::new("sh").arg("-c").arg("which protoc-gen-dart").output() {
|
||||||
|
Ok(output) => {
|
||||||
|
msg.push_str(&format!(
|
||||||
|
"Installed protoc-gen-dart path: {:?}\n",
|
||||||
|
String::from_utf8(output.stdout).unwrap()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Err(_) => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.push_str(&format!("✅ You can fix that by adding:"));
|
||||||
|
msg.push_str(&format!("\n\texport PATH=\"$PATH\":\"$HOME/.pub-cache/bin\"\n",));
|
||||||
|
msg.push_str(&format!(
|
||||||
|
"to your shell's config file.(.bashrc, .bash, .profile, .zshrc etc.)"
|
||||||
|
));
|
||||||
|
panic!("{}", msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue