integrate taskViewModel

This commit is contained in:
marlon-erler
2024-07-24 01:19:44 +02:00
parent 5a34a54273
commit bd880dfa06
8 changed files with 195 additions and 71 deletions
+121 -33
View File
@@ -565,8 +565,8 @@
return Color2; return Color2;
})(Color || {}); })(Color || {});
// src/Model/Files/taskModel.ts // src/Model/Files/boardModel.ts
var TaskModel = class _TaskModel { var BoardModel = class _BoardModel {
storageModel; storageModel;
chatModel; chatModel;
fileModel; fileModel;
@@ -616,7 +616,7 @@
}; };
// boards // boards
createBoard = (name) => { createBoard = (name) => {
const boardInfoFileContent = _TaskModel.createBoardInfoFileContent(v4_default(), name, "standard" /* Standard */); const boardInfoFileContent = _BoardModel.createBoardInfoFileContent(v4_default(), name, "standard" /* Standard */);
this.updateBoard(boardInfoFileContent); this.updateBoard(boardInfoFileContent);
return boardInfoFileContent; return boardInfoFileContent;
}; };
@@ -651,13 +651,13 @@
return boardInfoFileContentOrNull; return boardInfoFileContentOrNull;
}; };
//tasks //tasks
createTask = (boardId, name) => { createTask = (boardId) => {
const taskFileContent = _TaskModel.createTaskFileContent( const taskFileContent = _BoardModel.createTaskFileContent(
v4_default(), v4_default(),
name, "",
boardId boardId
); );
this.updateTask(taskFileContent); return taskFileContent;
}; };
updateTask = (taskFileContent) => { updateTask = (taskFileContent) => {
this.storeTask(taskFileContent); this.storeTask(taskFileContent);
@@ -678,6 +678,10 @@
const fileIds = this.storageModel.list(taskContainerPath); const fileIds = this.storageModel.list(taskContainerPath);
return fileIds; return fileIds;
}; };
getTaskFileContent = (taskId) => {
const taskFileContentOrNull = this.fileModel.getLatestFileContent(taskId, TaskFileContentReference);
return taskFileContentOrNull;
};
deleteTask = (boardId, taskId) => { deleteTask = (boardId, taskId) => {
const taskFilePath = this.getTaskFilePath(taskId); const taskFilePath = this.getTaskFilePath(taskId);
const taskReferencePath = this.getTaskReferencePath( const taskReferencePath = this.getTaskReferencePath(
@@ -828,7 +832,7 @@
constructor(chatModel, storageModel2) { constructor(chatModel, storageModel2) {
this.chatModel = chatModel; this.chatModel = chatModel;
this.storageModel = storageModel2; this.storageModel = storageModel2;
this.taskModel = new TaskModel(this.storageModel, chatModel, this); this.taskModel = new BoardModel(this.storageModel, chatModel, this);
} }
// utility // utility
static generateFileContentId = (creationDate) => { static generateFileContentId = (creationDate) => {
@@ -1409,12 +1413,67 @@
} }
}; };
// src/ViewModel/Pages/taskViewModel.ts
var TaskViewModel = class {
boardModel;
boardViewModel;
// data
task;
// paths
getFilePath = () => {
return this.boardModel.getTaskFilePath(this.task.fileId);
};
// state
name = new State("");
category = new State("");
status = new State("");
description = new State("");
priority = new State("");
date = new State("");
time = new State("");
// storage
save = () => {
const newTaskFileContent = BoardModel.createTaskFileContent(
this.task.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);
this.boardViewModel.trackTask(this);
};
// load
loadAllData = () => {
this.name.value = this.task.name;
this.category.value = this.task.category ?? "";
this.status.value = this.task.status ?? "";
this.description.value = this.task.description ?? "";
this.priority.value = this.task.priority ?? "";
this.date.value = this.task.date ?? "";
this.time.value = this.task.time ?? "";
};
// init
constructor(boardModel, boardViewModel, taskFileContent) {
this.boardModel = boardModel;
this.boardViewModel = boardViewModel;
this.task = taskFileContent;
this.loadAllData();
}
};
// src/ViewModel/Pages/boardViewModel.ts // src/ViewModel/Pages/boardViewModel.ts
var BoardViewModel = class { var BoardViewModel = class {
storageModel; storageModel;
boardModel;
taskPageViewModel; taskPageViewModel;
// state // data
boardInfo; boardInfo;
// state
name = new State(""); name = new State("");
color = new State("standard" /* Standard */); color = new State("standard" /* Standard */);
isSelected; isSelected;
@@ -1425,6 +1484,7 @@
"list" /* List */ "list" /* List */
); );
index = new State(0); index = new State(0);
taskViewModels = new MapState();
// paths // paths
getBasePath = () => { getBasePath = () => {
return [...this.taskPageViewModel.getBoardViewPath(this.boardInfo.fileId)]; return [...this.taskPageViewModel.getBoardViewPath(this.boardInfo.fileId)];
@@ -1462,9 +1522,9 @@
const index = this.taskPageViewModel.boardIndexManager.getIndex(this); const index = this.taskPageViewModel.boardIndexManager.getIndex(this);
this.index.value = index; this.index.value = index;
}; };
// methods // settings
saveSettings = () => { saveSettings = () => {
const newBoardInfoFileContent = TaskModel.createBoardInfoFileContent( const newBoardInfoFileContent = BoardModel.createBoardInfoFileContent(
this.boardInfo.fileId, this.boardInfo.fileId,
this.name.value, this.name.value,
this.color.value this.color.value
@@ -1478,7 +1538,16 @@
this.taskPageViewModel.deleteBoard(this.boardInfo); this.taskPageViewModel.deleteBoard(this.boardInfo);
this.close(); this.close();
}; };
// store // tasks
createTask = () => {
const taskFileContent = this.boardModel.createTask(this.boardInfo.fileId);
const taskViewModel = new TaskViewModel(this.boardModel, this, taskFileContent);
return taskViewModel;
};
trackTask = (taskViewModel) => {
this.taskViewModels.set(taskViewModel.task.fileId, taskViewModel);
};
// storage
storeLastUsedView = () => { storeLastUsedView = () => {
const path = this.getLastUsedBoardPath(); const path = this.getLastUsedBoardPath();
const lastUsedView = this.selectedPage.value; const lastUsedView = this.selectedPage.value;
@@ -1495,12 +1564,30 @@
this.name.value = this.boardInfo.name; this.name.value = this.boardInfo.name;
this.color.value = this.boardInfo.color; this.color.value = this.boardInfo.color;
}; };
loadTasks = () => {
this.taskViewModels.clear();
const taskIds = this.boardModel.listTaskIds(
this.boardInfo.fileId
);
for (const taskId of taskIds) {
const taskFileContent = this.boardModel.getTaskFileContent(taskId);
if (taskFileContent == null) continue;
const taskViewModel = new TaskViewModel(
this.boardModel,
this,
taskFileContent
);
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
}
};
loadData = () => { loadData = () => {
this.restoreLastUsedView(); this.restoreLastUsedView();
this.loadTasks();
}; };
// init // init
constructor(taskPageViewModel, boardInfo, storageModel2) { constructor(storageModel2, boardModel, taskPageViewModel, boardInfo) {
this.storageModel = storageModel2; this.storageModel = storageModel2;
this.boardModel = boardModel;
this.taskPageViewModel = taskPageViewModel; this.taskPageViewModel = taskPageViewModel;
this.boardInfo = boardInfo; this.boardInfo = boardInfo;
this.loadListRelevantData(); this.loadListRelevantData();
@@ -1521,7 +1608,7 @@
// src/ViewModel/Pages/taskPageViewModel.ts // src/ViewModel/Pages/taskPageViewModel.ts
var TaskPageViewModel = class { var TaskPageViewModel = class {
storageModel; storageModel;
taskModel; boardModel;
chatViewModel; chatViewModel;
// data // data
boardIndexManager = new IndexManager( boardIndexManager = new IndexManager(
@@ -1529,7 +1616,7 @@
); );
// paths // paths
getBasePath = () => { getBasePath = () => {
return [...this.taskModel.getViewPath()]; return [...this.boardModel.getViewPath()];
}; };
getBoardViewPath = (boardId) => { getBoardViewPath = (boardId) => {
return [...this.getBasePath(), boardId]; return [...this.getBasePath(), boardId];
@@ -1555,26 +1642,27 @@
// methods // methods
createBoard = () => { createBoard = () => {
if (this.cannotCreateBoard.value == true) return; if (this.cannotCreateBoard.value == true) return;
const boardInfoFileContent = this.taskModel.createBoard(this.newBoardNameInput.value); const boardInfoFileContent = this.boardModel.createBoard(this.newBoardNameInput.value);
this.newBoardNameInput.value = ""; this.newBoardNameInput.value = "";
this.showBoardInList(boardInfoFileContent); this.showBoardInList(boardInfoFileContent);
this.updateIndices(); this.updateIndices();
}; };
updateBoard = (boardInfoFileContent) => { updateBoard = (boardInfoFileContent) => {
this.taskModel.updateBoard(boardInfoFileContent); this.boardModel.updateBoard(boardInfoFileContent);
this.updateIndices(); this.updateIndices();
}; };
deleteBoard = (boardInfoFileContent) => { deleteBoard = (boardInfoFileContent) => {
this.taskModel.deleteBoard(boardInfoFileContent.fileId); this.boardModel.deleteBoard(boardInfoFileContent.fileId);
this.boardViewModels.remove(boardInfoFileContent.fileId); this.boardViewModels.remove(boardInfoFileContent.fileId);
this.updateIndices(); this.updateIndices();
}; };
// view // view
showBoardInList = (boardInfo) => { showBoardInList = (boardInfo) => {
const boardViewModel = new BoardViewModel( const 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);
}; };
@@ -1611,9 +1699,9 @@
// load // load
loadData = () => { loadData = () => {
this.boardViewModels.clear(); this.boardViewModels.clear();
const boardIds = this.taskModel.listBoardIds(); const boardIds = this.boardModel.listBoardIds();
for (const boardId of boardIds) { for (const boardId of boardIds) {
const boardInfo = this.taskModel.getBoardInfo(boardId); const boardInfo = this.boardModel.getBoardInfo(boardId);
if (boardInfo == null) continue; if (boardInfo == null) continue;
this.showBoardInList(boardInfo); this.showBoardInList(boardInfo);
} }
@@ -1621,11 +1709,11 @@
this.openLastUsedBoard(); this.openLastUsedBoard();
}; };
// init // init
constructor(taskModel, storageModel2, chatViewModel) { constructor(storageModel2, boardModel, chatViewModel) {
this.taskModel = taskModel;
this.storageModel = storageModel2; this.storageModel = storageModel2;
this.boardModel = boardModel;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
taskModel.boardHandlerManager.addHandler( boardModel.boardHandlerManager.addHandler(
(boardInfoFileContent) => { (boardInfoFileContent) => {
this.showBoardInList(boardInfoFileContent); this.showBoardInList(boardInfoFileContent);
this.updateIndices(); this.updateIndices();
@@ -1688,14 +1776,14 @@
}); });
}; };
// init // init
constructor(chatModel, storageModel2, settingsViewModel2, chatListViewModel2) { constructor(storageModel2, chatModel, settingsViewModel2, chatListViewModel2) {
this.chatModel = chatModel;
this.storageModel = storageModel2; this.storageModel = storageModel2;
this.chatModel = chatModel;
this.settingsViewModel = settingsViewModel2; this.settingsViewModel = settingsViewModel2;
this.chatListViewModel = chatListViewModel2; this.chatListViewModel = chatListViewModel2;
this.taskPageViewModel = new TaskPageViewModel( this.taskPageViewModel = new TaskPageViewModel(
this.chatModel.fileModel.taskModel,
this.storageModel, this.storageModel,
this.chatModel.fileModel.taskModel,
this this
); );
this.messagePageViewModel = new MessagePageViewModel(this); this.messagePageViewModel = new MessagePageViewModel(this);
@@ -1712,8 +1800,8 @@
// src/ViewModel/Chat/chatListViewModel.ts // src/ViewModel/Chat/chatListViewModel.ts
var ChatListViewModel = class { var ChatListViewModel = class {
chatListModel;
storageModel; storageModel;
chatListModel;
settingsViewModel; settingsViewModel;
// data // data
chatIndexManager = new IndexManager( chatIndexManager = new IndexManager(
@@ -1747,8 +1835,8 @@
}; };
createChatViewModel = (chatModel) => { createChatViewModel = (chatModel) => {
return new ChatViewModel( return new ChatViewModel(
chatModel,
this.storageModel, this.storageModel,
chatModel,
this.settingsViewModel, this.settingsViewModel,
this this
); );
@@ -1776,9 +1864,9 @@
this.updateIndices(); this.updateIndices();
}; };
// init // init
constructor(chatListModel2, storageModel2, settingsViewModel2) { constructor(storageModel2, chatListModel2, settingsViewModel2) {
this.chatListModel = chatListModel2;
this.storageModel = storageModel2; this.storageModel = storageModel2;
this.chatListModel = chatListModel2;
this.settingsViewModel = settingsViewModel2; this.settingsViewModel = settingsViewModel2;
this.loadChats(); this.loadChats();
} }
@@ -3236,8 +3324,8 @@
var settingsViewModel = new SettingsViewModel(settingsModel); var settingsViewModel = new SettingsViewModel(settingsModel);
var connectionViewModel = new ConnectionViewModel(connectionModel); var connectionViewModel = new ConnectionViewModel(connectionModel);
var chatListViewModel = new ChatListViewModel( var chatListViewModel = new ChatListViewModel(
chatListModel,
storageModel, storageModel,
chatListModel,
settingsViewModel settingsViewModel
); );
chatListViewModel.selectedChat.subscribe(() => { chatListViewModel.selectedChat.subscribe(() => {
+9 -3
View File
@@ -128,13 +128,13 @@ export default class BoardModel {
}; };
//tasks //tasks
createTask = (boardId: string, name: string): void => { createTask = (boardId: string): TaskFileContent => {
const taskFileContent: TaskFileContent = BoardModel.createTaskFileContent( const taskFileContent: TaskFileContent = BoardModel.createTaskFileContent(
v4(), v4(),
name, "",
boardId boardId
); );
this.updateTask(taskFileContent); return taskFileContent;
}; };
updateTask = (taskFileContent: TaskFileContent): void => { updateTask = (taskFileContent: TaskFileContent): void => {
@@ -162,6 +162,12 @@ export default class BoardModel {
return fileIds; return fileIds;
}; };
getTaskFileContent = (taskId: string): TaskFileContent | null => {
const taskFileContentOrNull: TaskFileContent | null =
this.fileModel.getLatestFileContent(taskId, TaskFileContentReference);
return taskFileContentOrNull;
};
deleteTask = (boardId: string, taskId: string): void => { deleteTask = (boardId: string, taskId: string): void => {
const taskFilePath: string[] = this.getTaskFilePath(taskId); const taskFilePath: string[] = this.getTaskFilePath(taskId);
const taskReferencePath: string[] = this.getTaskReferencePath( const taskReferencePath: string[] = this.getTaskReferencePath(
+5 -4
View File
@@ -3,13 +3,14 @@ import * as React from "bloatless-react";
import ChatListModel from "../../Model/Chat/chatListModel"; import ChatListModel from "../../Model/Chat/chatListModel";
import ChatModel from "../../Model/Chat/chatModel"; import ChatModel from "../../Model/Chat/chatModel";
import ChatViewModel from "./chatViewModel"; import ChatViewModel from "./chatViewModel";
import FileModel from "../../Model/Files/fileModel";
import { IndexManager } from "../../Model/Utility/utility"; import { IndexManager } from "../../Model/Utility/utility";
import SettingsViewModel from "../Global/settingsViewModel"; import SettingsViewModel from "../Global/settingsViewModel";
import StorageModel from "../../Model/Global/storageModel"; import StorageModel from "../../Model/Global/storageModel";
export default class ChatListViewModel { export default class ChatListViewModel {
chatListModel: ChatListModel;
storageModel: StorageModel; storageModel: StorageModel;
chatListModel: ChatListModel;
settingsViewModel: SettingsViewModel; settingsViewModel: SettingsViewModel;
// data // data
@@ -55,8 +56,8 @@ export default class ChatListViewModel {
createChatViewModel = (chatModel: ChatModel): ChatViewModel => { createChatViewModel = (chatModel: ChatModel): ChatViewModel => {
return new ChatViewModel( return new ChatViewModel(
chatModel,
this.storageModel, this.storageModel,
chatModel,
this.settingsViewModel, this.settingsViewModel,
this this
); );
@@ -90,12 +91,12 @@ export default class ChatListViewModel {
// init // init
constructor( constructor(
chatListModel: ChatListModel,
storageModel: StorageModel, storageModel: StorageModel,
chatListModel: ChatListModel,
settingsViewModel: SettingsViewModel settingsViewModel: SettingsViewModel
) { ) {
this.chatListModel = chatListModel;
this.storageModel = storageModel; this.storageModel = storageModel;
this.chatListModel = chatListModel;
this.settingsViewModel = settingsViewModel; this.settingsViewModel = settingsViewModel;
this.loadChats(); this.loadChats();
+3 -3
View File
@@ -77,21 +77,21 @@ export default class ChatViewModel {
// init // init
constructor( constructor(
chatModel: ChatModel,
storageModel: StorageModel, storageModel: StorageModel,
chatModel: ChatModel,
settingsViewModel: SettingsViewModel, settingsViewModel: SettingsViewModel,
chatListViewModel: ChatListViewModel chatListViewModel: ChatListViewModel
) { ) {
// models // models
this.chatModel = chatModel;
this.storageModel = storageModel; this.storageModel = storageModel;
this.chatModel = chatModel;
this.settingsViewModel = settingsViewModel; this.settingsViewModel = settingsViewModel;
this.chatListViewModel = chatListViewModel; this.chatListViewModel = chatListViewModel;
// page viewModels // page viewModels
this.taskPageViewModel = new TaskPageViewModel( this.taskPageViewModel = new TaskPageViewModel(
this.chatModel.fileModel.taskModel,
this.storageModel, this.storageModel,
this.chatModel.fileModel.taskModel,
this this
); );
this.messagePageViewModel = new MessagePageViewModel(this); this.messagePageViewModel = new MessagePageViewModel(this);
+40 -3
View File
@@ -2,12 +2,15 @@ import * as React from "bloatless-react";
import BoardModel, { import BoardModel, {
BoardInfoFileContent, BoardInfoFileContent,
BoardInfoFileContentReference, TaskFileContent,
TaskFileContentReference,
} from "../../Model/Files/boardModel"; } from "../../Model/Files/boardModel";
import { Color } from "../../colors"; import { Color } from "../../colors";
import FileModel from "../../Model/Files/fileModel";
import StorageModel from "../../Model/Global/storageModel"; import StorageModel from "../../Model/Global/storageModel";
import TaskPageViewModel from "./taskPageViewModel"; import TaskPageViewModel from "./taskPageViewModel";
import TaskViewModel from "./taskViewModel";
export default class BoardViewModel { export default class BoardViewModel {
storageModel: StorageModel; storageModel: StorageModel;
@@ -33,6 +36,8 @@ export default class BoardViewModel {
index: React.State<number> = new React.State(0); index: React.State<number> = new React.State(0);
taskViewModels: React.MapState<TaskViewModel> = new React.MapState();
// paths // paths
getBasePath = (): string[] => { getBasePath = (): string[] => {
return [...this.taskPageViewModel.getBoardViewPath(this.boardInfo.fileId)]; return [...this.taskPageViewModel.getBoardViewPath(this.boardInfo.fileId)];
@@ -82,7 +87,7 @@ export default class BoardViewModel {
this.index.value = index; this.index.value = index;
}; };
// methods // settings
saveSettings = (): void => { saveSettings = (): void => {
const newBoardInfoFileContent: BoardInfoFileContent = const newBoardInfoFileContent: BoardInfoFileContent =
BoardModel.createBoardInfoFileContent( BoardModel.createBoardInfoFileContent(
@@ -102,7 +107,18 @@ export default class BoardViewModel {
this.close(); this.close();
}; };
// store // tasks
createTask = (): TaskViewModel => {
const taskFileContent: TaskFileContent = this.boardModel.createTask(this.boardInfo.fileId);
const taskViewModel: TaskViewModel = new TaskViewModel(this.boardModel, this, taskFileContent);
return taskViewModel;
}
trackTask = (taskViewModel: TaskViewModel): void => {
this.taskViewModels.set(taskViewModel.task.fileId, taskViewModel);
}
// storage
storeLastUsedView = (): void => { storeLastUsedView = (): void => {
const path: string[] = this.getLastUsedBoardPath(); const path: string[] = this.getLastUsedBoardPath();
const lastUsedView: string = this.selectedPage.value; const lastUsedView: string = this.selectedPage.value;
@@ -123,8 +139,29 @@ export default class BoardViewModel {
this.color.value = this.boardInfo.color; this.color.value = this.boardInfo.color;
}; };
loadTasks = (): void => {
this.taskViewModels.clear();
const taskIds: string[] = this.boardModel.listTaskIds(
this.boardInfo.fileId
);
for (const taskId of taskIds) {
const taskFileContent: TaskFileContent | null =
this.boardModel.getTaskFileContent(taskId);
if (taskFileContent == null) continue;
const taskViewModel: TaskViewModel = new TaskViewModel(
this.boardModel,
this,
taskFileContent
);
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
}
};
loadData = (): void => { loadData = (): void => {
this.restoreLastUsedView(); this.restoreLastUsedView();
this.loadTasks();
}; };
// init // init
+3 -3
View File
@@ -4,10 +4,10 @@ import BoardModel, {
BoardInfoFileContent, BoardInfoFileContent,
BoardInfoFileContentReference, BoardInfoFileContentReference,
} from "../../Model/Files/boardModel"; } from "../../Model/Files/boardModel";
import FileModel, { FileContent } from "../../Model/Files/fileModel";
import BoardViewModel from "./boardViewModel"; import BoardViewModel from "./boardViewModel";
import ChatViewModel from "../Chat/chatViewModel"; import ChatViewModel from "../Chat/chatViewModel";
import { FileContent } from "../../Model/Files/fileModel";
import { IndexManager } from "../../Model/Utility/utility"; import { IndexManager } from "../../Model/Utility/utility";
import StorageModel from "../../Model/Global/storageModel"; import StorageModel from "../../Model/Global/storageModel";
import { checkMatchesObjectStructure } from "../../Model/Utility/typeSafety"; import { checkMatchesObjectStructure } from "../../Model/Utility/typeSafety";
@@ -154,12 +154,12 @@ export default class TaskPageViewModel {
// init // init
constructor( constructor(
boardModel: BoardModel,
storageModel: StorageModel, storageModel: StorageModel,
boardModel: BoardModel,
chatViewModel: ChatViewModel chatViewModel: ChatViewModel
) { ) {
this.boardModel = boardModel;
this.storageModel = storageModel; this.storageModel = storageModel;
this.boardModel = boardModel;
this.chatViewModel = chatViewModel; this.chatViewModel = chatViewModel;
+13 -21
View File
@@ -6,20 +6,18 @@ import BoardModel, {
} from "../../Model/Files/boardModel"; } from "../../Model/Files/boardModel";
import BoardViewModel from "./boardViewModel"; import BoardViewModel from "./boardViewModel";
import StorageModel from "../../Model/Global/storageModel";
export default class TaskViewModel { export default class TaskViewModel {
boardModel: BoardModel; boardModel: BoardModel;
storageModel: StorageModel;
boardViewModel: BoardViewModel; boardViewModel: BoardViewModel;
// data // data
fileId: string; task: TaskFileContent;
// paths // paths
getFilePath = (): string[] => { getFilePath = (): string[] => {
return this.boardModel.getTaskFilePath(this.fileId); return this.boardModel.getTaskFilePath(this.task.fileId);
}; };
// state // state
@@ -38,7 +36,7 @@ export default class TaskViewModel {
save = (): void => { save = (): void => {
const newTaskFileContent: TaskFileContent = const newTaskFileContent: TaskFileContent =
BoardModel.createTaskFileContent( BoardModel.createTaskFileContent(
this.fileId, this.task.fileId,
this.name.value, this.name.value,
this.boardViewModel.boardInfo.fileId this.boardViewModel.boardInfo.fileId
); );
@@ -51,39 +49,33 @@ export default class TaskViewModel {
newTaskFileContent.time = this.time.value; newTaskFileContent.time = this.time.value;
this.boardModel.updateTask(newTaskFileContent); this.boardModel.updateTask(newTaskFileContent);
this.boardViewModel.trackTask(this);
}; };
// load // load
loadAllData = (): void => { loadAllData = (): void => {
const path: string[] = this.getFilePath(); this.name.value = this.task.name;
const taskFileContent: TaskFileContent | null =
this.storageModel.readStringifiable(path, TaskFileContentReference);
if (taskFileContent == null) return;
this.name.value = taskFileContent.name; this.category.value = this.task.category ?? "";
this.status.value = this.task.status ?? "";
this.category.value = taskFileContent.category ?? ""; this.description.value = this.task.description ?? "";
this.status.value = taskFileContent.status ?? "";
this.description.value = taskFileContent.description ?? ""; this.priority.value = this.task.priority ?? "";
this.date.value = this.task.date ?? "";
this.priority.value = taskFileContent.priority ?? ""; this.time.value = this.task.time ?? "";
this.date.value = taskFileContent.date ?? "";
this.time.value = taskFileContent.time ?? "";
}; };
// init // init
constructor( constructor(
boardModel: BoardModel, boardModel: BoardModel,
storageModel: StorageModel,
boardViewModel: BoardViewModel, boardViewModel: BoardViewModel,
fileId: string taskFileContent: TaskFileContent
) { ) {
this.boardModel = boardModel; this.boardModel = boardModel;
this.storageModel = storageModel;
this.boardViewModel = boardViewModel; this.boardViewModel = boardViewModel;
this.fileId = fileId; this.task = taskFileContent;
this.loadAllData(); this.loadAllData();
} }
+1 -1
View File
@@ -32,8 +32,8 @@ const storageViewModel = new StorageViewModel(storageModel);
const settingsViewModel = new SettingsViewModel(settingsModel); const settingsViewModel = new SettingsViewModel(settingsModel);
const connectionViewModel = new ConnectionViewModel(connectionModel); const connectionViewModel = new ConnectionViewModel(connectionModel);
const chatListViewModel = new ChatListViewModel( const chatListViewModel = new ChatListViewModel(
chatListModel,
storageModel, storageModel,
chatListModel,
settingsViewModel settingsViewModel
); );