mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 15:49:00 +02:00
feat(views/table): disable drag if sorted
This commit is contained in:
parent
6a0b24f032
commit
bb0f384a39
@ -37,8 +37,7 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "title",
|
field: "title",
|
||||||
editable: true,
|
editable: true
|
||||||
rowDrag: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "position"
|
field: "position"
|
||||||
|
@ -81,8 +81,8 @@ export default class TableView extends ViewMode<StateInfo> {
|
|||||||
|
|
||||||
this.api = createGrid(el, {
|
this.api = createGrid(el, {
|
||||||
...buildData(parentNote, info, notes),
|
...buildData(parentNote, info, notes),
|
||||||
...setupEditing(),
|
...this.setupEditing(),
|
||||||
...setupDragging(),
|
...this.setupDragging(),
|
||||||
initialState,
|
initialState,
|
||||||
async onGridReady(event) {
|
async onGridReady(event) {
|
||||||
applyHeaderCustomization(el, event.api);
|
applyHeaderCustomization(el, event.api);
|
||||||
@ -101,9 +101,7 @@ export default class TableView extends ViewMode<StateInfo> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private setupEditing(): GridOptions<TableData> {
|
||||||
|
|
||||||
function setupEditing(): GridOptions<TableData> {
|
|
||||||
return {
|
return {
|
||||||
onCellValueChanged(event) {
|
onCellValueChanged(event) {
|
||||||
if (event.type !== "cellValueChanged") {
|
if (event.type !== "cellValueChanged") {
|
||||||
@ -128,10 +126,15 @@ function setupEditing(): GridOptions<TableData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupDragging() {
|
private setupDragging() {
|
||||||
return {
|
if (this.parentNote.hasLabel("sorted")) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const config: GridOptions<TableData> = {
|
||||||
|
rowDragEntireRow: true,
|
||||||
onRowDragEnd(e) {
|
onRowDragEnd(e) {
|
||||||
const fromIndex = e.node.rowIndex;
|
const fromIndex = e.node.rowIndex;
|
||||||
const toIndex = e.overNode?.rowIndex;
|
const toIndex = e.overNode?.rowIndex;
|
||||||
@ -153,4 +156,7 @@ function setupDragging() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user