Update of 'Excel Style' page
This commit is contained in:
parent
e3c5a9c60f
commit
65df44707b
1 changed files with 22 additions and 22 deletions
|
@ -1,47 +1,44 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import SelectedGameGroupsStore from '$lib/stores/GameGroupFilter';
|
import SelectedGameGroupsStore from '$lib/stores/GameGroupFilter';
|
||||||
import SelectedGameStore from '$lib/stores/GameFilter';
|
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 ChellarisDataStore from '$lib/stores/ChellarisData';
|
||||||
|
import GraphsTabStore from '$lib/stores/GraphsTab';
|
||||||
|
|
||||||
let selectedGameGroups: Array<string> = [];
|
let selectedGameGroups: Array<string> = [];
|
||||||
let selectedGameGroupsMap: Map<string, Array<string>> = new Map();
|
let selectedGameGroupsMap: Map<string, Array<string>> = new Map();
|
||||||
let gameGroups: Map<string, ChellarisGameGroup> = new Map();
|
let gameGroups: Map<string, ChellarisGameGroup> = new Map();
|
||||||
let chellarisData: ChellarisInfo = {
|
let chellarisData = createChellarisInfo();
|
||||||
games: new Map(),
|
let selectedGame = '';
|
||||||
ethics: [],
|
|
||||||
portraits: []
|
// Save Tab to Store
|
||||||
};
|
GraphsTabStore.update(() => 'tab');
|
||||||
let selectedGame: string = "";
|
|
||||||
|
|
||||||
const updateGameGroups = () => {
|
const updateGameGroups = () => {
|
||||||
let tmpData;
|
let tmpData;
|
||||||
if (selectedGame == "") {
|
if (selectedGame == '') {
|
||||||
tmpData = chellarisData.games.get(chellarisData.games.keys().next().value);
|
tmpData = chellarisData.games.get(chellarisData.games.keys().next().value);
|
||||||
}
|
} else {
|
||||||
else {
|
tmpData = chellarisData.games.get(selectedGame);
|
||||||
tmpData = chellarisData.games.get(selectedGame);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof tmpData !== 'undefined') {
|
if (typeof tmpData !== 'undefined') {
|
||||||
console.log(tmpData.groups);
|
|
||||||
gameGroups = tmpData.groups;
|
gameGroups = tmpData.groups;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ChellarisDataStore.subscribe((data) => {
|
ChellarisDataStore.subscribe((data) => {
|
||||||
chellarisData = data;
|
chellarisData = data;
|
||||||
|
|
||||||
updateGameGroups();
|
updateGameGroups();
|
||||||
// TODO Update selection if Groups Differ? Does this value ever even update without a full page reload?
|
// TODO Update selection if Groups Differ? Does this value ever even update without a full page reload?
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
SelectedGameStore.subscribe((selection) => {
|
SelectedGameStore.subscribe((selection) => {
|
||||||
selectedGame = selection;
|
selectedGame = selection;
|
||||||
if (selectedGameGroupsMap.size != 0) {
|
if (selectedGameGroupsMap.size != 0) {
|
||||||
const tmp = selectedGameGroupsMap.get(selectedGame);
|
const tmp = selectedGameGroupsMap.get(selectedGame);
|
||||||
if (typeof tmp !== "undefined") {
|
if (typeof tmp !== 'undefined') {
|
||||||
selectedGameGroups = [...tmp.values()];
|
selectedGameGroups = [...tmp.values()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +51,6 @@
|
||||||
selectedGameGroups = [...tmp.values()];
|
selectedGameGroups = [...tmp.values()];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
@ -64,4 +60,8 @@
|
||||||
|
|
||||||
<h1>Example Tab</h1>
|
<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>
|
||||||
|
|
Reference in a new issue