chore(react/collections/table): reintroduce editing of newly added item

This commit is contained in:
Elian Doran
2025-09-11 20:02:58 +03:00
parent 3d2a4d8c38
commit 1ce42d1301
3 changed files with 85 additions and 47 deletions

View File

@@ -3,6 +3,7 @@ import FNote from "../../../entities/fnote";
import attributes from "../../../services/attributes";
import { executeBulkActions } from "../../../services/bulk_action";
import note_create from "../../../services/note_create";
import server from "../../../services/server";
import { ColumnMap } from "./data";
export default class BoardApi {
@@ -13,7 +14,8 @@ export default class BoardApi {
private parentNote: FNote,
private statusAttribute: string,
private viewConfig: BoardViewData,
private saveConfig: (newConfig: BoardViewData) => void
private saveConfig: (newConfig: BoardViewData) => void,
private setBranchIdToEdit: (branchId: string | undefined) => void
) {};
async createNewItem(column: string) {
@@ -22,17 +24,14 @@ export default class BoardApi {
const parentNotePath = this.parentNote.noteId;
// Create a new note as a child of the parent note
const { note: newNote } = await note_create.createNote(parentNotePath, {
const { note: newNote, branch: newBranch } = await note_create.createNote(parentNotePath, {
activate: false,
title: "New item"
});
if (newNote) {
// Set the status label to place it in the correct column
await this.changeColumn(newNote.noteId, column);
// Start inline editing of the newly created card
//this.startInlineEditingCard(newNote.noteId);
this.setBranchIdToEdit(newBranch?.branchId);
}
} catch (error) {
console.error("Failed to create new item:", error);
@@ -57,5 +56,13 @@ export default class BoardApi {
this.saveConfig(this.viewConfig);
}
dismissEditingTitle() {
this.setBranchIdToEdit(undefined);
}
renameCard(noteId: string, newTitle: string) {
return server.put(`notes/${noteId}/title`, { title: newTitle.trim() });
}
}