From e926fa758d1f1f0b8b0c96fb75982b00ee5b2c9c Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Tue, 23 Jul 2024 02:40:11 +0200 Subject: [PATCH] prepare opening boards --- dist/index.js | 33 +++++++++++++++++++----- src/View/Components/boardEntry.tsx | 3 +++ src/ViewModel/Pages/boardViewModel.ts | 25 +++++++++++++++--- src/ViewModel/Pages/taskPageViewModel.ts | 22 ++++++++++++---- 4 files changed, 69 insertions(+), 14 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1c1c3eb9..be1009c2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1383,6 +1383,14 @@ boardInfo; name = new State(""); color = new State("standard" /* Standard */); + isSelected; + // view + select = () => { + this.taskPageViewModel.selectBoard(this); + }; + close = () => { + this.taskPageViewModel.closeBoard(); + }; // load loadListRelevantData = () => { this.name.value = this.boardInfo.name; @@ -1395,6 +1403,10 @@ this.taskPageViewModel = taskPageViewModel; this.boardInfo = boardInfo; this.loadListRelevantData(); + this.isSelected = createProxyState( + [this.taskPageViewModel.selectedBoard], + () => this.taskPageViewModel.selectedBoard.value == this + ); } }; @@ -1404,6 +1416,7 @@ // state newBoardNameInput = new State(""); boardViewModels = new MapState(); + selectedBoard = new State(void 0); // guards cannotCreateBoard = createProxyState( [this.newBoardNameInput], @@ -1413,20 +1426,26 @@ handleFileContent = (fileContent) => { if (checkMatchesObjectStructure(fileContent, BoardInfoFileContentReference) == false) return; - this.showBoard(fileContent); + this.showBoardInList(fileContent); }; // methods createBoard = () => { if (this.cannotCreateBoard.value == true) return; const boardInfoFileContent = this.taskModel.createBoard(this.newBoardNameInput.value); this.newBoardNameInput.value = ""; - this.showBoard(boardInfoFileContent); + this.showBoardInList(boardInfoFileContent); }; // view - showBoard = (boardInfo) => { + showBoardInList = (boardInfo) => { const boardViewModel = new BoardViewModel(this, boardInfo); this.boardViewModels.set(boardInfo.fileId, boardViewModel); }; + selectBoard = (boardViewModel) => { + this.selectedBoard.value = boardViewModel; + }; + closeBoard = () => { + this.selectedBoard.value = void 0; + }; // load loadData = () => { this.boardViewModels.clear(); @@ -1434,7 +1453,7 @@ for (const boardId of boardIds) { const boardInfo = this.taskModel.getBoardInfo(boardId); if (boardInfo == null) continue; - this.showBoard(boardInfo); + this.showBoardInList(boardInfo); } }; // init @@ -1442,7 +1461,7 @@ this.taskModel = taskModel; taskModel.boardHandlerManager.addHandler( (boardInfoFileContent) => { - this.showBoard(boardInfoFileContent); + this.showBoardInList(boardInfoFileContent); } ); } @@ -1953,7 +1972,9 @@ "button", { "set:color": boardViewModel.color, - class: "tile colored-tile" + class: "tile colored-tile", + "toggle:selected": boardViewModel.isSelected, + "on:click": boardViewModel.select }, /* @__PURE__ */ createElement("span", { class: "shadow", "subscribe:innerText": boardViewModel.name }), /* @__PURE__ */ createElement("b", { "subscribe:innerText": boardViewModel.name }) diff --git a/src/View/Components/boardEntry.tsx b/src/View/Components/boardEntry.tsx index 723fa7a3..ff36f8a2 100644 --- a/src/View/Components/boardEntry.tsx +++ b/src/View/Components/boardEntry.tsx @@ -7,6 +7,9 @@ export function BoardEntry(boardViewModel: BoardViewModel) {