implement updating task list

This commit is contained in:
marlon-erler
2024-07-24 13:40:17 +02:00
parent 20b27d1a57
commit b1f28cd5ad
4 changed files with 59 additions and 11 deletions
+25 -5
View File
@@ -572,6 +572,7 @@
fileModel;
// data
boardHandlerManager = new HandlerManager();
taskHandlerManager = new HandlerManager();
// paths
getBasePath = () => {
return this.fileModel.getModelContainerPath("tasks" /* ModelTask */);
@@ -612,7 +613,7 @@
this.updateBoard(boardInfoFileContent);
};
handleTask = (taskFileContent) => {
this.storeTask(taskFileContent);
this.updateTask(taskFileContent);
};
// boards
createBoard = (name) => {
@@ -623,6 +624,10 @@
this.storeBoard(boardInfoFileContent);
this.boardHandlerManager.trigger(boardInfoFileContent);
};
updateBoardAndSend = (boardInfoFileContent) => {
this.updateBoard(boardInfoFileContent);
this.chatModel.sendMessage("", boardInfoFileContent);
};
storeBoard = (boardInfoFileContent) => {
this.fileModel.storeFileContent(boardInfoFileContent);
const boardDirectoryPath = this.getBoardDirectoryPath(
@@ -630,9 +635,6 @@
);
this.storageModel.write(boardDirectoryPath, "");
};
updateBoardAndSend = (boardInfoFileContent) => {
this.chatModel.sendMessage("", boardInfoFileContent);
};
deleteBoard = (boardId) => {
const boardFilePath = this.getBoardFilePath(boardId);
const boardDirectoryPath = this.getBoardDirectoryPath(boardId);
@@ -662,6 +664,11 @@
};
updateTask = (taskFileContent) => {
this.storeTask(taskFileContent);
this.taskHandlerManager.trigger(taskFileContent);
};
updateTaskAndSend = (taskFileContent) => {
this.updateTask(taskFileContent);
this.chatModel.sendMessage("", taskFileContent);
};
storeTask = (taskFileContent) => {
this.fileModel.storeFileContent(taskFileContent);
@@ -1469,7 +1476,7 @@
newTaskFileContent.priority = this.priority.value;
newTaskFileContent.date = this.date.value;
newTaskFileContent.time = this.time.value;
this.boardModel.updateTask(newTaskFileContent);
this.boardModel.updateTaskAndSend(newTaskFileContent);
this.boardViewModel.trackTask(this);
};
// load
@@ -1561,6 +1568,14 @@
this.selectedPage.value = lastUsedView;
};
// view
showTaskInList = (taskFileContent) => {
const taskViewModel = new TaskViewModel(
this.boardModel,
this,
taskFileContent
);
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
};
select = () => {
this.taskPageViewModel.selectBoard(this);
};
@@ -1633,6 +1648,11 @@
this.selectedPage.subscribeSilent(() => {
this.storeLastUsedView();
});
boardModel.taskHandlerManager.addHandler(
(taskFileContent) => {
this.showTaskInList(taskFileContent);
}
);
}
};
+13 -5
View File
@@ -20,6 +20,7 @@ export default class BoardModel {
// data
boardHandlerManager: HandlerManager<BoardInfoFileContent> =
new HandlerManager();
taskHandlerManager: HandlerManager<TaskFileContent> = new HandlerManager();
// paths
getBasePath = (): string[] => {
@@ -76,7 +77,7 @@ export default class BoardModel {
};
handleTask = (taskFileContent: TaskFileContent) => {
this.storeTask(taskFileContent);
this.updateTask(taskFileContent);
};
// boards
@@ -91,6 +92,11 @@ export default class BoardModel {
this.boardHandlerManager.trigger(boardInfoFileContent);
};
updateBoardAndSend = (boardInfoFileContent: BoardInfoFileContent): void => {
this.updateBoard(boardInfoFileContent);
this.chatModel.sendMessage("", boardInfoFileContent);
};
storeBoard = (boardInfoFileContent: BoardInfoFileContent): void => {
// store info
this.fileModel.storeFileContent(boardInfoFileContent);
@@ -102,10 +108,6 @@ export default class BoardModel {
this.storageModel.write(boardDirectoryPath, "");
};
updateBoardAndSend = (boardInfoFileContent: BoardInfoFileContent): void => {
this.chatModel.sendMessage("", boardInfoFileContent);
};
deleteBoard = (boardId: string): void => {
const boardFilePath: string[] = this.getBoardFilePath(boardId);
const boardDirectoryPath: string[] = this.getBoardDirectoryPath(boardId);
@@ -141,6 +143,12 @@ export default class BoardModel {
updateTask = (taskFileContent: TaskFileContent): void => {
this.storeTask(taskFileContent);
this.taskHandlerManager.trigger(taskFileContent);
};
updateTaskAndSend = (taskFileContent: TaskFileContent): void => {
this.updateTask(taskFileContent);
this.chatModel.sendMessage("", taskFileContent);
};
storeTask = (taskFileContent: TaskFileContent): void => {
+20
View File
@@ -99,6 +99,15 @@ export default class BoardViewModel {
};
// view
showTaskInList = (taskFileContent: TaskFileContent): void => {
const taskViewModel: TaskViewModel = new TaskViewModel(
this.boardModel,
this,
taskFileContent
);
this.taskViewModels.set(taskFileContent.fileId, taskViewModel);
};
select = (): void => {
this.taskPageViewModel.selectBoard(this);
};
@@ -176,13 +185,16 @@ export default class BoardViewModel {
taskPageViewModel: TaskPageViewModel,
boardInfo: BoardInfoFileContent
) {
// set
this.storageModel = storageModel;
this.boardModel = boardModel;
this.taskPageViewModel = taskPageViewModel;
this.boardInfo = boardInfo;
// load
this.loadListRelevantData();
// subscriptions
this.isSelected = React.createProxyState(
[this.taskPageViewModel.selectedBoardId],
() =>
@@ -193,9 +205,17 @@ export default class BoardViewModel {
if (this.isSelected.value == false) return;
this.applyColor();
});
this.selectedPage.subscribeSilent(() => {
this.storeLastUsedView();
});
// handlers
boardModel.taskHandlerManager.addHandler(
(taskFileContent: TaskFileContent) => {
this.showTaskInList(taskFileContent);
}
);
}
}
+1 -1
View File
@@ -59,7 +59,7 @@ export default class TaskViewModel {
newTaskFileContent.date = this.date.value;
newTaskFileContent.time = this.time.value;
this.boardModel.updateTask(newTaskFileContent);
this.boardModel.updateTaskAndSend(newTaskFileContent);
this.boardViewModel.trackTask(this);
};