mirror of
https://github.com/zadam/trilium.git
synced 2026-01-03 13:14:24 +01:00
fix(views/board): reordering same column not working
This commit is contained in:
parent
b277f4bf3f
commit
e2157aab26
@ -137,7 +137,6 @@ export class DifferentialBoardRenderer {
|
||||
const orderChanged = !this.arraysEqual(oldState.columnOrder, newState.columnOrder);
|
||||
|
||||
if (orderChanged) {
|
||||
console.log("Column order changed from", oldState.columnOrder, "to", newState.columnOrder);
|
||||
// If order changed, we need to reorder the columns in the DOM
|
||||
this.reorderColumns(newState.columnOrder);
|
||||
}
|
||||
@ -175,8 +174,6 @@ export class DifferentialBoardRenderer {
|
||||
}
|
||||
|
||||
private reorderColumns(newOrder: string[]): void {
|
||||
console.log("Reordering columns to:", newOrder);
|
||||
|
||||
// Get all existing column elements
|
||||
const $columns = this.$container.find('.board-column');
|
||||
const $addColumnButton = this.$container.find('.board-add-column');
|
||||
@ -213,8 +210,6 @@ export class DifferentialBoardRenderer {
|
||||
if ($addColumnButton.length) {
|
||||
this.$container.append($addColumnButton);
|
||||
}
|
||||
|
||||
console.log("Column reordering complete");
|
||||
}
|
||||
|
||||
private updateColumnCards(column: string, oldCards: { note: any; branch: any }[], newCards: { note: any; branch: any }[]): void {
|
||||
|
||||
@ -490,13 +490,8 @@ export class BoardDragHandler {
|
||||
const $dropIndicator = this.$container.find(".column-drop-indicator.show");
|
||||
|
||||
if ($dropIndicator.length > 0) {
|
||||
// Get current column order from the DOM
|
||||
const currentOrder = Array.from(this.$container.find('.board-column')).map(el =>
|
||||
$(el).attr('data-column')
|
||||
).filter(col => col) as string[];
|
||||
|
||||
console.log("Current order:", currentOrder);
|
||||
console.log("Dragged column:", this.context.draggedColumn);
|
||||
// Get current column order from the API (source of truth)
|
||||
const currentOrder = [...this.api.columns];
|
||||
|
||||
let newOrder = [...currentOrder];
|
||||
|
||||
@ -513,16 +508,13 @@ export class BoardDragHandler {
|
||||
// Insert before the next column
|
||||
const nextColumnValue = $nextColumn.attr('data-column');
|
||||
insertIndex = newOrder.indexOf(nextColumnValue!);
|
||||
console.log("Inserting before column:", nextColumnValue, "at index:", insertIndex);
|
||||
} else if ($prevColumn.length > 0) {
|
||||
// Insert after the previous column
|
||||
const prevColumnValue = $prevColumn.attr('data-column');
|
||||
insertIndex = newOrder.indexOf(prevColumnValue!) + 1;
|
||||
console.log("Inserting after column:", prevColumnValue, "at index:", insertIndex);
|
||||
} else {
|
||||
// Insert at the beginning
|
||||
insertIndex = 0;
|
||||
console.log("Inserting at the beginning");
|
||||
}
|
||||
|
||||
// Insert the dragged column at the determined position
|
||||
@ -531,16 +523,11 @@ export class BoardDragHandler {
|
||||
} else {
|
||||
// Fallback: insert at the end
|
||||
newOrder.push(this.context.draggedColumn);
|
||||
console.log("Fallback: inserting at the end");
|
||||
}
|
||||
|
||||
console.log("New order:", newOrder);
|
||||
|
||||
// Update column order in API
|
||||
await this.api.reorderColumns(newOrder);
|
||||
|
||||
console.log(`Moved column "${this.context.draggedColumn}" to new position`);
|
||||
|
||||
// Refresh the board to reflect the changes
|
||||
await this.onBoardRefresh();
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user