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