Files
CT/src/View/ChatPages/boardKanbanPage.tsx
T

107 lines
3.6 KiB
TypeScript
Raw Normal View History

2024-07-25 01:38:11 +02:00
import * as React from "bloatless-react";
2024-07-25 18:42:06 +02:00
import {
2026-04-01 08:29:39 +00:00
PropertyValueList,
createPropertyValueIndexState,
2024-07-25 18:42:06 +02:00
} from "../Components/propertyValueList";
2024-07-25 01:38:11 +02:00
import BoardViewModel from "../../ViewModel/Pages/boardViewModel";
2024-07-25 02:49:23 +02:00
import { FilteredList } from "../Components/filteredList";
2024-07-25 15:31:27 +02:00
import { TaskCategoryBulkChangeViewModel } from "../../ViewModel/Utility/taskPropertyBulkChangeViewModel";
import TaskViewModel from "../../ViewModel/Pages/taskViewModel";
2024-07-25 02:49:23 +02:00
import { TaskViewModelToEntry } from "../Components/taskEntry";
2024-07-25 16:20:43 +02:00
import { allowDrop } from "../utility";
2024-07-25 02:49:23 +02:00
import { translations } from "../translations";
2024-07-25 01:38:11 +02:00
export function BoardKanbanPage(boardViewModel: BoardViewModel) {
2026-04-01 08:29:39 +00:00
return PropertyValueList(
"category",
(taskViewModel: TaskViewModel) => taskViewModel.task,
boardViewModel.taskViewModels,
(
categories: React.ListState<string>,
sortedCategories: React.State<string[]>,
) => {
const categoryNameConverter: React.StateItemConverter<string> = (
categoryName: string,
) => {
const index: React.State<number> =
createPropertyValueIndexState(
sortedCategories,
categoryName,
);
return KanbanBoard(categoryName, index, boardViewModel);
};
2024-07-25 18:25:05 +02:00
2026-04-01 08:29:39 +00:00
return (
<div
class="kanban-board-wrapper"
children:append={[categories, categoryNameConverter]}
></div>
);
},
);
2024-07-25 02:49:23 +02:00
}
2024-07-25 18:25:05 +02:00
function KanbanBoard(
2026-04-01 08:29:39 +00:00
categoryName: string,
index: React.State<number>,
boardViewModel: BoardViewModel,
2024-07-25 18:25:05 +02:00
) {
2026-04-01 08:29:39 +00:00
return FilteredList(
{ category: categoryName },
(taskViewModel: TaskViewModel) => taskViewModel.task,
boardViewModel.filteredTaskViewModels,
(taskViewModels: React.ListState<TaskViewModel>) => {
const viewModel: TaskCategoryBulkChangeViewModel =
new TaskCategoryBulkChangeViewModel(
taskViewModels,
categoryName,
);
2024-07-25 02:49:23 +02:00
2026-04-01 08:29:39 +00:00
function drop() {
boardViewModel.handleDropWithinBoard(categoryName);
}
2024-07-25 16:20:43 +02:00
2026-04-01 08:29:39 +00:00
const view = (
<div
class="flex-column flex-no"
on:dragover={allowDrop}
on:drop={drop}
>
<div class="flex-row width-input">
<input
placeholder={
translations.chatPage.task
.renameCategoryInputPlaceholder
}
bind:value={viewModel.inputValue}
on:enter={viewModel.set}
></input>
<button
class="primary"
on:click={viewModel.set}
toggle:disabled={viewModel.cannotSet}
>
<span class="icon">check</span>
</button>
</div>
2024-07-25 02:49:23 +02:00
2026-04-01 08:29:39 +00:00
<hr></hr>
2024-07-25 02:49:23 +02:00
2026-04-01 08:29:39 +00:00
<div
class="kanban-column"
children:append={[taskViewModels, TaskViewModelToEntry]}
></div>
</div>
);
2024-07-25 18:25:05 +02:00
2026-04-01 08:29:39 +00:00
index.subscribe((newIndex) => {
view.style.order = newIndex;
});
return view;
},
);
2024-07-25 01:38:11 +02:00
}