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

114 lines
3.8 KiB
TypeScript
Raw Normal View History

2024-07-25 01:38:11 +02:00
import * as React from "bloatless-react";
2026-04-18 11:55:01 +00:00
import { ViewController } from "../viewController";
import { TaskViewModelToEntry } from "../Components/taskEntry";
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 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";
2026-04-18 11:55:01 +00:00
import BoardViewModel from "../../ViewModel/Pages/boardViewModel";
import CoreViewModel from "../../ViewModel/Global/coreViewModel";
2024-07-25 01:38:11 +02:00
export function BoardKanbanPage(
coreViewModel: CoreViewModel,
boardViewModel: BoardViewModel,
) {
2026-04-01 08:29:39 +00:00
return PropertyValueList(
"category",
(taskViewModel: TaskViewModel) => taskViewModel.task,
boardViewModel.filteredTaskViewModels,
2026-04-01 08:29:39 +00:00
(
categories: React.ListState<string>,
sortedCategories: React.State<string[]>,
) => {
const categoryNameConverter: React.StateItemConverter<string> = (
categoryName: string,
) => {
const index: React.State<number> =
createPropertyValueIndexState(
sortedCategories,
categoryName,
);
return Column(
coreViewModel,
categoryName,
index,
boardViewModel,
);
2026-04-01 08:29:39 +00:00
};
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
}
function Column(
coreViewModel: CoreViewModel,
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"
2026-04-15 12:47:10 +00:00
on:dragover={ViewController.allowDrop}
2026-04-01 08:29:39 +00:00
on:drop={drop}
>
<div class="flex-row width-input">
<input
placeholder={
coreViewModel.translations.chatPage.task
2026-04-01 08:29:39 +00:00
.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
}