2024-07-26 06:20:16 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
import BoardsAndTasksModel, {
|
2026-04-01 08:29:39 +00:00
|
|
|
TaskFileContent,
|
2024-07-26 06:20:16 +02:00
|
|
|
} from "../../Model/Files/boardsAndTasksModel";
|
|
|
|
|
|
2024-07-28 17:09:27 +02:00
|
|
|
import ChatViewModel from "../Chat/chatViewModel";
|
2026-04-12 19:20:37 +00:00
|
|
|
import CoreViewModel, { Context } from "../Global/coreViewModel";
|
2024-07-26 06:20:16 +02:00
|
|
|
import { IndexManager } from "../../Model/Utility/utility";
|
|
|
|
|
import TaskViewModel from "./taskViewModel";
|
|
|
|
|
|
2026-04-12 19:20:37 +00:00
|
|
|
export default class TaskContainingPageViewModel extends Context {
|
2026-04-01 08:29:39 +00:00
|
|
|
// state
|
2026-04-13 10:58:21 +00:00
|
|
|
readonly taskIndexManager = new IndexManager<TaskViewModel>(
|
2026-04-01 08:29:39 +00:00
|
|
|
(taskViewModel: TaskViewModel) => taskViewModel.sortingString,
|
|
|
|
|
);
|
2024-07-26 06:20:16 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
selectedTaskViewModel: React.State<TaskViewModel | undefined> =
|
|
|
|
|
new React.State<any>(undefined);
|
2024-07-26 06:20:16 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
taskViewModels: React.MapState<TaskViewModel> = new React.MapState();
|
2024-07-26 06:20:16 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
// methods
|
|
|
|
|
createTaskFromBoardId = (boardId: string): void => {
|
|
|
|
|
const taskFileContent: TaskFileContent =
|
|
|
|
|
this.boardsAndTasksModel.createTask(boardId);
|
|
|
|
|
const taskViewModel: TaskViewModel = new TaskViewModel(
|
|
|
|
|
this.coreViewModel,
|
|
|
|
|
this.chatViewModel,
|
|
|
|
|
this.boardsAndTasksModel,
|
|
|
|
|
this,
|
|
|
|
|
taskFileContent,
|
|
|
|
|
);
|
2026-04-13 14:07:43 +00:00
|
|
|
taskViewModel.open();
|
2026-04-01 08:29:39 +00:00
|
|
|
this.updateTaskIndices();
|
|
|
|
|
};
|
2024-07-26 06:20:16 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
// view
|
|
|
|
|
showTask = (taskFileContent: TaskFileContent): void => {};
|
|
|
|
|
removeTaskFromView = (taskFileContent: TaskFileContent): void => {};
|
2024-07-26 06:20:16 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
selectTask = (selectedTask: TaskViewModel): void => {
|
|
|
|
|
this.selectedTaskViewModel.value = selectedTask;
|
|
|
|
|
};
|
2024-07-26 06:20:16 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
closeTask = () => {
|
|
|
|
|
this.selectedTaskViewModel.value = undefined;
|
|
|
|
|
};
|
2024-07-26 06:20:16 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
updateTaskIndices = (): void => {
|
|
|
|
|
this.taskIndexManager.update([...this.taskViewModels.value.values()]);
|
2026-04-02 19:11:35 +00:00
|
|
|
for (const taskViewModel of this.taskViewModels.value.values()) {
|
|
|
|
|
taskViewModel.updateIndex();
|
2026-04-01 08:29:39 +00:00
|
|
|
}
|
|
|
|
|
};
|
2024-07-26 06:20:16 +02:00
|
|
|
|
2026-04-01 08:29:39 +00:00
|
|
|
// init
|
|
|
|
|
constructor(
|
2026-04-13 10:58:21 +00:00
|
|
|
public readonly coreViewModel: CoreViewModel,
|
|
|
|
|
public readonly chatViewModel: ChatViewModel,
|
|
|
|
|
public readonly boardsAndTasksModel: BoardsAndTasksModel,
|
2026-04-12 19:20:37 +00:00
|
|
|
) {
|
|
|
|
|
super();
|
|
|
|
|
}
|
2024-07-26 06:20:16 +02:00
|
|
|
}
|