prepare taskViewModel
This commit is contained in:
@@ -243,7 +243,7 @@ export interface TaskFileContent extends FileContent<"task"> {
|
|||||||
|
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|
||||||
priority?: number;
|
priority?: string;
|
||||||
date?: string;
|
date?: string;
|
||||||
time?: string;
|
time?: string;
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
} from "../Utility/utility";
|
} from "../Utility/utility";
|
||||||
import StorageModel, { filePaths } from "../Global/storageModel";
|
import StorageModel, { filePaths } from "../Global/storageModel";
|
||||||
|
|
||||||
import BoardModel from "./boadModel";
|
import BoardModel from "./boardModel";
|
||||||
import ChatModel from "../Chat/chatModel";
|
import ChatModel from "../Chat/chatModel";
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import * as React from "bloatless-react";
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
import BoardModel, { BoardInfoFileContent } from "../../Model/Files/boadModel";
|
import BoardModel, {
|
||||||
|
BoardInfoFileContent,
|
||||||
|
BoardInfoFileContentReference,
|
||||||
|
} from "../../Model/Files/boardModel";
|
||||||
|
|
||||||
import { Color } from "../../colors";
|
import { Color } from "../../colors";
|
||||||
import StorageModel from "../../Model/Global/storageModel";
|
import StorageModel from "../../Model/Global/storageModel";
|
||||||
@@ -8,11 +11,14 @@ import TaskPageViewModel from "./taskPageViewModel";
|
|||||||
|
|
||||||
export default class BoardViewModel {
|
export default class BoardViewModel {
|
||||||
storageModel: StorageModel;
|
storageModel: StorageModel;
|
||||||
|
boardModel: BoardModel;
|
||||||
|
|
||||||
taskPageViewModel: TaskPageViewModel;
|
taskPageViewModel: TaskPageViewModel;
|
||||||
|
|
||||||
// state
|
// data
|
||||||
boardInfo: BoardInfoFileContent;
|
boardInfo: BoardInfoFileContent;
|
||||||
|
|
||||||
|
// state
|
||||||
name: React.State<string> = new React.State("");
|
name: React.State<string> = new React.State("");
|
||||||
color: React.State<Color> = new React.State<Color>(Color.Standard);
|
color: React.State<Color> = new React.State<Color>(Color.Standard);
|
||||||
|
|
||||||
@@ -123,11 +129,13 @@ export default class BoardViewModel {
|
|||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(
|
constructor(
|
||||||
|
storageModel: StorageModel,
|
||||||
|
boardModel: BoardModel,
|
||||||
taskPageViewModel: TaskPageViewModel,
|
taskPageViewModel: TaskPageViewModel,
|
||||||
boardInfo: BoardInfoFileContent,
|
boardInfo: BoardInfoFileContent
|
||||||
storageModel: StorageModel
|
|
||||||
) {
|
) {
|
||||||
this.storageModel = storageModel;
|
this.storageModel = storageModel;
|
||||||
|
this.boardModel = boardModel;
|
||||||
this.taskPageViewModel = taskPageViewModel;
|
this.taskPageViewModel = taskPageViewModel;
|
||||||
this.boardInfo = boardInfo;
|
this.boardInfo = boardInfo;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as React from "bloatless-react";
|
|||||||
import BoardModel, {
|
import BoardModel, {
|
||||||
BoardInfoFileContent,
|
BoardInfoFileContent,
|
||||||
BoardInfoFileContentReference,
|
BoardInfoFileContentReference,
|
||||||
} from "../../Model/Files/boadModel";
|
} from "../../Model/Files/boardModel";
|
||||||
|
|
||||||
import BoardViewModel from "./boardViewModel";
|
import BoardViewModel from "./boardViewModel";
|
||||||
import ChatViewModel from "../Chat/chatViewModel";
|
import ChatViewModel from "../Chat/chatViewModel";
|
||||||
@@ -14,7 +14,7 @@ import { checkMatchesObjectStructure } from "../../Model/Utility/typeSafety";
|
|||||||
|
|
||||||
export default class TaskPageViewModel {
|
export default class TaskPageViewModel {
|
||||||
storageModel: StorageModel;
|
storageModel: StorageModel;
|
||||||
taskModel: BoardModel;
|
boardModel: BoardModel;
|
||||||
|
|
||||||
chatViewModel: ChatViewModel;
|
chatViewModel: ChatViewModel;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ export default class TaskPageViewModel {
|
|||||||
|
|
||||||
// paths
|
// paths
|
||||||
getBasePath = (): string[] => {
|
getBasePath = (): string[] => {
|
||||||
return [...this.taskModel.getViewPath()];
|
return [...this.boardModel.getViewPath()];
|
||||||
};
|
};
|
||||||
|
|
||||||
getBoardViewPath = (boardId): string[] => {
|
getBoardViewPath = (boardId): string[] => {
|
||||||
@@ -66,7 +66,7 @@ export default class TaskPageViewModel {
|
|||||||
if (this.cannotCreateBoard.value == true) return;
|
if (this.cannotCreateBoard.value == true) return;
|
||||||
|
|
||||||
const boardInfoFileContent: BoardInfoFileContent =
|
const boardInfoFileContent: BoardInfoFileContent =
|
||||||
this.taskModel.createBoard(this.newBoardNameInput.value);
|
this.boardModel.createBoard(this.newBoardNameInput.value);
|
||||||
this.newBoardNameInput.value = "";
|
this.newBoardNameInput.value = "";
|
||||||
|
|
||||||
this.showBoardInList(boardInfoFileContent);
|
this.showBoardInList(boardInfoFileContent);
|
||||||
@@ -74,12 +74,12 @@ export default class TaskPageViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
updateBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
updateBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
||||||
this.taskModel.updateBoard(boardInfoFileContent);
|
this.boardModel.updateBoard(boardInfoFileContent);
|
||||||
this.updateIndices();
|
this.updateIndices();
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
deleteBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
|
||||||
this.taskModel.deleteBoard(boardInfoFileContent.fileId);
|
this.boardModel.deleteBoard(boardInfoFileContent.fileId);
|
||||||
this.boardViewModels.remove(boardInfoFileContent.fileId);
|
this.boardViewModels.remove(boardInfoFileContent.fileId);
|
||||||
this.updateIndices();
|
this.updateIndices();
|
||||||
};
|
};
|
||||||
@@ -87,9 +87,10 @@ export default class TaskPageViewModel {
|
|||||||
// view
|
// view
|
||||||
showBoardInList = (boardInfo: BoardInfoFileContent): void => {
|
showBoardInList = (boardInfo: BoardInfoFileContent): void => {
|
||||||
const boardViewModel: BoardViewModel = new BoardViewModel(
|
const boardViewModel: BoardViewModel = new BoardViewModel(
|
||||||
|
this.storageModel,
|
||||||
|
this.boardModel,
|
||||||
this,
|
this,
|
||||||
boardInfo,
|
boardInfo
|
||||||
this.storageModel
|
|
||||||
);
|
);
|
||||||
this.boardViewModels.set(boardInfo.fileId, boardViewModel);
|
this.boardViewModels.set(boardInfo.fileId, boardViewModel);
|
||||||
};
|
};
|
||||||
@@ -138,10 +139,10 @@ export default class TaskPageViewModel {
|
|||||||
loadData = (): void => {
|
loadData = (): void => {
|
||||||
this.boardViewModels.clear();
|
this.boardViewModels.clear();
|
||||||
|
|
||||||
const boardIds: string[] = this.taskModel.listBoardIds();
|
const boardIds: string[] = this.boardModel.listBoardIds();
|
||||||
for (const boardId of boardIds) {
|
for (const boardId of boardIds) {
|
||||||
const boardInfo: BoardInfoFileContent | null =
|
const boardInfo: BoardInfoFileContent | null =
|
||||||
this.taskModel.getBoardInfo(boardId);
|
this.boardModel.getBoardInfo(boardId);
|
||||||
if (boardInfo == null) continue;
|
if (boardInfo == null) continue;
|
||||||
|
|
||||||
this.showBoardInList(boardInfo);
|
this.showBoardInList(boardInfo);
|
||||||
@@ -153,17 +154,17 @@ export default class TaskPageViewModel {
|
|||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(
|
constructor(
|
||||||
taskModel: BoardModel,
|
boardModel: BoardModel,
|
||||||
storageModel: StorageModel,
|
storageModel: StorageModel,
|
||||||
chatViewModel: ChatViewModel
|
chatViewModel: ChatViewModel
|
||||||
) {
|
) {
|
||||||
this.taskModel = taskModel;
|
this.boardModel = boardModel;
|
||||||
this.storageModel = storageModel;
|
this.storageModel = storageModel;
|
||||||
|
|
||||||
this.chatViewModel = chatViewModel;
|
this.chatViewModel = chatViewModel;
|
||||||
|
|
||||||
// handlers
|
// handlers
|
||||||
taskModel.boardHandlerManager.addHandler(
|
boardModel.boardHandlerManager.addHandler(
|
||||||
(boardInfoFileContent: BoardInfoFileContent) => {
|
(boardInfoFileContent: BoardInfoFileContent) => {
|
||||||
this.showBoardInList(boardInfoFileContent);
|
this.showBoardInList(boardInfoFileContent);
|
||||||
this.updateIndices();
|
this.updateIndices();
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
|
import BoardModel, {
|
||||||
|
TaskFileContent,
|
||||||
|
TaskFileContentReference,
|
||||||
|
} from "../../Model/Files/boardModel";
|
||||||
|
|
||||||
|
import BoardViewModel from "./boardViewModel";
|
||||||
|
import StorageModel from "../../Model/Global/storageModel";
|
||||||
|
|
||||||
|
export default class TaskViewModel {
|
||||||
|
boardModel: BoardModel;
|
||||||
|
storageModel: StorageModel;
|
||||||
|
|
||||||
|
boardViewModel: BoardViewModel;
|
||||||
|
|
||||||
|
// data
|
||||||
|
fileId: string;
|
||||||
|
|
||||||
|
// paths
|
||||||
|
getFilePath = (): string[] => {
|
||||||
|
return this.boardModel.getTaskFilePath(this.fileId);
|
||||||
|
};
|
||||||
|
|
||||||
|
// state
|
||||||
|
name: React.State<string> = new React.State("");
|
||||||
|
|
||||||
|
category: React.State<string> = new React.State("");
|
||||||
|
status: React.State<string> = new React.State("");
|
||||||
|
|
||||||
|
description: React.State<string> = new React.State("");
|
||||||
|
|
||||||
|
priority: React.State<string> = new React.State("");
|
||||||
|
date: React.State<string> = new React.State("");
|
||||||
|
time: React.State<string> = new React.State("");
|
||||||
|
|
||||||
|
// storage
|
||||||
|
save = (): void => {
|
||||||
|
const newTaskFileContent: TaskFileContent =
|
||||||
|
BoardModel.createTaskFileContent(
|
||||||
|
this.fileId,
|
||||||
|
this.name.value,
|
||||||
|
this.boardViewModel.boardInfo.fileId
|
||||||
|
);
|
||||||
|
|
||||||
|
newTaskFileContent.status = this.status.value;
|
||||||
|
newTaskFileContent.category = this.category.value;
|
||||||
|
newTaskFileContent.description = this.description.value;
|
||||||
|
newTaskFileContent.priority = this.priority.value;
|
||||||
|
newTaskFileContent.date = this.date.value;
|
||||||
|
newTaskFileContent.time = this.time.value;
|
||||||
|
|
||||||
|
this.boardModel.updateTask(newTaskFileContent);
|
||||||
|
};
|
||||||
|
|
||||||
|
// load
|
||||||
|
loadAllData = (): void => {
|
||||||
|
const path: string[] = this.getFilePath();
|
||||||
|
const taskFileContent: TaskFileContent | null =
|
||||||
|
this.storageModel.readStringifiable(path, TaskFileContentReference);
|
||||||
|
if (taskFileContent == null) return;
|
||||||
|
|
||||||
|
this.name.value = taskFileContent.name;
|
||||||
|
|
||||||
|
this.category.value = taskFileContent.category ?? "";
|
||||||
|
this.status.value = taskFileContent.status ?? "";
|
||||||
|
|
||||||
|
this.description.value = taskFileContent.description ?? "";
|
||||||
|
|
||||||
|
this.priority.value = taskFileContent.priority ?? "";
|
||||||
|
this.date.value = taskFileContent.date ?? "";
|
||||||
|
this.time.value = taskFileContent.time ?? "";
|
||||||
|
};
|
||||||
|
|
||||||
|
// init
|
||||||
|
constructor(
|
||||||
|
boardModel: BoardModel,
|
||||||
|
storageModel: StorageModel,
|
||||||
|
boardViewModel: BoardViewModel,
|
||||||
|
fileId: string
|
||||||
|
) {
|
||||||
|
this.boardModel = boardModel;
|
||||||
|
this.storageModel = storageModel;
|
||||||
|
this.boardViewModel = boardViewModel;
|
||||||
|
|
||||||
|
this.fileId = fileId;
|
||||||
|
|
||||||
|
this.loadAllData();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import * as React from "bloatless-react";
|
|
||||||
|
|
||||||
import BoardViewModel from "./ViewModel/Pages/boardViewModel";
|
|
||||||
|
|
||||||
export default class TaskViewModel {
|
|
||||||
boardViewModel: BoardViewModel;
|
|
||||||
|
|
||||||
// state
|
|
||||||
name: React.State<string> = new React.State("");
|
|
||||||
|
|
||||||
category: React.State<string> = new React.State("");
|
|
||||||
status: React.State<string> = new React.State("");
|
|
||||||
|
|
||||||
description: React.State<string> = new React.State("");
|
|
||||||
|
|
||||||
priority: React.State<string> = new React.State("");
|
|
||||||
date: React.State<string> = new React.State("");
|
|
||||||
time: React.State<string> = new React.State("");
|
|
||||||
|
|
||||||
// storage
|
|
||||||
save = (): void => {}
|
|
||||||
|
|
||||||
// init
|
|
||||||
constructor(boardViewModel: BoardViewModel) {
|
|
||||||
this.boardViewModel = boardViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user