diff --git a/apps/client/src/widgets/view_widgets/table_view/data.ts b/apps/client/src/widgets/view_widgets/table_view/data.ts index 1ac64e364..a9c7ceb75 100644 --- a/apps/client/src/widgets/view_widgets/table_view/data.ts +++ b/apps/client/src/widgets/view_widgets/table_view/data.ts @@ -37,8 +37,7 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[]) { }, { field: "title", - editable: true, - rowDrag: true, + editable: true }, { field: "position" diff --git a/apps/client/src/widgets/view_widgets/table_view/index.ts b/apps/client/src/widgets/view_widgets/table_view/index.ts index 024509970..6297bcde0 100644 --- a/apps/client/src/widgets/view_widgets/table_view/index.ts +++ b/apps/client/src/widgets/view_widgets/table_view/index.ts @@ -81,8 +81,8 @@ export default class TableView extends ViewMode { this.api = createGrid(el, { ...buildData(parentNote, info, notes), - ...setupEditing(), - ...setupDragging(), + ...this.setupEditing(), + ...this.setupDragging(), initialState, async onGridReady(event) { applyHeaderCustomization(el, event.api); @@ -101,56 +101,62 @@ export default class TableView extends ViewMode { }); } -} + private setupEditing(): GridOptions { + return { + onCellValueChanged(event) { + if (event.type !== "cellValueChanged") { + return; + } -function setupEditing(): GridOptions { - return { - onCellValueChanged(event) { - if (event.type !== "cellValueChanged") { - return; - } + const noteId = event.data.noteId; + const name = event.colDef.field; + if (!name) { + return; + } - const noteId = event.data.noteId; - const name = event.colDef.field; - if (!name) { - return; - } + const { newValue } = event; + if (name === "title") { + // TODO: Deduplicate with note_title. + server.put(`notes/${noteId}/title`, { title: newValue }); + } - const { newValue } = event; - if (name === "title") { - // TODO: Deduplicate with note_title. - server.put(`notes/${noteId}/title`, { title: newValue }); - } - - if (name.startsWith("labels.")) { - const labelName = name.split(".", 2)[1]; - setLabel(noteId, labelName, newValue); + if (name.startsWith("labels.")) { + const labelName = name.split(".", 2)[1]; + setLabel(noteId, labelName, newValue); + } } } } -} -function setupDragging() { - return { - onRowDragEnd(e) { - const fromIndex = e.node.rowIndex; - const toIndex = e.overNode?.rowIndex; - if (fromIndex === null || toIndex === null || toIndex === undefined || fromIndex === toIndex) { - return; - } - - const isBelow = (toIndex > fromIndex); - const fromBranchId = e.node.data?.branchId; - const toBranchId = e.overNode?.data?.branchId; - if (fromBranchId === undefined || toBranchId === undefined) { - return; - } - - if (isBelow) { - branches.moveAfterBranch([ fromBranchId ], toBranchId); - } else { - branches.moveBeforeBranch([ fromBranchId ], toBranchId); - } + private setupDragging() { + if (this.parentNote.hasLabel("sorted")) { + return {}; } - }; + + const config: GridOptions = { + rowDragEntireRow: true, + onRowDragEnd(e) { + const fromIndex = e.node.rowIndex; + const toIndex = e.overNode?.rowIndex; + if (fromIndex === null || toIndex === null || toIndex === undefined || fromIndex === toIndex) { + return; + } + + const isBelow = (toIndex > fromIndex); + const fromBranchId = e.node.data?.branchId; + const toBranchId = e.overNode?.data?.branchId; + if (fromBranchId === undefined || toBranchId === undefined) { + return; + } + + if (isBelow) { + branches.moveAfterBranch([ fromBranchId ], toBranchId); + } else { + branches.moveBeforeBranch([ fromBranchId ], toBranchId); + } + } + }; + return config; + } } +