From d35f2ff0ea2d1113e0b88681c41c29003f804582 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Tue, 23 Jul 2024 00:32:29 +0200 Subject: [PATCH] dynamically add boards to view --- dist/index.js | 9 +++++---- src/Model/Files/taskModel.ts | 7 ++++--- src/ViewModel/Pages/taskPageViewModel.ts | 5 +++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6628a3d4..fb00156d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -571,6 +571,7 @@ createBoard = (name) => { const boardInfoFileContent = _TaskModel.createBoardInfoFileContent(v4_default(), name, "standard" /* Standard */); this.updateBoard(boardInfoFileContent); + return boardInfoFileContent; }; updateBoard = (boardInfoFileContent) => { this.storeBoard(boardInfoFileContent); @@ -591,8 +592,8 @@ }; listBoardIds = () => { const boardContainerPath = this.getBoardContainerPath(); - const boardNames = this.storageModel.list(boardContainerPath); - return boardNames; + const boardIds = this.storageModel.list(boardContainerPath); + return boardIds; }; getBoardInfo = (fileId) => { const boardInfoFileContentOrNull = this.fileModel.getLatestFileContent( @@ -1409,9 +1410,9 @@ // methods createBoard = () => { if (this.cannotCreateBoard.value == true) return; - this.taskModel.createBoard(this.newBoardNameInput.value); + const boardInfoFileContent = this.taskModel.createBoard(this.newBoardNameInput.value); this.newBoardNameInput.value = ""; - this.loadData(); + this.boards.add(boardInfoFileContent); }; // view showBoard = (boardInfo) => { diff --git a/src/Model/Files/taskModel.ts b/src/Model/Files/taskModel.ts index 5d2b463b..c180da9c 100644 --- a/src/Model/Files/taskModel.ts +++ b/src/Model/Files/taskModel.ts @@ -68,10 +68,11 @@ export default class TaskModel { }; // boards - createBoard = (name: string): void => { + createBoard = (name: string): BoardInfoFileContent => { const boardInfoFileContent: BoardInfoFileContent = TaskModel.createBoardInfoFileContent(v4(), name, Color.Standard); this.updateBoard(boardInfoFileContent); + return boardInfoFileContent; }; updateBoard = (boardInfoFileContent: BoardInfoFileContent): void => { @@ -100,8 +101,8 @@ export default class TaskModel { listBoardIds = (): string[] => { const boardContainerPath: string[] = this.getBoardContainerPath(); - const boardNames: string[] = this.storageModel.list(boardContainerPath); - return boardNames; + const boardIds: string[] = this.storageModel.list(boardContainerPath); + return boardIds; }; getBoardInfo = (fileId: string): BoardInfoFileContent | null => { diff --git a/src/ViewModel/Pages/taskPageViewModel.ts b/src/ViewModel/Pages/taskPageViewModel.ts index 901e5b06..977cbaee 100644 --- a/src/ViewModel/Pages/taskPageViewModel.ts +++ b/src/ViewModel/Pages/taskPageViewModel.ts @@ -37,10 +37,11 @@ export default class TaskPageViewModel { createBoard = (): void => { if (this.cannotCreateBoard.value == true) return; - this.taskModel.createBoard(this.newBoardNameInput.value); + const boardInfoFileContent: BoardInfoFileContent = + this.taskModel.createBoard(this.newBoardNameInput.value); this.newBoardNameInput.value = ""; - this.loadData(); + this.boards.add(boardInfoFileContent); }; // view