Update of 'Excel Style' page

This commit is contained in:
Neshura 2023-08-14 20:18:53 +02:00
parent e3c5a9c60f
commit 65df44707b
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -1,30 +1,28 @@
<script lang="ts">
import SelectedGameGroupsStore from '$lib/stores/GameGroupFilter';
import SelectedGameStore from '$lib/stores/GameFilter';
import type { ChellarisGameGroup, ChellarisInfo } from '$lib/types/chellaris';
import { createChellarisInfo, type ChellarisGameGroup, type ChellarisInfo } from '$lib/types/chellaris';
import ChellarisDataStore from '$lib/stores/ChellarisData';
import GraphsTabStore from '$lib/stores/GraphsTab';
let selectedGameGroups: Array<string> = [];
let selectedGameGroupsMap: Map<string, Array<string>> = new Map();
let gameGroups: Map<string, ChellarisGameGroup> = new Map();
let chellarisData: ChellarisInfo = {
games: new Map(),
ethics: [],
portraits: []
};
let selectedGame: string = "";
let chellarisData = createChellarisInfo();
let selectedGame = '';
// Save Tab to Store
GraphsTabStore.update(() => 'tab');
const updateGameGroups = () => {
let tmpData;
if (selectedGame == "") {
if (selectedGame == '') {
tmpData = chellarisData.games.get(chellarisData.games.keys().next().value);
}
else {
} else {
tmpData = chellarisData.games.get(selectedGame);
}
if (typeof tmpData !== 'undefined') {
console.log(tmpData.groups);
gameGroups = tmpData.groups;
}
};
@ -36,12 +34,11 @@
// TODO Update selection if Groups Differ? Does this value ever even update without a full page reload?
});
SelectedGameStore.subscribe((selection) => {
selectedGame = selection;
if (selectedGameGroupsMap.size != 0) {
const tmp = selectedGameGroupsMap.get(selectedGame);
if (typeof tmp !== "undefined") {
if (typeof tmp !== 'undefined') {
selectedGameGroups = [...tmp.values()];
}
}
@ -54,7 +51,6 @@
selectedGameGroups = [...tmp.values()];
}
});
</script>
<svelte:head>
@ -64,4 +60,8 @@
<h1>Example Tab</h1>
<p>{selectedGameGroups.length > 1 ? "Groups" : "Group"} {selectedGameGroups.map((selection) => gameGroups.get(selection)?.name).join(", ")} {selectedGameGroups.length > 1 ? "are" : "is"} selected</p>
<p>
{selectedGameGroups.length > 1 ? 'Groups' : 'Group'}
{selectedGameGroups.map((selection) => gameGroups.get(selection)?.name).join(', ')}
{selectedGameGroups.length > 1 ? 'are' : 'is'} selected
</p>