-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/ntnui-darts/dartpp into main
- Loading branch information
Showing
7 changed files
with
214 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<h3>Status of {{ user.name }}</h3> | ||
<label for="beers">Beers</label> | ||
<input id="beers" type="number" v-model="beers" /> | ||
<label for="arrows">Arrows</label> | ||
<input id="arrows" type="text" v-model="arrows" /> | ||
<br /> | ||
<div class="row"> | ||
<button @click="emit('cancel')">Cancel</button> | ||
<button @click="emit('submit', { beers, arrows })">Confirm</button> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { User } from '@/stores/users' | ||
import { ref } from 'vue' | ||
const beers = ref(0) | ||
const arrows = ref('unknown') | ||
defineProps<{ | ||
user: User | ||
}>() | ||
const emit = defineEmits<{ | ||
cancel: [] | ||
submit: [data: { beers: number; arrows: string }] | ||
}>() | ||
</script> | ||
|
||
<style> | ||
input { | ||
min-width: 250px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<template> | ||
<input | ||
type="text" | ||
ref="inputElement" | ||
v-model="searchText" | ||
placeholder="Search by name.." | ||
/> | ||
|
||
<div class="col" style="height: 400px; overflow: auto"> | ||
<button | ||
v-for="user in searchResultUsers" | ||
:key="user.id" | ||
:id="user.id" | ||
:disabled="props.selectedUsers.some((u) => u.id == user.id)" | ||
@click="select(user)" | ||
> | ||
{{ user.name }} | ||
</button> | ||
<p v-if="searchResultUsers.length == 0">No results 🤔</p> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { useModalStore } from '@/stores/modal' | ||
import { User, useUsersStore } from '@/stores/users' | ||
import { ref, computed, onMounted } from 'vue' | ||
import PlayerOptions from './PlayerOptions.vue' | ||
const props = defineProps<{ | ||
selectedUsers: User[] | ||
}>() | ||
const emit = defineEmits<{ | ||
select: [user: User] | ||
}>() | ||
const usersStore = useUsersStore() | ||
const inputElement = ref<HTMLInputElement | null>(null) | ||
const searchText = ref('') | ||
const searchResultUsers = computed(() => { | ||
return usersStore.users | ||
.filter((user) => | ||
user.name.toLowerCase().includes(searchText.value.toLowerCase()) | ||
) | ||
.slice(0, 10) | ||
}) | ||
onMounted(() => { | ||
inputElement.value?.focus() | ||
}) | ||
const select = (user: User) => { | ||
useModalStore().push( | ||
PlayerOptions, | ||
{ user }, | ||
{ | ||
cancel: () => useModalStore().pop(), | ||
submit: (data: { beers: number; arrows: string }) => { | ||
emit('select', { | ||
...user, | ||
...data, | ||
}) | ||
useModalStore().pop() | ||
}, | ||
} | ||
) | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
input { | ||
min-width: 250px; | ||
} | ||
button { | ||
flex: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<template> | ||
<h2>Select Players</h2> | ||
<div class="col" v-auto-animate> | ||
<button | ||
v-for="user in selectedUsers" | ||
:key="user.id" | ||
:id="user.id" | ||
:class="{ selected: true }" | ||
@click="toggleUser(user)" | ||
> | ||
{{ user.name }} | ||
</button> | ||
</div> | ||
<button @click="searchForPlayer">+ Add Player</button> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref, watch } from 'vue' | ||
import { User, useUsersStore } from '@/stores/users' | ||
import { useModalStore } from '@/stores/modal' | ||
import PlayerSearch from './PlayerSearch.vue' | ||
export type UserCurrentInfo = User & { | ||
arrows?: string | ||
beers?: number | ||
} | ||
const emit = defineEmits<{ | ||
update: [players: UserCurrentInfo[]] | ||
}>() | ||
const usersStore = useUsersStore() | ||
const selectedUsers = ref<UserCurrentInfo[]>([]) | ||
const searchForPlayer = () => { | ||
useModalStore().push( | ||
PlayerSearch, | ||
{ selectedUsers: selectedUsers.value }, | ||
{ | ||
select: (user) => { | ||
selectedUsers.value.push(user) | ||
useModalStore().pop() | ||
emit('update', selectedUsers.value) | ||
}, | ||
} | ||
) | ||
} | ||
const toggleUser = (user: UserCurrentInfo) => { | ||
const index = selectedUsers.value.findIndex((u) => u.id == user.id) | ||
if (index == -1) { | ||
selectedUsers.value.push(user) | ||
} else { | ||
selectedUsers.value.splice(index, 1) | ||
} | ||
emit('update', selectedUsers.value) | ||
} | ||
watch( | ||
() => usersStore.getCurrentUser, | ||
(user) => { | ||
if (user && !selectedUsers.value.find((u) => u.id == user.id)) { | ||
selectedUsers.value.push(user) | ||
emit('update', selectedUsers.value) | ||
} | ||
}, | ||
{ immediate: true } | ||
) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters