diff --git a/frontend/appflowy_flutter/lib/plugins/database/application/field/type_option/translate_type_option_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database/application/field/type_option/translate_type_option_bloc.dart index 8f9bd8559c..43e990f6d4 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/application/field/type_option/translate_type_option_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/application/field/type_option/translate_type_option_bloc.dart @@ -57,14 +57,24 @@ class TranslateTypeOptionState with _$TranslateTypeOptionState { String languageTypeToLanguage(TranslateLanguagePB langaugeType) { switch (langaugeType) { - case TranslateLanguagePB.Chinese: - return 'Chinese'; + case TranslateLanguagePB.SimplifiedChinese: + return 'Simplified Chinese'; + case TranslateLanguagePB.TraditionalChinese: + return 'Traditional Chinese'; case TranslateLanguagePB.English: return 'English'; case TranslateLanguagePB.French: return 'French'; case TranslateLanguagePB.German: return 'German'; + case TranslateLanguagePB.Spanish: + return 'Spanish'; + case TranslateLanguagePB.Hindi: + return 'Hindi'; + case TranslateLanguagePB.Portuguese: + return 'Portuguese'; + case TranslateLanguagePB.StandardArabic: + return 'Standard Arabic'; default: Log.error('Unknown language type: $langaugeType'); return 'English'; diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_summary_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_summary_cell.dart index 09d7d43b14..b5d915b022 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_summary_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_summary_cell.dart @@ -32,24 +32,27 @@ class DesktopGridSummaryCellSkin extends IEditableSummaryCellSkin { minHeight: GridSize.headerHeight, ), child: Stack( + fit: StackFit.expand, children: [ - TextField( - controller: textEditingController, - enabled: false, - focusNode: focusNode, - onEditingComplete: () => focusNode.unfocus(), - onSubmitted: (_) => focusNode.unfocus(), - maxLines: null, - style: Theme.of(context).textTheme.bodyMedium, - textInputAction: TextInputAction.done, - decoration: InputDecoration( - contentPadding: GridSize.cellContentInsets, - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - errorBorder: InputBorder.none, - disabledBorder: InputBorder.none, - isDense: true, + Center( + child: TextField( + controller: textEditingController, + enabled: false, + focusNode: focusNode, + onEditingComplete: () => focusNode.unfocus(), + onSubmitted: (_) => focusNode.unfocus(), + maxLines: null, + style: Theme.of(context).textTheme.bodyMedium, + textInputAction: TextInputAction.done, + decoration: InputDecoration( + contentPadding: GridSize.cellContentInsets, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + isDense: true, + ), ), ), Padding( diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_translate_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_translate_cell.dart index b96c4320a7..aece28373c 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_translate_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_translate_cell.dart @@ -32,24 +32,27 @@ class DesktopGridTranslateCellSkin extends IEditableTranslateCellSkin { minHeight: GridSize.headerHeight, ), child: Stack( + fit: StackFit.expand, children: [ - TextField( - controller: textEditingController, - enabled: false, - focusNode: focusNode, - onEditingComplete: () => focusNode.unfocus(), - onSubmitted: (_) => focusNode.unfocus(), - maxLines: null, - style: Theme.of(context).textTheme.bodyMedium, - textInputAction: TextInputAction.done, - decoration: InputDecoration( - contentPadding: GridSize.cellContentInsets, - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - errorBorder: InputBorder.none, - disabledBorder: InputBorder.none, - isDense: true, + Center( + child: TextField( + controller: textEditingController, + readOnly: true, + focusNode: focusNode, + onEditingComplete: () => focusNode.unfocus(), + onSubmitted: (_) => focusNode.unfocus(), + maxLines: null, + style: Theme.of(context).textTheme.bodyMedium, + textInputAction: TextInputAction.done, + decoration: InputDecoration( + contentPadding: GridSize.cellContentInsets, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + isDense: true, + ), ), ), Padding( diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_summary_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_summary_cell.dart index 424dda870c..d8a8902a8c 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_summary_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_summary_cell.dart @@ -3,6 +3,7 @@ import 'package:appflowy/plugins/database/grid/presentation/layout/sizes.dart'; import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/summary.dart'; import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class DesktopRowDetailSummaryCellSkin extends IEditableSummaryCellSkin { @override @@ -13,41 +14,53 @@ class DesktopRowDetailSummaryCellSkin extends IEditableSummaryCellSkin { FocusNode focusNode, TextEditingController textEditingController, ) { - return Column( - children: [ - TextField( - controller: textEditingController, - focusNode: focusNode, - onEditingComplete: () => focusNode.unfocus(), - onSubmitted: (_) => focusNode.unfocus(), - style: Theme.of(context).textTheme.bodyMedium, - textInputAction: TextInputAction.done, - maxLines: null, - minLines: 1, - decoration: InputDecoration( - contentPadding: GridSize.cellContentInsets, - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - errorBorder: InputBorder.none, - disabledBorder: InputBorder.none, - isDense: true, - ), - ), - Row( - children: [ - const Spacer(), - Padding( - padding: const EdgeInsets.all(8.0), - child: SummaryCellAccessory( - viewId: bloc.cellController.viewId, - fieldId: bloc.cellController.fieldId, - rowId: bloc.cellController.rowId, - ), + return Padding( + padding: const EdgeInsets.all(8.0), + child: Stack( + children: [ + TextField( + controller: textEditingController, + readOnly: true, + focusNode: focusNode, + onEditingComplete: () => focusNode.unfocus(), + onSubmitted: (_) => focusNode.unfocus(), + style: Theme.of(context).textTheme.bodyMedium, + textInputAction: TextInputAction.done, + maxLines: null, + minLines: 1, + decoration: InputDecoration( + contentPadding: GridSize.cellContentInsets, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + isDense: true, ), - ], - ), - ], + ), + ChangeNotifierProvider.value( + value: cellContainerNotifier, + child: Selector( + selector: (_, notifier) => notifier.isHover, + builder: (context, isHover, child) { + return Visibility( + visible: isHover, + child: Row( + children: [ + const Spacer(), + SummaryCellAccessory( + viewId: bloc.cellController.viewId, + fieldId: bloc.cellController.fieldId, + rowId: bloc.cellController.rowId, + ), + ], + ), + ); + }, + ), + ), + ], + ), ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/destop_row_detail_translate_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/destop_row_detail_translate_cell.dart index a12159b83d..1c7bab9f92 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/destop_row_detail_translate_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/destop_row_detail_translate_cell.dart @@ -3,6 +3,7 @@ import 'package:appflowy/plugins/database/grid/presentation/layout/sizes.dart'; import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/translate.dart'; import 'package:appflowy/plugins/database/widgets/row/cells/cell_container.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class DesktopRowDetailTranslateCellSkin extends IEditableTranslateCellSkin { @override @@ -13,41 +14,53 @@ class DesktopRowDetailTranslateCellSkin extends IEditableTranslateCellSkin { FocusNode focusNode, TextEditingController textEditingController, ) { - return Column( - children: [ - TextField( - controller: textEditingController, - focusNode: focusNode, - onEditingComplete: () => focusNode.unfocus(), - onSubmitted: (_) => focusNode.unfocus(), - style: Theme.of(context).textTheme.bodyMedium, - textInputAction: TextInputAction.done, - maxLines: null, - minLines: 1, - decoration: InputDecoration( - contentPadding: GridSize.cellContentInsets, - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - errorBorder: InputBorder.none, - disabledBorder: InputBorder.none, - isDense: true, - ), - ), - Row( - children: [ - const Spacer(), - Padding( - padding: const EdgeInsets.all(8.0), - child: TranslateCellAccessory( - viewId: bloc.cellController.viewId, - fieldId: bloc.cellController.fieldId, - rowId: bloc.cellController.rowId, - ), + return Padding( + padding: const EdgeInsets.all(8.0), + child: Stack( + children: [ + TextField( + controller: textEditingController, + focusNode: focusNode, + readOnly: true, + onEditingComplete: () => focusNode.unfocus(), + onSubmitted: (_) => focusNode.unfocus(), + style: Theme.of(context).textTheme.bodyMedium, + textInputAction: TextInputAction.done, + maxLines: null, + minLines: 1, + decoration: InputDecoration( + contentPadding: GridSize.cellContentInsets, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + isDense: true, ), - ], - ), - ], + ), + ChangeNotifierProvider.value( + value: cellContainerNotifier, + child: Selector( + selector: (_, notifier) => notifier.isHover, + builder: (context, isHover, child) { + return Visibility( + visible: isHover, + child: Row( + children: [ + const Spacer(), + TranslateCellAccessory( + viewId: bloc.cellController.viewId, + fieldId: bloc.cellController.fieldId, + rowId: bloc.cellController.rowId, + ), + ], + ), + ); + }, + ), + ), + ], + ), ); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_grid/mobile_grid_summary_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_grid/mobile_grid_summary_cell.dart index 3fdb28a8fa..0da8d6bc64 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_grid/mobile_grid_summary_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_grid/mobile_grid_summary_cell.dart @@ -32,7 +32,7 @@ class MobileGridSummaryCellSkin extends IEditableSummaryCellSkin { children: [ TextField( controller: textEditingController, - enabled: false, + readOnly: true, focusNode: focusNode, onEditingComplete: () => focusNode.unfocus(), onSubmitted: (_) => focusNode.unfocus(), diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_grid/mobile_grid_translate_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_grid/mobile_grid_translate_cell.dart index 5b17bef39a..3a7b44cbc5 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_grid/mobile_grid_translate_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_grid/mobile_grid_translate_cell.dart @@ -32,7 +32,7 @@ class MobileGridTranslateCellSkin extends IEditableTranslateCellSkin { children: [ TextField( controller: textEditingController, - enabled: false, + readOnly: true, focusNode: focusNode, onEditingComplete: () => focusNode.unfocus(), onSubmitted: (_) => focusNode.unfocus(), diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_row_detail/mobile_row_detail_summary_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_row_detail/mobile_row_detail_summary_cell.dart index cca601ce12..a900cf62fb 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_row_detail/mobile_row_detail_summary_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_row_detail/mobile_row_detail_summary_cell.dart @@ -17,6 +17,7 @@ class MobileRowDetailSummaryCellSkin extends IEditableSummaryCellSkin { children: [ TextField( controller: textEditingController, + readOnly: true, focusNode: focusNode, onEditingComplete: () => focusNode.unfocus(), onSubmitted: (_) => focusNode.unfocus(), diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_row_detail/mobile_row_detail_translate_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_row_detail/mobile_row_detail_translate_cell.dart index a9b141fe9a..84af6c7062 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_row_detail/mobile_row_detail_translate_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/mobile_row_detail/mobile_row_detail_translate_cell.dart @@ -16,6 +16,7 @@ class MobileRowDetailTranslateCellSkin extends IEditableTranslateCellSkin { return Column( children: [ TextField( + readOnly: true, controller: textEditingController, focusNode: focusNode, onEditingComplete: () => focusNode.unfocus(), diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/translate.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/translate.dart index 2c6815f621..4cb5b0d9a3 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/translate.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/translate.dart @@ -96,7 +96,7 @@ class SelectLanguageButton extends StatelessWidget { @override Widget build(BuildContext context) { return SizedBox( - height: 40, + height: 30, child: FlowyButton(text: FlowyText(language)), ); } diff --git a/frontend/rust-lib/event-integration-test/tests/folder/local_test/script.rs b/frontend/rust-lib/event-integration-test/tests/folder/local_test/script.rs index fe55ad1bd2..7be83964e3 100644 --- a/frontend/rust-lib/event-integration-test/tests/folder/local_test/script.rs +++ b/frontend/rust-lib/event-integration-test/tests/folder/local_test/script.rs @@ -126,8 +126,13 @@ impl FolderTest { let app = create_view(sdk, &self.workspace.id, &name, &desc, ViewLayout::Document).await; self.parent_view = app; }, - FolderScript::AssertParentView(app) => { - assert_eq!(self.parent_view, app, "App not equal"); + FolderScript::AssertParentView(view) => { + assert_eq!(self.parent_view.id, view.id, "view id not equal"); + assert_eq!(self.parent_view.name, view.name, "view name not equal"); + assert_eq!( + self.parent_view.is_favorite, view.is_favorite, + "view name not equal" + ); }, FolderScript::ReloadParentView(parent_view_id) => { let parent_view = read_view(sdk, &parent_view_id).await; diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/translate_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/translate_entities.rs index bb373bb942..050d83c77d 100644 --- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/translate_entities.rs +++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/translate_entities.rs @@ -30,20 +30,30 @@ impl From for TranslateTypeOption { #[derive(Clone, Debug, Copy, ProtoBuf_Enum, Default)] #[repr(i64)] pub enum TranslateLanguagePB { - Chinese = 0, + TraditionalChinese = 0, #[default] English = 1, French = 2, German = 3, + Hindi = 4, + Spanish = 5, + Portuguese = 6, + StandardArabic = 7, + SimplifiedChinese = 8, } impl From for TranslateLanguagePB { fn from(data: i64) -> Self { match data { - 0 => TranslateLanguagePB::Chinese, + 0 => TranslateLanguagePB::TraditionalChinese, 1 => TranslateLanguagePB::English, 2 => TranslateLanguagePB::French, 3 => TranslateLanguagePB::German, + 4 => TranslateLanguagePB::Hindi, + 5 => TranslateLanguagePB::Spanish, + 6 => TranslateLanguagePB::Portuguese, + 7 => TranslateLanguagePB::StandardArabic, + 8 => TranslateLanguagePB::SimplifiedChinese, _ => TranslateLanguagePB::English, } } diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rs index 83dcd17431..968289b5f0 100644 --- a/frontend/rust-lib/flowy-database2/src/manager.rs +++ b/frontend/rust-lib/flowy-database2/src/manager.rs @@ -428,8 +428,6 @@ impl DatabaseManager { field_id: String, ) -> FlowyResult<()> { let database = self.get_database_with_view_id(&view_id).await?; - - // let mut summary_row_content = SummaryRowContent::new(); if let Some(row) = database.get_row(&view_id, &row_id) { let fields = database.get_fields(&view_id, None); @@ -437,6 +435,10 @@ impl DatabaseManager { // When summarizing a row, skip the content in the "AI summary" cell; it does not need to // be summarized. if field.id != field_id { + // Don't summarize the summary field. + if field.field_type == FieldType::Summary as i64 { + continue; + } if let Some(cell) = row.cells.get(&field.id) { summary_row_content.insert(field.name.clone(), stringify_cell(cell, &field)); } @@ -480,6 +482,11 @@ impl DatabaseManager { // When translate a row, skip the content in the "AI Translate" cell; it does not need to // be translated. if field.id != field_id { + // Don't translate the translate field. + if field.field_type == FieldType::Translate as i64 { + continue; + } + if let Some(cell) = row.cells.get(&field.id) { translate_row_content.push(TranslateItem { title: field.name.clone(), diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/translate_type_option/translate.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/translate_type_option/translate.rs index 080411796c..5403782387 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/translate_type_option/translate.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/translate_type_option/translate.rs @@ -23,10 +23,15 @@ pub struct TranslateTypeOption { impl TranslateTypeOption { pub fn language_from_type(language_type: i64) -> &'static str { match language_type { - 0 => "Chinese", + 0 => "Traditional Chinese", 1 => "English", 2 => "French", 3 => "German", + 4 => "Hindi", + 5 => "Spanish", + 6 => "Portuguese", + 7 => "Standard Arabic", + 8 => "Simplified Chinese", _ => "English", } } diff --git a/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs b/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs index b73f3bf92e..0666d9171c 100644 --- a/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs +++ b/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs @@ -6,6 +6,7 @@ use crate::database::mock_data::{COMPLETED, FACEBOOK, GOOGLE, PAUSED, PLANNED, T use event_integration_test::database_event::TestRowBuilder; use flowy_database2::entities::FieldType; use flowy_database2::services::field::summary_type_option::summary::SummarizationTypeOption; +use flowy_database2::services::field::translate_type_option::translate::TranslateTypeOption; use flowy_database2::services::field::{ ChecklistTypeOption, DateFormat, DateTypeOption, FieldBuilder, MultiSelectTypeOption, NumberFormat, NumberTypeOption, RelationTypeOption, SelectOption, SelectOptionColor, @@ -132,7 +133,16 @@ pub fn make_test_grid() -> DatabaseData { .build(); fields.push(relation_field); }, - FieldType::Translate => {}, + FieldType::Translate => { + let type_option = TranslateTypeOption { + auto_fill: false, + language_type: 0, + }; + let translate_field = FieldBuilder::new(field_type, type_option) + .name("AI translate") + .build(); + fields.push(translate_field); + }, } }