From 07a4cc53793d964b27fe1f44fa863cf9bc2cc37f Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Thu, 25 Jul 2024 18:25:05 +0200 Subject: [PATCH] fix kanbanboard sorting --- dist/index.js | 24 +++++++++++++----- src/Model/Utility/utility.ts | 2 +- src/View/ChatPages/boardKanbanPage.tsx | 35 ++++++++++++++++++++------ 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0538168a..803b3172 100644 --- a/dist/index.js +++ b/dist/index.js @@ -351,7 +351,7 @@ continue; values.add(stringEntryObjectValue); } - return [...values.values()].sort(localeCompare); + return [...values.values()]; } function checkDoesObjectMatchSearch(query, getStringsOfObject, object) { if (query == "") return true; @@ -2690,14 +2690,22 @@ // src/View/ChatPages/boardKanbanPage.tsx function BoardKanbanPage(boardViewModel) { - const categoryNameConverter = (categoryName) => { - return KanbanBoard(categoryName, boardViewModel); - }; return PropertyValueList( "category", (taskViewModel) => taskViewModel.task, boardViewModel.taskViewModels, (categories) => { + const sortedCategories = createProxyState( + [categories], + () => [...categories.value.values()].sort(localeCompare) + ); + const categoryNameConverter = (categoryName) => { + const index = createProxyState( + [sortedCategories], + () => sortedCategories.value.indexOf(categoryName) + ); + return KanbanBoard(categoryName, index, boardViewModel); + }; return /* @__PURE__ */ createElement( "div", { @@ -2708,7 +2716,7 @@ } ); } - function KanbanBoard(categoryName, boardViewModel) { + function KanbanBoard(categoryName, index, boardViewModel) { return FilteredList( { category: categoryName }, (taskViewModel) => taskViewModel.task, @@ -2718,7 +2726,7 @@ function drop() { boardViewModel.handleDropWithinBoard(categoryName); } - return /* @__PURE__ */ createElement("div", { class: "flex-column flex-no", "on:dragover": allowDrop, "on:drop": drop }, /* @__PURE__ */ createElement("div", { class: "flex-row width-input" }, /* @__PURE__ */ createElement( + const view = /* @__PURE__ */ createElement("div", { class: "flex-column flex-no", "on:dragover": allowDrop, "on:drop": drop }, /* @__PURE__ */ createElement("div", { class: "flex-row width-input" }, /* @__PURE__ */ createElement( "input", { placeholder: translations.chatPage.task.renameCategoryInputPlaceholder, @@ -2740,6 +2748,10 @@ "children:append": [taskViewModels, TaskViewModelToEntry] } )); + index.subscribe((newIndex) => { + view.style.order = newIndex; + }); + return view; } ); } diff --git a/src/Model/Utility/utility.ts b/src/Model/Utility/utility.ts index 7d93be77..85598cfc 100644 --- a/src/Model/Utility/utility.ts +++ b/src/Model/Utility/utility.ts @@ -90,7 +90,7 @@ export function collectObjectValuesForKey( values.add(stringEntryObjectValue); } - return [...values.values()].sort(localeCompare); + return [...values.values()]; } export function filterObjectsByWords( diff --git a/src/View/ChatPages/boardKanbanPage.tsx b/src/View/ChatPages/boardKanbanPage.tsx index dde7dcf1..c87ea21f 100644 --- a/src/View/ChatPages/boardKanbanPage.tsx +++ b/src/View/ChatPages/boardKanbanPage.tsx @@ -7,20 +7,30 @@ import { TaskCategoryBulkChangeViewModel } from "../../ViewModel/Utility/taskPro import TaskViewModel from "../../ViewModel/Pages/taskViewModel"; import { TaskViewModelToEntry } from "../Components/taskEntry"; import { allowDrop } from "../utility"; +import { localeCompare } from "../../Model/Utility/utility"; import { translations } from "../translations"; export function BoardKanbanPage(boardViewModel: BoardViewModel) { - const categoryNameConverter: React.StateItemConverter = ( - categoryName: string - ) => { - return KanbanBoard(categoryName, boardViewModel); - }; - return PropertyValueList( "category", (taskViewModel: TaskViewModel) => taskViewModel.task, boardViewModel.taskViewModels, (categories: React.ListState) => { + const sortedCategories: React.State = React.createProxyState( + [categories], + () => [...categories.value.values()].sort(localeCompare) + ); + + const categoryNameConverter: React.StateItemConverter = ( + categoryName: string + ) => { + const index: React.State = React.createProxyState( + [sortedCategories], + () => sortedCategories.value.indexOf(categoryName) + ); + return KanbanBoard(categoryName, index, boardViewModel); + }; + return (
, + boardViewModel: BoardViewModel +) { return FilteredList( { category: categoryName }, (taskViewModel: TaskViewModel) => taskViewModel.task, @@ -44,7 +58,7 @@ function KanbanBoard(categoryName: string, boardViewModel: BoardViewModel) { boardViewModel.handleDropWithinBoard(categoryName); } - return ( + const view = (
); + + index.subscribe((newIndex) => { + view.style.order = newIndex; + }) + return view; } ); }