2024-07-25 04:12:30 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
TaskCategoryBulkChangeViewModel,
|
|
|
|
|
TaskStatusBulkChangeViewModel,
|
2024-07-25 15:31:27 +02:00
|
|
|
} from "../../ViewModel/Utility/taskPropertyBulkChangeViewModel";
|
2024-07-25 04:12:30 +02:00
|
|
|
|
|
|
|
|
import BoardViewModel from "../../ViewModel/Pages/boardViewModel";
|
|
|
|
|
import { FilteredList } from "../Components/filteredList";
|
2024-07-25 16:57:51 +02:00
|
|
|
import { PropertyValueList } from "../Components/propertyValueList";
|
2024-07-25 04:12:30 +02:00
|
|
|
import TaskViewModel from "../../ViewModel/Pages/taskViewModel";
|
|
|
|
|
import { TaskViewModelToEntry } from "../Components/taskEntry";
|
2024-07-25 16:24:09 +02:00
|
|
|
import { allowDrop } from "../utility";
|
2024-07-25 04:12:30 +02:00
|
|
|
import { collectObjectValuesForKey } from "../../Model/Utility/utility";
|
|
|
|
|
import { translations } from "../translations";
|
|
|
|
|
|
|
|
|
|
export function BoardStatusGridPage(boardViewModel: BoardViewModel) {
|
|
|
|
|
const categoryRowConverter: React.StateItemConverter<string> = (
|
|
|
|
|
categoryName: string
|
|
|
|
|
) => {
|
|
|
|
|
return CategoryRow(categoryName, statuses, boardViewModel);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const statusNameCellConverter: React.StateItemConverter<string> = (
|
|
|
|
|
statusName: string
|
|
|
|
|
) => {
|
|
|
|
|
return StatusNameCell(statusName, boardViewModel);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const statuses: React.ListState<string> = new React.ListState();
|
|
|
|
|
boardViewModel.taskViewModels.subscribe(() => {
|
|
|
|
|
statuses.clear();
|
|
|
|
|
const statusArray: string[] = collectObjectValuesForKey(
|
|
|
|
|
"status",
|
|
|
|
|
(taskViewModel: TaskViewModel) => taskViewModel.task,
|
|
|
|
|
[...boardViewModel.taskViewModels.value.values()]
|
|
|
|
|
);
|
|
|
|
|
statuses.add(...statusArray);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="status-page-content">
|
|
|
|
|
<div
|
|
|
|
|
class="status-name-row"
|
|
|
|
|
children:append={[statuses, statusNameCellConverter]}
|
|
|
|
|
></div>
|
|
|
|
|
{PropertyValueList(
|
|
|
|
|
"category",
|
|
|
|
|
(taskViewModel: TaskViewModel) => taskViewModel.task,
|
2024-07-25 15:31:27 +02:00
|
|
|
boardViewModel.filteredTaskViewModels,
|
2024-07-25 04:12:30 +02:00
|
|
|
(categories: React.ListState<string>) => {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
class="status-grid-wrapper"
|
|
|
|
|
children:append={[categories, categoryRowConverter]}
|
|
|
|
|
></div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function StatusNameCell(statusName: string, boardViewModel: BoardViewModel) {
|
|
|
|
|
const taskViewModelsWithMatchingStatus: React.ListState<TaskViewModel> =
|
|
|
|
|
new React.ListState();
|
|
|
|
|
|
|
|
|
|
boardViewModel.taskViewModels.handleAddition(
|
|
|
|
|
(taskViewModel: TaskViewModel) => {
|
|
|
|
|
const doesMatchStatus: boolean = taskViewModel.task.status == statusName;
|
|
|
|
|
if (doesMatchStatus == false) return;
|
|
|
|
|
|
|
|
|
|
taskViewModelsWithMatchingStatus.add(taskViewModel);
|
|
|
|
|
boardViewModel.taskViewModels.handleRemoval(taskViewModel, () => {
|
|
|
|
|
taskViewModelsWithMatchingStatus.remove(taskViewModel);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const viewModel: TaskStatusBulkChangeViewModel =
|
|
|
|
|
new TaskStatusBulkChangeViewModel(
|
|
|
|
|
taskViewModelsWithMatchingStatus,
|
|
|
|
|
statusName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="flex-row">
|
|
|
|
|
<div class="property-input-wrapper">
|
|
|
|
|
<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>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CategoryRow(
|
|
|
|
|
categoryName: string,
|
|
|
|
|
allStatuses: React.ListState<string>,
|
|
|
|
|
boardViewModel: BoardViewModel
|
|
|
|
|
) {
|
|
|
|
|
return FilteredList(
|
|
|
|
|
{ category: categoryName },
|
|
|
|
|
(taskViewModel: TaskViewModel) => taskViewModel.task,
|
|
|
|
|
boardViewModel.taskViewModels,
|
|
|
|
|
(taskViewModels: React.ListState<TaskViewModel>) => {
|
|
|
|
|
const statusNameConverter: React.StateItemConverter<string> = (
|
|
|
|
|
statusName: string
|
|
|
|
|
) => {
|
2024-07-25 16:24:09 +02:00
|
|
|
return CategoryStatusColumn(
|
|
|
|
|
categoryName,
|
|
|
|
|
statusName,
|
|
|
|
|
boardViewModel,
|
|
|
|
|
taskViewModels
|
|
|
|
|
);
|
2024-07-25 04:12:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const viewModel: TaskCategoryBulkChangeViewModel =
|
|
|
|
|
new TaskCategoryBulkChangeViewModel(taskViewModels, categoryName);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="flex-row flex-no large-gap">
|
|
|
|
|
<div class="property-input-wrapper">
|
|
|
|
|
<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>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="flex-row large-gap padding-right"
|
|
|
|
|
children:append={[allStatuses, statusNameConverter]}
|
|
|
|
|
></div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CategoryStatusColumn(
|
2024-07-25 16:24:09 +02:00
|
|
|
categoryName: string,
|
2024-07-25 04:12:30 +02:00
|
|
|
statusName: string,
|
2024-07-25 16:24:09 +02:00
|
|
|
boardViewModel: BoardViewModel,
|
2024-07-25 04:12:30 +02:00
|
|
|
taskViewModelsWithMatchingCategory: React.ListState<TaskViewModel>
|
|
|
|
|
) {
|
|
|
|
|
const taskViewModels: React.ListState<TaskViewModel> = new React.ListState();
|
|
|
|
|
|
|
|
|
|
taskViewModelsWithMatchingCategory.handleAddition((taskViewModel) => {
|
|
|
|
|
const doesMatchStatus: boolean = taskViewModel.status.value == statusName;
|
|
|
|
|
if (doesMatchStatus == false) return;
|
|
|
|
|
|
|
|
|
|
taskViewModels.add(taskViewModel);
|
|
|
|
|
taskViewModelsWithMatchingCategory.handleRemoval(taskViewModel, () => {
|
|
|
|
|
taskViewModels.remove(taskViewModel);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2024-07-25 16:24:09 +02:00
|
|
|
function drop() {
|
2024-07-25 17:59:11 +02:00
|
|
|
boardViewModel.handleDropWithinBoard(categoryName, statusName);
|
2024-07-25 16:24:09 +02:00
|
|
|
}
|
|
|
|
|
|
2024-07-25 04:12:30 +02:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
class="status-column gap"
|
2024-07-25 16:24:09 +02:00
|
|
|
on:dragover={allowDrop}
|
|
|
|
|
on:drop={drop}
|
2024-07-25 04:12:30 +02:00
|
|
|
children:append={[taskViewModels, TaskViewModelToEntry]}
|
|
|
|
|
></div>
|
|
|
|
|
);
|
|
|
|
|
}
|