Skip to content
Snippets Groups Projects
Commit 7fc88404 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

fix: don’t show inaccessible shows in show selector

refs #247
parent 901ad724
No related branches found
No related tags found
No related merge requests found
Pipeline #7417 passed
...@@ -80,7 +80,7 @@ import { useMagicKeys } from '@vueuse/core' ...@@ -80,7 +80,7 @@ import { useMagicKeys } from '@vueuse/core'
import { useI18n } from '@/i18n' import { useI18n } from '@/i18n'
import { sanitizeHTML } from '@/util' import { sanitizeHTML } from '@/util'
import { useShowStore } from '@/stores' import { useAuthStore, useShowStore } from '@/stores'
import SwitchButton from '@/components/SwitchButton.vue' import SwitchButton from '@/components/SwitchButton.vue'
import ComboBox from '@/components/ComboBox.vue' import ComboBox from '@/components/ComboBox.vue'
import AddShowButton from '@/components/shows/AddShowButton.vue' import AddShowButton from '@/components/shows/AddShowButton.vue'
...@@ -92,6 +92,7 @@ defineOptions({ compatConfig: { MODE: 3 } }) ...@@ -92,6 +92,7 @@ defineOptions({ compatConfig: { MODE: 3 } })
const keys = useMagicKeys() const keys = useMagicKeys()
const { t } = useI18n() const { t } = useI18n()
const showStore = useShowStore() const showStore = useShowStore()
const authStore = useAuthStore()
const selectedShow = computed<Show | null>(() => showStore.selectedShow) const selectedShow = computed<Show | null>(() => showStore.selectedShow)
const showSearchQuery = ref('') const showSearchQuery = ref('')
...@@ -105,13 +106,22 @@ const sortedShows = computed(() => { ...@@ -105,13 +106,22 @@ const sortedShows = computed(() => {
]) ])
}) })
const filteredShows = computed(() => { const filteredShows = computed(() => {
return sortedShows.value return (
.filter((show) => (filterActive.value !== null ? show.isActive === filterActive.value : true)) sortedShows.value
.filter( .filter((show) => (filterActive.value !== null ? show.isActive === filterActive.value : true))
(show) => // FIXME: Re-implementation of the ?isWritable=1 filter on the show API endpoint.
sanitizeHTML(show.name).toLocaleLowerCase().includes(showSearchQuery.value) || // If we’re keeping the show selector it should be refactored to use the API.
show.id.toString() === showSearchQuery.value, .filter(
) (show) =>
authStore.steeringUser?.isPrivileged ||
(authStore.steeringUser && show.ownerIds.includes(authStore.steeringUser.id)),
)
.filter(
(show) =>
sanitizeHTML(show.name).toLocaleLowerCase().includes(showSearchQuery.value) ||
show.id.toString() === showSearchQuery.value,
)
)
}) })
function toggleFilterActive(toggleState: boolean) { function toggleFilterActive(toggleState: boolean) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment