mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 17:49:02 +01: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",
|
||||
editable: true,
|
||||
rowDrag: true,
|
||||
editable: true
|
||||
},
|
||||
{
|
||||
field: "position"
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user