prepare opening boards

This commit is contained in:
marlon-erler
2024-07-23 02:40:11 +02:00
parent 4f0a967ac6
commit e926fa758d
4 changed files with 69 additions and 14 deletions
+27 -6
View File
@@ -1383,6 +1383,14 @@
boardInfo; boardInfo;
name = new State(""); name = new State("");
color = new State("standard" /* Standard */); color = new State("standard" /* Standard */);
isSelected;
// view
select = () => {
this.taskPageViewModel.selectBoard(this);
};
close = () => {
this.taskPageViewModel.closeBoard();
};
// load // load
loadListRelevantData = () => { loadListRelevantData = () => {
this.name.value = this.boardInfo.name; this.name.value = this.boardInfo.name;
@@ -1395,6 +1403,10 @@
this.taskPageViewModel = taskPageViewModel; this.taskPageViewModel = taskPageViewModel;
this.boardInfo = boardInfo; this.boardInfo = boardInfo;
this.loadListRelevantData(); this.loadListRelevantData();
this.isSelected = createProxyState(
[this.taskPageViewModel.selectedBoard],
() => this.taskPageViewModel.selectedBoard.value == this
);
} }
}; };
@@ -1404,6 +1416,7 @@
// state // state
newBoardNameInput = new State(""); newBoardNameInput = new State("");
boardViewModels = new MapState(); boardViewModels = new MapState();
selectedBoard = new State(void 0);
// guards // guards
cannotCreateBoard = createProxyState( cannotCreateBoard = createProxyState(
[this.newBoardNameInput], [this.newBoardNameInput],
@@ -1413,20 +1426,26 @@
handleFileContent = (fileContent) => { handleFileContent = (fileContent) => {
if (checkMatchesObjectStructure(fileContent, BoardInfoFileContentReference) == false) if (checkMatchesObjectStructure(fileContent, BoardInfoFileContentReference) == false)
return; return;
this.showBoard(fileContent); this.showBoardInList(fileContent);
}; };
// 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.taskModel.createBoard(this.newBoardNameInput.value);
this.newBoardNameInput.value = ""; this.newBoardNameInput.value = "";
this.showBoard(boardInfoFileContent); this.showBoardInList(boardInfoFileContent);
}; };
// view // view
showBoard = (boardInfo) => { showBoardInList = (boardInfo) => {
const boardViewModel = new BoardViewModel(this, boardInfo); const boardViewModel = new BoardViewModel(this, boardInfo);
this.boardViewModels.set(boardInfo.fileId, boardViewModel); this.boardViewModels.set(boardInfo.fileId, boardViewModel);
}; };
selectBoard = (boardViewModel) => {
this.selectedBoard.value = boardViewModel;
};
closeBoard = () => {
this.selectedBoard.value = void 0;
};
// load // load
loadData = () => { loadData = () => {
this.boardViewModels.clear(); this.boardViewModels.clear();
@@ -1434,7 +1453,7 @@
for (const boardId of boardIds) { for (const boardId of boardIds) {
const boardInfo = this.taskModel.getBoardInfo(boardId); const boardInfo = this.taskModel.getBoardInfo(boardId);
if (boardInfo == null) continue; if (boardInfo == null) continue;
this.showBoard(boardInfo); this.showBoardInList(boardInfo);
} }
}; };
// init // init
@@ -1442,7 +1461,7 @@
this.taskModel = taskModel; this.taskModel = taskModel;
taskModel.boardHandlerManager.addHandler( taskModel.boardHandlerManager.addHandler(
(boardInfoFileContent) => { (boardInfoFileContent) => {
this.showBoard(boardInfoFileContent); this.showBoardInList(boardInfoFileContent);
} }
); );
} }
@@ -1953,7 +1972,9 @@
"button", "button",
{ {
"set:color": boardViewModel.color, "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("span", { class: "shadow", "subscribe:innerText": boardViewModel.name }),
/* @__PURE__ */ createElement("b", { "subscribe:innerText": boardViewModel.name }) /* @__PURE__ */ createElement("b", { "subscribe:innerText": boardViewModel.name })
+3
View File
@@ -7,6 +7,9 @@ export function BoardEntry(boardViewModel: BoardViewModel) {
<button <button
set:color={boardViewModel.color} set:color={boardViewModel.color}
class="tile colored-tile" class="tile colored-tile"
toggle:selected={boardViewModel.isSelected}
on:click={boardViewModel.select}
> >
<span class="shadow" subscribe:innerText={boardViewModel.name}></span> <span class="shadow" subscribe:innerText={boardViewModel.name}></span>
<b subscribe:innerText={boardViewModel.name}></b> <b subscribe:innerText={boardViewModel.name}></b>
+22 -3
View File
@@ -13,19 +13,38 @@ export default class BoardViewModel {
name: React.State<string> = new React.State(""); name: React.State<string> = new React.State("");
color: React.State<Color> = new React.State<Color>(Color.Standard); color: React.State<Color> = new React.State<Color>(Color.Standard);
isSelected: React.State<boolean>;
// view
select = (): void => {
this.taskPageViewModel.selectBoard(this);
};
close = (): void => {
this.taskPageViewModel.closeBoard();
};
// load // load
loadListRelevantData = (): void => { loadListRelevantData = (): void => {
this.name.value = this.boardInfo.name; this.name.value = this.boardInfo.name;
this.color.value = this.boardInfo.color; this.color.value = this.boardInfo.color;
} };
loadData = (): void => {} loadData = (): void => {};
// init // init
constructor(taskPageViewModel: TaskPageViewModel, boardInfo: BoardInfoFileContent) { constructor(
taskPageViewModel: TaskPageViewModel,
boardInfo: BoardInfoFileContent
) {
this.taskPageViewModel = taskPageViewModel; this.taskPageViewModel = taskPageViewModel;
this.boardInfo = boardInfo; this.boardInfo = boardInfo;
this.loadListRelevantData(); this.loadListRelevantData();
this.isSelected = React.createProxyState(
[this.taskPageViewModel.selectedBoard],
() => this.taskPageViewModel.selectedBoard.value == this
);
} }
} }
+17 -5
View File
@@ -18,6 +18,10 @@ export default class TaskPageViewModel {
boardViewModels: React.MapState<BoardViewModel> = new React.MapState(); boardViewModels: React.MapState<BoardViewModel> = new React.MapState();
selectedBoard: React.State<BoardViewModel | undefined> = new React.State<
BoardViewModel | undefined
>(undefined);
// guards // guards
cannotCreateBoard: React.State<boolean> = React.createProxyState( cannotCreateBoard: React.State<boolean> = React.createProxyState(
[this.newBoardNameInput], [this.newBoardNameInput],
@@ -31,7 +35,7 @@ export default class TaskPageViewModel {
false false
) )
return; return;
this.showBoard(fileContent as BoardInfoFileContent); this.showBoardInList(fileContent as BoardInfoFileContent);
}; };
// methods // methods
@@ -42,15 +46,23 @@ export default class TaskPageViewModel {
this.taskModel.createBoard(this.newBoardNameInput.value); this.taskModel.createBoard(this.newBoardNameInput.value);
this.newBoardNameInput.value = ""; this.newBoardNameInput.value = "";
this.showBoard(boardInfoFileContent); this.showBoardInList(boardInfoFileContent);
}; };
// view // view
showBoard = (boardInfo: BoardInfoFileContent): void => { showBoardInList = (boardInfo: BoardInfoFileContent): void => {
const boardViewModel: BoardViewModel = new BoardViewModel(this, boardInfo); const boardViewModel: BoardViewModel = new BoardViewModel(this, boardInfo);
this.boardViewModels.set(boardInfo.fileId, boardViewModel); this.boardViewModels.set(boardInfo.fileId, boardViewModel);
}; };
selectBoard = (boardViewModel: BoardViewModel): void => {
this.selectedBoard.value = boardViewModel;
};
closeBoard = (): void => {
this.selectedBoard.value = undefined;
};
// load // load
loadData = (): void => { loadData = (): void => {
this.boardViewModels.clear(); this.boardViewModels.clear();
@@ -61,7 +73,7 @@ export default class TaskPageViewModel {
this.taskModel.getBoardInfo(boardId); this.taskModel.getBoardInfo(boardId);
if (boardInfo == null) continue; if (boardInfo == null) continue;
this.showBoard(boardInfo); this.showBoardInList(boardInfo);
} }
}; };
@@ -72,7 +84,7 @@ export default class TaskPageViewModel {
// handlers // handlers
taskModel.boardHandlerManager.addHandler( taskModel.boardHandlerManager.addHandler(
(boardInfoFileContent: BoardInfoFileContent) => { (boardInfoFileContent: BoardInfoFileContent) => {
this.showBoard(boardInfoFileContent); this.showBoardInList(boardInfoFileContent);
} }
); );
} }