mirror of
https://github.com/zadam/trilium.git
synced 2025-11-05 04:45:47 +01:00
feat(views/table): basic reordering mechanism
This commit is contained in:
24
apps/client/src/widgets/view_widgets/table_view/dragging.ts
Normal file
24
apps/client/src/widgets/view_widgets/table_view/dragging.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { Tabulator } from "tabulator-tables";
|
||||
import type FNote from "../../../entities/fnote.js";
|
||||
import branches from "../../../services/branches.js";
|
||||
|
||||
export function canReorderRows(parentNote: FNote) {
|
||||
return !parentNote.hasLabel("sorted");
|
||||
}
|
||||
|
||||
export function configureReorderingRows(tabulator: Tabulator) {
|
||||
tabulator.on("rowMoved", (row) => {
|
||||
const branchIdsToMove = [ row.getData().branchId ];
|
||||
|
||||
const prevRow = row.getPrevRow();
|
||||
if (prevRow) {
|
||||
branches.moveAfterBranch(branchIdsToMove, prevRow.getData().branchId);
|
||||
return;
|
||||
}
|
||||
|
||||
const nextRow = row.getNextRow();
|
||||
if (nextRow) {
|
||||
branches.moveBeforeBranch(branchIdsToMove, nextRow.getData().branchId);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user