Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add use event composable #90

Merged
merged 47 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b465174
worked on adding coaches-page
Ryan-Bauroth Feb 2, 2024
ae35932
removed unused const and fixed issue with session roles not being acc…
Ryan-Bauroth Feb 3, 2024
f7e11f9
uninstalled heic2any
Ryan-Bauroth Feb 3, 2024
0916ca7
added back heic2any i was being goofy
Ryan-Bauroth Feb 3, 2024
33a34fc
made significant changes to OuterComponents.vue and Navbar.vue to rem…
Ryan-Bauroth Feb 3, 2024
4dde9bb
made significant changes to OuterComponents.vue and Navbar.vue to rem…
Ryan-Bauroth Feb 3, 2024
cae2225
Merge remote-tracking branch 'origin/outcomponents-changes' into outc…
Ryan-Bauroth Feb 3, 2024
50260fe
quick fix
Ryan-Bauroth Feb 3, 2024
cb779d7
changed style to css
Ryan-Bauroth Feb 3, 2024
0033b61
created auto flex divs for each alliance
Ryan-Bauroth Feb 3, 2024
d79ba53
created auto flex divs for each alliance
Ryan-Bauroth Feb 3, 2024
e82c5f6
Merge remote-tracking branch 'origin/coaches-page' into coaches-page
Ryan-Bauroth Feb 3, 2024
384324c
updated stuff to use useState instead of ref. reformatted OuterCompon…
Ryan-Bauroth Feb 4, 2024
e464bb3
Merge pull request #81 from DurhamAcademy/outcomponents-changes
Ryan-Bauroth Feb 4, 2024
aef417c
Merge branch 'coaches-page' into dev
Ryan-Bauroth Feb 4, 2024
7369491
removed coach page from dev for the time being
Ryan-Bauroth Feb 4, 2024
5709a35
added some notes and redid how tabs were made (v-for)
Ryan-Bauroth Feb 6, 2024
df0d085
added more comments
Ryan-Bauroth Feb 6, 2024
4f328a1
put teams in a card and allowed sortable on columns
Ryan-Bauroth Feb 6, 2024
17ef5d5
saving so someone doesn't delete my code
Ryan-Bauroth Feb 7, 2024
028311b
created a filters custom component. used this component on the teams …
Ryan-Bauroth Feb 7, 2024
dee87a5
edited searchplaceholder
Ryan-Bauroth Feb 7, 2024
74ba0d8
applied team # filter to teams table
Ryan-Bauroth Feb 7, 2024
6ad36d0
deleted coach preview
Ryan-Bauroth Feb 7, 2024
5be7ed9
quick fix to navbar
Ryan-Bauroth Feb 7, 2024
3428651
added code to remove custom filters when unselected
Ryan-Bauroth Feb 7, 2024
ecfa335
added some resizing stuff
Ryan-Bauroth Feb 7, 2024
6cc58c1
removed pages from teams page (felt mid)
Ryan-Bauroth Feb 8, 2024
7512429
changed auto.leave to auto.mobility. added two new filters
Ryan-Bauroth Feb 8, 2024
bdcbe56
added a comment to FilterMultiSelect.vue
Ryan-Bauroth Feb 8, 2024
522129e
added useEvent composable
a1cd Feb 8, 2024
2b9413f
changed useEvent to useSelectedEvent
a1cd Feb 8, 2024
fae3914
haha get screwed everett i caught a bug
Ryan-Bauroth Feb 8, 2024
9f0775e
did some stuff idk
Ryan-Bauroth Feb 11, 2024
29c2bbf
in progress
Ryan-Bauroth Feb 11, 2024
48f936b
still bugs with custom filters
Ryan-Bauroth Feb 11, 2024
06977d6
fixed custom filters jankily
Ryan-Bauroth Feb 13, 2024
8b7a9e7
removed bun maybe
Ryan-Bauroth Feb 13, 2024
453ae3e
fixed bug added bun
Ryan-Bauroth Feb 13, 2024
9c62906
got rid of compostable geteventoptions and added a new const
Ryan-Bauroth Feb 13, 2024
d7a5034
bun
Ryan-Bauroth Feb 13, 2024
205e7b8
removed all uses of compostable
Ryan-Bauroth Feb 13, 2024
449dde5
added it back changing the compostable
Ryan-Bauroth Feb 13, 2024
a46eb01
removed compostable again so it works
Ryan-Bauroth Feb 13, 2024
265f93a
filters and events in a working state i believe
Ryan-Bauroth Feb 13, 2024
70aca1f
quick bug fix
Ryan-Bauroth Feb 13, 2024
0988371
Merge remote-tracking branch 'origin/add-useEvent-composable' into ad…
Ryan-Bauroth Feb 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ logs
sw.*

# Other
bun.lockb
package-lock.json
Binary file modified bun.lockb
Binary file not shown.
98 changes: 98 additions & 0 deletions components/FilterMultiSelect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<script setup lang="ts">
import { computed } from 'vue'
const emit = defineEmits(['update:modelValue'])
/*
Model Value => The selected filters, each containing an id, their content, and optionally if they are user created
Options => Pre-programmed filter options, each with an id and content
Extra options => Guidelines for user creation of filters. Array of strings. Becomes a button with extraOption ': ' user input
Search Placeholder => placeholder for search (user input). defaults to "Search or Add Filter"
Filter Placeholder => placeholder for filter (dropdown button). defaults to "Edit Filters"
*/
const props = defineProps<{
modelValue: Array<{ id: number, content: string, custom?: boolean}>,
options: Array<{ id: number, content: string, custom?: boolean}>,
extraOptions?: Array<string>
searchPlaceholder?: string,
filterPlaceholder?: string,
}>()

const value = computed({
get() {
return props.modelValue
},
set(value) {
for(let option of props.options){
let optionSelected = false
for(let selectedOption of value){
if(option.id == selectedOption.id)
optionSelected = true
}
if(!optionSelected && option.custom != undefined && option.custom){
props.options.splice(props.options.indexOf(option, 1))
}
}
for(let selectedOption of value){
if(!props.options.includes(selectedOption)){
let optionExists = false
for(let option in props.options){
if(props.options[2].id == selectedOption.id){
optionExists = true
}
}
if(!optionExists){
props.options.push(selectedOption)

}
}
}
emit('update:modelValue', value)
}
})

let dropdownVariants = ref<Array<string>>()
if(props.extraOptions) {
dropdownVariants = ref(Array(props.extraOptions.length)
.fill("")
.map(
() => "ghost"
))
}

function addFilter(filterOption: string, index: number, query: string){
let customFilter = { id: props.options.length + 1, content: filterOption + ': ' + query, custom: true}
props.options.push(customFilter)
let currentVal = value.value
currentVal.push(customFilter)
value.value = currentVal
}

</script>

<template>
<USelectMenu
v-model="value"
by="id"
:options="props.options"
option-attribute="content"
multiple
searchable
:searchable-placeholder="searchPlaceholder != undefined ? searchPlaceholder: 'Search or Add Filter'"
>
<template #default>
<UButton color="gray" class="flex-1 justify-between min-h-9">
<span class="text-slate-600" v-if="value.length == 0">{{filterPlaceholder != undefined ? filterPlaceholder: 'Edit Filters'}}</span>
<div>
<UBadge class="mr-1 pl-2.5 pr-2.5" v-for="filter in value" :label="filter.content" color="white" :ui="{ rounded: 'rounded-full' }"></UBadge>
</div>
<UIcon name="i-heroicons-adjustments-horizontal" class="w-5 h-5 transition-transform text-gray-400 dark:text-gray-500" :class="[open && 'transform rotate-90']" />
</UButton>
</template>
<template #option-empty="{ query }" class="w-full">
<UButton v-for="(option, index) in props.extraOptions" :label="'add \'' + option + ': ' + query + '\''" :variant="dropdownVariants[index]" color="gray" @mouseover="dropdownVariants[index] = 'soft'" @mouseleave="dropdownVariants[index] = 'ghost'" @click="addFilter(option, index, query)"></UButton>
</template>
</USelectMenu>
</template>

<style scoped>

</style>
5 changes: 5 additions & 0 deletions components/IncrementalButton.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<script setup lang="ts">
import { computed } from 'vue'
/*
Model Value: the number selected
Max Value: the maximum value possible
(implied min value): must be above 0, can be changed in code below if need be
*/
const props = defineProps<{
modelValue: number,
maxValue?: number,
Expand Down
6 changes: 6 additions & 0 deletions components/MultiSelect.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<script setup lang="ts">
import { computed } from 'vue'
const emit = defineEmits(['update:modelValue'])
/*
Model Value: Array of numbers => 1 is selected, 0 is not selected
Options: Array of strings => the labels for the buttons
Connected Options: Array of numbers => matches the amount of buttons,
if two buttons have the same number in this array they can be selected at the same time
*/
const props = defineProps<{
modelValue: Array<number>,
options: Array<String>,
Expand Down
81 changes: 39 additions & 42 deletions components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import LoginState from "~/utils/authorization/LoginState";
import {loginStateKey} from "~/utils/keys";
import SessionResponse = PouchDB.Authentication.SessionResponse;

import {eventOptions} from "~/utils/eventOptions";
const {usernameState, sessionState, logout}: {
logout: () => Promise<void>;
// noinspection TypeScriptUnresolvedReference
Expand All @@ -14,6 +14,11 @@ const {usernameState, sessionState, logout}: {
updateUsernameState: () => Promise<boolean>
} = inject(loginStateKey)!

const events = eventOptions
let selectedEvent = ref(localStorage.getItem('currentEvent') || eventOptions[0])
watch(selectedEvent, (value) => {
window.localStorage.setItem('currentEvent', value)
})
let props = defineProps({
scoutMode: {
type: Boolean,
Expand All @@ -33,72 +38,64 @@ let links: VerticalNavigationLink[] = [
{ label: "Dashboard", to: "/dashboard" },
{ label: "Matches", to: "/matches" },
{ label: "Teams", to: "/teams" },
{ label: "Competitions", to: "/competitions" },
{ label: "Attachments", to: "/attachments" },
{ label: "Contacts", to: "/contacts" }
]
console.log(sessionState?.value?.userCtx?.roles)
if (sessionState?.value?.userCtx?.roles?.indexOf('_admin') != -1)
links.push({ label: "Users", to: "/users" })

const events = ['2024test', '2024trial']

let selectedEvent = ref(window.localStorage.getItem("event"))

function updateEvent(value: string){
window.localStorage.setItem("event", value)
}
</script>

<template>
<div class="py-2.5 px-5 z-10 bg-opacity-50 bg-gray-200 dark:bg-gray-700 w-screen navbar-right sticky top-0 flex-row justify-between backdrop-blur-lg">
<div class="flex">
<div v-if="!disableSidebar" class="py-2.5 px-5 z-10 bg-opacity-50 bg-gray-200 dark:bg-gray-700 w-screen navbar-right sticky top-0 flex-row justify-between backdrop-blur-lg min-h-16">
<Transition name="slide-fade">
<UButton class="slide-nothing" v-if="!disableSidebar" icon="i-heroicons-bars-3-20-solid" variant="ghost" @click="isOpen=!isOpen" :size="scoutMode?'sm':'xl'" square/>
<UButton class="slide-nothing" v-if="!disableSidebar" icon="i-heroicons-bars-3-20-solid" variant="ghost" @click="isOpen=!isOpen" :size="'xl'" square style="position:absolute; top:50%; transform: translateY(-50%)"/>
</Transition>
<UPopover style="right: 1%; position: absolute;top: 50%;transform: translateY(-50%);">
<UButton variant="ghost">
<UAvatar v-if="usernameState!==undefined" :alt="usernameState" :size="scoutMode?'xs':'md'" class="m-1"/>
</UButton>
<template #panel>
<UCard class="p-2">
<template #header>
{{usernameState}}
</template>
<UFormGroup class="inputDiv" label="Event" name="event">
<USelectMenu v-model="selectedEvent" :options="events" @update:model-value ="value => {updateEvent(value)}"/>
</UFormGroup>
<template #footer>
<UButton block label="Logout" square @click="logout"/>
</template>
</UCard>
</template>
</UPopover>
</div>
</div>
<USlideover v-model="isOpen" side="left" :appear="!disableSidebar">
<UCard class="flex flex-col h-screen">
<template #header>
<UButton icon="i-heroicons-bars-3-20-solid" variant="ghost" @click="isOpen=!isOpen" :size="scoutMode?'sm':'xl'"/>
<UButton icon="i-heroicons-bars-3-20-solid" variant="ghost" @click="isOpen=!isOpen" :size="'xl'"/>
</template>
<UVerticalNavigation :links="links"/>
<div class="settingsPopupDiv">
<UPopover>
<UButton icon="i-heroicons-cog-6-tooth" square :size="'xl'" :variant="'ghost'" :color="'gray'"/>
<template #panel>
<UCard class="p-2">
<template #header>
<div class="usernameLabel max-w-32 text-zinc-900">
{{usernameState}}
</div>
</template>
<UFormGroup class="inputDiv" label="Event" name="event">
<USelectMenu v-model="selectedEvent" :options="events" @update:v-model="(value) => updateEvent(value)"/>
</UFormGroup>
<template #footer>
<UButton block label="Logout" square @click="logout"/>
</template>
</UCard>
</template>
</UPopover>
</div>
</UCard>
</USlideover>
</template>

<style scoped>
.slide-fade-enter-active,
.slide-fade-leave-active {
transition: all 0.3s ease-in-out;

.slide-nothing {
transform: translateX(0%);
}

.slide-fade-enter-from,
.slide-fade-leave-to {
transform: translateX(-100%) !important;
opacity: .5;
.usernameLabel{
overflow:hidden
}

.slide-nothing {
transform: translateX(0%);
.settingsPopupDiv{
position:absolute;
left:4%;
bottom: 2%
}

</style>
Loading
Loading