feat(views/table): disable drag if sorted

This commit is contained in:
Elian Doran 2025-06-27 20:30:36 +03:00
parent 6a0b24f032
commit bb0f384a39
No known key found for this signature in database
2 changed files with 53 additions and 48 deletions

View File

@ -37,8 +37,7 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {
},
{
field: "title",
editable: true,
rowDrag: true,
editable: true
},
{
field: "position"

View File

@ -81,8 +81,8 @@ export default class TableView extends ViewMode<StateInfo> {
this.api = createGrid(el, {
...buildData(parentNote, info, notes),
...setupEditing(),
...setupDragging(),
...this.setupEditing(),
...this.setupDragging(),
initialState,
async onGridReady(event) {
applyHeaderCustomization(el, event.api);
@ -101,9 +101,7 @@ export default class TableView extends ViewMode<StateInfo> {
});
}
}
function setupEditing(): GridOptions<TableData> {
private setupEditing(): GridOptions<TableData> {
return {
onCellValueChanged(event) {
if (event.type !== "cellValueChanged") {
@ -130,8 +128,13 @@ function setupEditing(): GridOptions<TableData> {
}
}
function setupDragging() {
return {
private setupDragging() {
if (this.parentNote.hasLabel("sorted")) {
return {};
}
const config: GridOptions<TableData> = {
rowDragEntireRow: true,
onRowDragEnd(e) {
const fromIndex = e.node.rowIndex;
const toIndex = e.overNode?.rowIndex;
@ -153,4 +156,7 @@ function setupDragging() {
}
}
};
return config;
}
}