add BoardViewModel
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import * as React from "bloatless-react";
|
||||
|
||||
import { BoardInfoFileContent } from "../../Model/Files/taskModel";
|
||||
import { Color } from "../../colors";
|
||||
import TaskPageViewModel from "./taskPageViewModel";
|
||||
|
||||
export default class BoardViewModel {
|
||||
taskPageViewModel: TaskPageViewModel;
|
||||
|
||||
// data
|
||||
boardInfo: BoardInfoFileContent;
|
||||
|
||||
name: React.State<string> = new React.State("");
|
||||
color: React.State<Color> = new React.State<Color>(Color.Standard);
|
||||
|
||||
// load
|
||||
loadListRelevantData = (): void => {
|
||||
this.name.value = this.boardInfo.name;
|
||||
this.color.value = this.boardInfo.color;
|
||||
}
|
||||
|
||||
loadData = (): void => {}
|
||||
|
||||
// init
|
||||
constructor(taskPageViewModel: TaskPageViewModel, boardInfo: BoardInfoFileContent) {
|
||||
this.taskPageViewModel = taskPageViewModel;
|
||||
this.boardInfo = boardInfo;
|
||||
|
||||
this.loadListRelevantData();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import TaskModel, {
|
||||
BoardInfoFileContentReference,
|
||||
} from "../../Model/Files/taskModel";
|
||||
|
||||
import BoardViewModel from "./boardViewModel";
|
||||
import { FileContent } from "../../Model/Files/fileModel";
|
||||
import StorageModel from "../../Model/Global/storageModel";
|
||||
import { checkMatchesObjectStructure } from "../../Model/Utility/typeSafety";
|
||||
@@ -15,7 +16,7 @@ export default class TaskPageViewModel {
|
||||
// state
|
||||
newBoardNameInput: React.State<string> = new React.State("");
|
||||
|
||||
boards: React.ListState<BoardInfoFileContent> = new React.ListState();
|
||||
boardViewModels: React.ListState<BoardViewModel> = new React.ListState();
|
||||
|
||||
// guards
|
||||
cannotCreateBoard: React.State<boolean> = React.createProxyState(
|
||||
@@ -41,17 +42,18 @@ export default class TaskPageViewModel {
|
||||
this.taskModel.createBoard(this.newBoardNameInput.value);
|
||||
this.newBoardNameInput.value = "";
|
||||
|
||||
this.boards.add(boardInfoFileContent);
|
||||
this.showBoard(boardInfoFileContent);
|
||||
};
|
||||
|
||||
// view
|
||||
showBoard = (boardInfo: BoardInfoFileContent): void => {
|
||||
this.boards.add(boardInfo);
|
||||
const boardViewModel: BoardViewModel = new BoardViewModel(this, boardInfo);
|
||||
this.boardViewModels.add(boardViewModel);
|
||||
};
|
||||
|
||||
// load
|
||||
loadData = (): void => {
|
||||
this.boards.clear();
|
||||
this.boardViewModels.clear();
|
||||
|
||||
const boardIds: string[] = this.taskModel.listBoardIds();
|
||||
for (const boardId of boardIds) {
|
||||
|
||||
Reference in New Issue
Block a user