mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: duplicate field with cell data (#4737)
* feat: duplicate field with cell data * chore: code review remove extra option
This commit is contained in:
parent
d67e904f56
commit
26f8397624
@ -67,10 +67,7 @@ class FieldBackendService {
|
||||
required String viewId,
|
||||
required String fieldId,
|
||||
}) {
|
||||
final payload = DuplicateFieldPayloadPB(
|
||||
viewId: viewId,
|
||||
fieldId: fieldId,
|
||||
);
|
||||
final payload = DuplicateFieldPayloadPB(viewId: viewId, fieldId: fieldId);
|
||||
|
||||
return DatabaseEventDuplicateField(payload).send();
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||
import 'package:appflowy/plugins/database/application/field/field_controller.dart';
|
||||
@ -14,7 +16,6 @@ import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
||||
|
@ -281,7 +281,7 @@ pub(crate) async fn duplicate_field_handler(
|
||||
manager: AFPluginState<Weak<DatabaseManager>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let manager = upgrade_manager(manager)?;
|
||||
let params: FieldIdParams = data.into_inner().try_into()?;
|
||||
let params: DuplicateFieldPayloadPB = data.into_inner();
|
||||
let database_editor = manager.get_database_with_view_id(¶ms.view_id).await?;
|
||||
database_editor
|
||||
.duplicate_field(¶ms.view_id, ¶ms.field_id)
|
||||
|
@ -441,8 +441,18 @@ impl DatabaseEditor {
|
||||
.duplicate_field(view_id, field_id, |field| format!("{} (copy)", field.name));
|
||||
if let Some((index, duplicated_field)) = value {
|
||||
let _ = self
|
||||
.notify_did_insert_database_field(duplicated_field, index)
|
||||
.notify_did_insert_database_field(duplicated_field.clone(), index)
|
||||
.await;
|
||||
|
||||
let new_field_id = duplicated_field.id.clone();
|
||||
let cells = self.get_cells_for_field(view_id, field_id).await;
|
||||
for cell in cells {
|
||||
if let Some(new_cell) = cell.cell.clone() {
|
||||
self
|
||||
.update_cell(view_id, cell.row_id, &new_field_id, new_cell)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user