Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: update kanban demo (#2008)
Nathan.fooo1dbfd838ef80
diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dartindex e075cf5b92..dac75a6e52 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart@@ -159,8 +159,11 @@ class DatabaseController {);}- Future<Either<Unit, FlowyError>> moveRow(RowPB fromRow,- {RowPB? toRow, String? groupId}) {+ Future<Either<Unit, FlowyError>> moveRow({+ required RowPB fromRow,+ required String groupId,+ RowPB? toRow,+ }) {return _databaseViewBackendSvc.moveRow(fromRowId: fromRow.id,toGroupId: groupId,diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dartindex 842eeac90c..5ecaad6ef3 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart@@ -46,15 +46,13 @@ class DatabaseViewBackendService {Future<Either<Unit, FlowyError>> moveRow({required String fromRowId,- required String? toGroupId,- required String? toRowId,+ required String toGroupId,+ String? toRowId,}) {var payload = MoveGroupRowPayloadPB.create()..viewId = viewId- ..fromRowId = fromRowId;- if (toGroupId != null) {- payload.toGroupId = toGroupId;- }+ ..fromRowId = fromRowId+ ..toGroupId = toGroupId;if (toRowId != null) {payload.toRowId = toRowId;diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dartindex 1ee14a95d0..61911b5318 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart@@ -54,7 +54,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {final toRow = groupControllers[groupId]?.rowAtIndex(toIndex);if (fromRow != null) {_databaseController.moveRow(- fromRow,+ fromRow: fromRow,toRow: toRow,groupId: groupId,);@@ -70,7 +70,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {final toRow = groupControllers[toGroupId]?.rowAtIndex(toIndex);if (fromRow != null) {_databaseController.moveRow(- fromRow,+ fromRow: fromRow,toRow: toRow,groupId: toGroupId,);diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/tests/TestGroup.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/tests/TestGroup.tsxindex a88065f253..bbcf7a860c 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/tests/TestGroup.tsx+++ b/frontend/appflowy_tauri/src/appflowy_app/components/tests/TestGroup.tsx@@ -69,6 +69,37 @@ async function moveKanbanBoardRow() {// Create row in no status groupconst firstGroup = databaseController.groups.getValue()[1];const secondGroup = databaseController.groups.getValue()[2];+ // subscribe the group changes+ firstGroup.subscribe({+ onRemoveRow: (groupId, deleteRowId) => {+ console.log(groupId + 'did remove:' + deleteRowId);+ },+ onInsertRow: (groupId, rowPB) => {+ console.log(groupId + 'did insert:' + rowPB.id);+ },+ onUpdateRow: (groupId, rowPB) => {+ console.log(groupId + 'did update:' + rowPB.id);+ },+ onCreateRow: (groupId, rowPB) => {+ console.log(groupId + 'did create:' + rowPB.id);+ },+ });++ secondGroup.subscribe({+ onRemoveRow: (groupId, deleteRowId) => {+ console.log(groupId + 'did remove:' + deleteRowId);+ },+ onInsertRow: (groupId, rowPB) => {+ console.log(groupId + 'did insert:' + rowPB.id);+ },+ onUpdateRow: (groupId, rowPB) => {+ console.log(groupId + 'did update:' + rowPB.id);+ },+ onCreateRow: (groupId, rowPB) => {+ console.log(groupId + 'did create:' + rowPB.id);+ },+ });+const row = firstGroup.rowAtIndex(0).unwrap();await databaseController.moveRow(row.id, secondGroup.groupId);diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_bd_svc.tsindex 433c6acb17..f66f78ee15 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_bd_svc.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_bd_svc.ts@@ -56,11 +56,19 @@ export class DatabaseBackendService {return DatabaseEventCreateRow(payload);};- moveRow = (rowId: string, groupId?: string) => {- const payload = MoveGroupRowPayloadPB.fromObject({ view_id: this.viewId, from_row_id: rowId });- if (groupId !== undefined) {- payload.to_group_id = groupId;+ /// Move the row from one group to another group+ /// [groupId] can be the moving row's group id or others.+ /// [toRowId] is used to locate the moving row location.+ moveGroupRow = (fromRowId: string, groupId: string, toRowId?: string) => {+ const payload = MoveGroupRowPayloadPB.fromObject({+ view_id: this.viewId,+ from_row_id: fromRowId,+ to_group_id: groupId,+ });+ if (toRowId !== undefined) {+ payload.to_row_id = toRowId;}+return DatabaseEventMoveGroupRow(payload);};@@ -88,6 +96,8 @@ export class DatabaseBackendService {return DatabaseEventGetGroup(payload);};+ /// Get all groups in database+ /// It should only call once after the board openloadGroups = () => {const payload = DatabaseViewIdPB.fromObject({ value: this.viewId });return DatabaseEventGetGroups(payload);diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.tsindex e47119c49a..cdd3bd76aa 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts@@ -76,7 +76,7 @@ export class DatabaseController {};moveRow = (rowId: string, groupId: string) => {- return this.backendService.moveRow(rowId, groupId);+ return this.backendService.moveGroupRow(rowId, groupId);};moveGroup = (fromGroupId: string, toGroupId: string) => {diff --git a/frontend/rust-lib/flowy-database/src/services/group/controller_impls/select_option_controller/util.rs b/frontend/rust-lib/flowy-database/src/services/group/controller_impls/select_option_controller/util.rsindex d630df5d13..b800cf988f 100644--- a/frontend/rust-lib/flowy-database/src/services/group/controller_impls/select_option_controller/util.rs+++ b/frontend/rust-lib/flowy-database/src/services/group/controller_impls/select_option_controller/util.rs@@ -115,6 +115,8 @@ pub fn move_group_row(}// Update the corresponding row's cell content.+ // If the from_index is none which means the row is not belong to this group before and+ // it is moved from other groups.if from_index.is_none() {let cell_rev = make_inserted_cell_rev(&group.id, field_rev);if let Some(cell_rev) = cell_rev {@@ -126,7 +128,6 @@ pub fn move_group_row(row_changeset.cell_by_field_id.insert(field_rev.id.clone(), cell_rev);- changeset.updated_rows.push(RowPB::from(*row_rev));}}}