diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.ts
new file mode 100644
index 000000000..70246efcc
--- /dev/null
+++ b/apps/client/src/widgets/collections/board/api.ts
@@ -0,0 +1,31 @@
+import FNote from "../../../entities/fnote";
+import attributes from "../../../services/attributes";
+import note_create from "../../../services/note_create";
+
+export async function createNewItem(parentNote: FNote, column: string) {
+ try {
+ // Get the parent note path
+ const parentNotePath = parentNote.noteId;
+ const statusAttribute = parentNote.getLabelValue("board:groupBy") ?? "status";
+
+ // Create a new note as a child of the parent note
+ const { note: newNote } = await note_create.createNote(parentNotePath, {
+ activate: false,
+ title: "New item"
+ });
+
+ if (newNote) {
+ // Set the status label to place it in the correct column
+ await changeColumn(newNote.noteId, column, statusAttribute);
+
+ // Start inline editing of the newly created card
+ //this.startInlineEditingCard(newNote.noteId);
+ }
+ } catch (error) {
+ console.error("Failed to create new item:", error);
+ }
+}
+
+async function changeColumn(noteId: string, newColumn: string, statusAttribute: string) {
+ await attributes.setLabel(noteId, statusAttribute, newColumn);
+}
diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsx
index 4220cca8e..d47a066bc 100644
--- a/apps/client/src/widgets/collections/board/index.tsx
+++ b/apps/client/src/widgets/collections/board/index.tsx
@@ -5,6 +5,9 @@ import { ColumnMap, getBoardData } from "./data";
import { useNoteLabel } from "../../react/hooks";
import FNote from "../../../entities/fnote";
import FBranch from "../../../entities/fbranch";
+import Icon from "../../react/Icon";
+import { t } from "../../../services/i18n";
+import { createNewItem } from "./api";
export interface BoardViewData {
columns?: BoardColumnData[];
@@ -40,14 +43,18 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
{byColumn && columns?.map(column => (
-
+
))}
)
}
-function Column({ column, columnItems }: { column: string, columnItems?: { note: FNote, branch: FBranch }[] }) {
+function Column({ parentNote, column, columnItems }: { parentNote: FNote, column: string, columnItems?: { note: FNote, branch: FBranch }[] }) {
return (
@@ -60,6 +67,11 @@ function Column({ column, columnItems }: { column: string, columnItems?: { note:
{(columnItems ?? []).map(({ note, branch }) => (
))}
+
+
createNewItem(parentNote, column)}>
+ {" "}
+ {t("board_view.new-item")}
+
)
}
diff --git a/apps/client/src/widgets/view_widgets/board_view/api.ts b/apps/client/src/widgets/view_widgets/board_view/api.ts
index df354ace4..086a6a714 100644
--- a/apps/client/src/widgets/view_widgets/board_view/api.ts
+++ b/apps/client/src/widgets/view_widgets/board_view/api.ts
@@ -29,10 +29,6 @@ export default class BoardApi {
return this.byColumn.get(column);
}
- async changeColumn(noteId: string, newColumn: string) {
- await attributes.setLabel(noteId, this._statusAttribute, newColumn);
- }
-
openNote(noteId: string) {
appContext.triggerCommand("openInPopup", { noteIdOrPath: noteId });
}
diff --git a/apps/client/src/widgets/view_widgets/board_view/differential_renderer.ts b/apps/client/src/widgets/view_widgets/board_view/differential_renderer.ts
index 474fa7317..ba2d0990e 100644
--- a/apps/client/src/widgets/view_widgets/board_view/differential_renderer.ts
+++ b/apps/client/src/widgets/view_widgets/board_view/differential_renderer.ts
@@ -349,9 +349,8 @@ export class DifferentialBoardRenderer {
const $newItemEl = $("")
.addClass("board-new-item")
.attr("data-column", column)
- .html(` ${t("board_view.new-item")}`);
+ .html(` ${}`);
- $newItemEl.on("click", () => this.onCreateNewItem(column));
$columnEl.append($newItemEl);
return $columnEl;
diff --git a/apps/client/src/widgets/view_widgets/board_view/index.ts b/apps/client/src/widgets/view_widgets/board_view/index.ts
index ec203068f..489fd0b95 100644
--- a/apps/client/src/widgets/view_widgets/board_view/index.ts
+++ b/apps/client/src/widgets/view_widgets/board_view/index.ts
@@ -64,7 +64,6 @@ export default class BoardView extends ViewMode {
this.$container,
this.api,
this.dragHandler,
- (column: string) => this.createNewItem(column),
this.parentNote,
this.viewStorage,
() => this.refreshApi()
@@ -220,32 +219,6 @@ export default class BoardView extends ViewMode {
}
}
- private async createNewItem(column: string) {
- try {
- // Get the parent note path
- const parentNotePath = this.parentNote.noteId;
-
- // Create a new note as a child of the parent note
- const { note: newNote } = await noteCreateService.createNote(parentNotePath, {
- activate: false,
- title: "New item"
- });
-
- if (newNote) {
- // Set the status label to place it in the correct column
- await this.api?.changeColumn(newNote.noteId, column);
-
- // Refresh the board to show the new item
- await this.renderList();
-
- // Start inline editing of the newly created card
- this.startInlineEditingCard(newNote.noteId);
- }
- } catch (error) {
- console.error("Failed to create new item:", error);
- }
- }
-
async insertItemAtPosition(column: string, relativeToBranchId: string, direction: "before" | "after"): Promise {
try {
// Create the note without opening it