Files
CT/src/ViewModel/Pages/taskPageViewModel.ts
T

36 lines
883 B
TypeScript
Raw Normal View History

2024-07-22 19:54:39 +02:00
import * as React from "bloatless-react";
2024-07-22 20:02:13 +02:00
import TaskModel, {
BoardInfoFileContent,
} from "../../Model/Files/taskModel";
import StorageModel from "../../Model/Global/storageModel";
2024-07-22 21:07:44 +02:00
export default class TaskPageViewModel {
2024-07-22 20:02:13 +02:00
taskModel: TaskModel;
// state
newBoardNameInput: React.State<string> = new React.State("");
boards: React.ListState<BoardInfoFileContent> = new React.ListState();
// guards
cannotCreateBoard: React.State<boolean> = React.createProxyState(
[this.newBoardNameInput],
() => this.newBoardNameInput.value == ""
);
// methods
createBoard = (): void => {
if (this.cannotCreateBoard.value == true) return;
this.taskModel.createBoard(this.newBoardNameInput.value);
this.newBoardNameInput.value = "";
};
// init
constructor(taskModel: TaskModel, storageModel: StorageModel) {
this.taskModel = taskModel;
}
}