Skip to content

Commit

Permalink
chore: select version by default in projectselect
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Song <[email protected]>
  • Loading branch information
ferothefox committed Oct 17, 2024
1 parent d384cf9 commit 0da1247
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions apps/frontend/src/components/ui/servers/ProjectSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
<div v-if="expandedMods[mod.project_id]" class="mt-2 flex items-center gap-2">
<DropdownSelect
id="version-select"
v-model="selectedVersion"
v-model="selectedVersions[mod.project_id]"
name="version-select"
:options="expandedMods[mod.project_id].versions"
placeholder="Select version..."
/>
<Button icon-only @click="emits('select', mod, selectedVersion)">
<Button icon-only @click="emits('select', mod, selectedVersions[mod.project_id])">
<ChevronRightIcon />
</Button>
</div>
Expand Down Expand Up @@ -127,7 +127,7 @@ const getVersions = async (projectId: string) => {
return versions[projectId];
};
const selectedVersion = ref("");
const selectedVersions = reactive<{ [key: string]: string }>({});
const expandedMods = reactive<{ [key: string]: { expanded: boolean; versions: any[] } }>({});
Expand All @@ -138,8 +138,11 @@ const toggleMod = async (modId: string) => {
expandedMods[modId].expanded = !expandedMods[modId].expanded;
if (expandedMods[modId].expanded && expandedMods[modId].versions.length === 0) {
expandedMods[modId].versions = await getVersions(modId);
// Select the first version by default
if (expandedMods[modId].versions.length > 0) {
selectedVersions[modId] = expandedMods[modId].versions[0];
}
}
selectedVersion.value = "";
};
const loadMore = async () => {
Expand All @@ -159,8 +162,8 @@ const { reset } = useInfiniteScroll(scrollContainer, async () => {
const resetList = () => {
mods.value.hits = [];
Object.keys(expandedMods).forEach((key) => delete expandedMods[key]);
Object.keys(selectedVersions).forEach((key) => delete selectedVersions[key]);
page.value = 0;
selectedVersion.value = "";
loadMods();
reset();
};
Expand Down

0 comments on commit 0da1247

Please sign in to comment.