2024-07-25 01:38:11 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
2024-07-25 18:42:06 +02:00
|
|
|
import {
|
|
|
|
|
PropertyValueList,
|
|
|
|
|
createPropertyValueIndexState,
|
|
|
|
|
} 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";
|
2024-07-25 01:42:41 +02:00
|
|
|
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) {
|
2024-07-25 01:42:41 +02:00
|
|
|
return PropertyValueList(
|
|
|
|
|
"category",
|
|
|
|
|
(taskViewModel: TaskViewModel) => taskViewModel.task,
|
|
|
|
|
boardViewModel.taskViewModels,
|
2024-07-25 18:42:06 +02:00
|
|
|
(
|
|
|
|
|
categories: React.ListState<string>,
|
|
|
|
|
sortedCategories: React.State<string[]>
|
|
|
|
|
) => {
|
2024-07-25 18:25:05 +02:00
|
|
|
const categoryNameConverter: React.StateItemConverter<string> = (
|
|
|
|
|
categoryName: string
|
|
|
|
|
) => {
|
2024-07-25 18:42:06 +02:00
|
|
|
const index: React.State<number> = createPropertyValueIndexState(
|
|
|
|
|
sortedCategories,
|
|
|
|
|
categoryName
|
2024-07-25 18:25:05 +02:00
|
|
|
);
|
|
|
|
|
return KanbanBoard(categoryName, index, boardViewModel);
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-25 02:49:23 +02:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
class="kanban-board-wrapper"
|
|
|
|
|
children:append={[categories, categoryNameConverter]}
|
|
|
|
|
></div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-25 18:25:05 +02:00
|
|
|
function KanbanBoard(
|
|
|
|
|
categoryName: string,
|
|
|
|
|
index: React.State<number>,
|
|
|
|
|
boardViewModel: BoardViewModel
|
|
|
|
|
) {
|
2024-07-25 02:49:23 +02:00
|
|
|
return FilteredList(
|
|
|
|
|
{ category: categoryName },
|
|
|
|
|
(taskViewModel: TaskViewModel) => taskViewModel.task,
|
2024-07-25 15:31:27 +02:00
|
|
|
boardViewModel.filteredTaskViewModels,
|
2024-07-25 02:49:23 +02:00
|
|
|
(taskViewModels: React.ListState<TaskViewModel>) => {
|
|
|
|
|
const viewModel: TaskCategoryBulkChangeViewModel =
|
|
|
|
|
new TaskCategoryBulkChangeViewModel(taskViewModels, categoryName);
|
|
|
|
|
|
2024-07-25 16:20:43 +02:00
|
|
|
function drop() {
|
2024-07-25 17:59:11 +02:00
|
|
|
boardViewModel.handleDropWithinBoard(categoryName);
|
2024-07-25 16:20:43 +02:00
|
|
|
}
|
|
|
|
|
|
2024-07-25 18:25:05 +02:00
|
|
|
const view = (
|
2024-07-25 16:20:43 +02:00
|
|
|
<div class="flex-column flex-no" on:dragover={allowDrop} on:drop={drop}>
|
2024-07-25 02:49:23 +02:00
|
|
|
<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>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
|
|
|
|
<div
|
2024-07-25 04:12:30 +02:00
|
|
|
class="kanban-column"
|
2024-07-25 02:49:23 +02:00
|
|
|
children:append={[taskViewModels, TaskViewModelToEntry]}
|
|
|
|
|
></div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2024-07-25 18:25:05 +02:00
|
|
|
|
|
|
|
|
index.subscribe((newIndex) => {
|
|
|
|
|
view.style.order = newIndex;
|
2024-07-25 18:42:06 +02:00
|
|
|
});
|
|
|
|
|
|
2024-07-25 18:25:05 +02:00
|
|
|
return view;
|
2024-07-25 02:49:23 +02:00
|
|
|
}
|
2024-07-25 01:42:41 +02:00
|
|
|
);
|
2024-07-25 01:38:11 +02:00
|
|
|
}
|