Aggregating channels, filter inoperable.
This commit is contained in:
@@ -54,8 +54,8 @@
|
||||
v-for="(actor, index) in group"
|
||||
:key="`filter-actor-${actor.id}`"
|
||||
class="filter-item"
|
||||
:class="{ selected: filters.actors.includes(actor.id), first: groupKey === 'available' && index === 0 && filters.actors.length > 0 }"
|
||||
@click="emit('update', 'actors', [actor.id])"
|
||||
:class="{ selected: filters.actors.some((filterActor) => filterActor.id === actor.id), first: groupKey === 'available' && index === 0 && filters.actors.length > 0 }"
|
||||
@click="emit('update', 'actors', [actor])"
|
||||
>
|
||||
<div
|
||||
class="filter-include"
|
||||
@@ -73,7 +73,10 @@
|
||||
</div>
|
||||
|
||||
<span class="filter-name actor-name">
|
||||
{{ actor.name }}
|
||||
<span
|
||||
class="filter-text"
|
||||
:title="actor.name"
|
||||
>{{ actor.name }}</span>
|
||||
|
||||
<span class="actor-details">
|
||||
<div class="actor-gender">
|
||||
@@ -121,9 +124,9 @@ const { pageProps } = inject('pageContext');
|
||||
const { actor: pageActor } = pageProps;
|
||||
|
||||
const groupedActors = computed(() => ({
|
||||
selected: props.filters.actors.map((actorId) => props.actors.find((actor) => actor.id === actorId)).filter(Boolean),
|
||||
selected: props.filters.actors.map((filterActor) => props.actors.find((actor) => actor.id === filterActor.id)).filter(Boolean),
|
||||
available: props.actors
|
||||
.filter((actor) => !props.filters.actors.includes(actor.id)
|
||||
.filter((actor) => !props.filters.actors.some((filterActor) => filterActor.id === actor.id)
|
||||
&& actor.id !== pageActor?.id
|
||||
&& searchRegexp.value.test(actor.name)
|
||||
&& (!selectedGender.value || actor.gender === selectedGender.value))
|
||||
@@ -139,12 +142,12 @@ const groupedActors = computed(() => ({
|
||||
const genders = computed(() => [null, ...['female', 'male', 'transsexual', 'other'].filter((gender) => props.actors.some((actor) => actor.gender === gender))]);
|
||||
|
||||
function toggleActor(actor) {
|
||||
if (props.filters.actors.includes(actor.id)) {
|
||||
emit('update', 'actors', props.filters.actors.filter((actorId) => actorId !== actor.id));
|
||||
if (props.filters.actors.some((filterActor) => filterActor.id === actor.id)) {
|
||||
emit('update', 'actors', props.filters.actors.filter((filterActor) => filterActor.id !== actor.id));
|
||||
return;
|
||||
}
|
||||
|
||||
emit('update', 'actors', props.filters.actors.concat(actor.id));
|
||||
emit('update', 'actors', props.filters.actors.concat(actor));
|
||||
}
|
||||
|
||||
function selectGender() {
|
||||
@@ -160,12 +163,6 @@ function selectGender() {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.gender-unselected {
|
||||
.icon {
|
||||
fill: var(--shadow);
|
||||
}
|
||||
}
|
||||
|
||||
.filter {
|
||||
padding: 0;
|
||||
}
|
||||
@@ -175,9 +172,7 @@ function selectGender() {
|
||||
}
|
||||
|
||||
.filter-name {
|
||||
height: 1rem;
|
||||
align-items: stretch;
|
||||
padding: .25rem 0 .25rem .25rem;
|
||||
}
|
||||
|
||||
.actor-name {
|
||||
|
||||
151
components/filters/channels.vue
Normal file
151
components/filters/channels.vue
Normal file
@@ -0,0 +1,151 @@
|
||||
<template>
|
||||
<div class="filter channels-container">
|
||||
<div class="filters-sort">
|
||||
<input
|
||||
v-model="search"
|
||||
type="search"
|
||||
placeholder="Filter channels"
|
||||
class="input input-inline filters-search"
|
||||
>
|
||||
|
||||
<div
|
||||
v-show="order === 'name'"
|
||||
class="filter-sort order noselect"
|
||||
@click="order = 'count'"
|
||||
>
|
||||
<Icon
|
||||
icon="sort-alpha-asc"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-show="order === 'count'"
|
||||
class="filter-sort order noselect"
|
||||
@click="order = 'priority'"
|
||||
>
|
||||
<Icon
|
||||
icon="sort-numeric-desc"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul
|
||||
class="filter-items nolist"
|
||||
>
|
||||
<template v-for="network in networks">
|
||||
<li
|
||||
v-for="(channel) in [network, ...(network.children || [])]"
|
||||
:key="`filter-channel-${channel.id}`"
|
||||
class="filter-item"
|
||||
:class="{ channel: !channel.isIndependent && channel.type !== 'network', selected: filters.channel?.id === channel.id }"
|
||||
@click="emit('update', 'channel', channel)"
|
||||
>
|
||||
<span class="filter-name">
|
||||
<span
|
||||
class="filter-text"
|
||||
:title="channel.name"
|
||||
>
|
||||
<img
|
||||
v-if="channel.isIndependent || channel.type === 'network'"
|
||||
:src="`/logos/${channel.slug}/favicon_dark.png`"
|
||||
class="favicon"
|
||||
>
|
||||
|
||||
<Icon
|
||||
v-else
|
||||
icon="arrow-up4"
|
||||
/>
|
||||
|
||||
{{ channel.name }}
|
||||
</span>
|
||||
|
||||
<span class="channel-details">
|
||||
<span
|
||||
v-if="channel.count"
|
||||
class="filter-count"
|
||||
>{{ channel.count }}</span>
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
</template>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, inject } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
filters: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
channels: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update']);
|
||||
|
||||
const search = ref('');
|
||||
const searchRegexp = computed(() => new RegExp(search.value, 'i'));
|
||||
const order = ref('name');
|
||||
|
||||
const { pageProps } = inject('pageContext');
|
||||
const { channel: pageChannel } = pageProps;
|
||||
|
||||
const networks = computed(() => {
|
||||
const filteredChannels = props.channels.filter((channel) => channel.id !== pageChannel?.id
|
||||
&& (searchRegexp.value.test(channel.name)
|
||||
|| searchRegexp.value.test(channel.slug)
|
||||
|| (channel.parent && searchRegexp.value.test(channel.parent.name))
|
||||
|| (channel.parent && searchRegexp.value.test(channel.parent.slug))));
|
||||
|
||||
return Object.values(filteredChannels.reduce((acc, channel) => {
|
||||
if (!channel.parent || channel.isIndependent) {
|
||||
acc[channel.id] = channel;
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (!acc[channel.parent.id]) {
|
||||
acc[channel.parent.id] = {
|
||||
...channel.parent,
|
||||
children: [],
|
||||
};
|
||||
}
|
||||
|
||||
acc[channel.parent.id].children.push(channel);
|
||||
|
||||
return acc;
|
||||
}, {}));
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.filter-items {
|
||||
max-height: 10rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.filter {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.filter-item.channel {
|
||||
.icon {
|
||||
width: 1.5rem;
|
||||
height: 1rem;
|
||||
transform: rotate(-135deg);
|
||||
fill: var(--shadow-weak-30);
|
||||
}
|
||||
}
|
||||
|
||||
.favicon {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
margin-right: .5rem;
|
||||
object-fit: contain;
|
||||
}
|
||||
</style>
|
||||
@@ -186,11 +186,17 @@ function toggleFilters(state) {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
padding: .25rem .75rem .25rem 1rem;
|
||||
padding: .25rem 0 .25rem .25rem;
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.filter-text {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.filter-include {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -222,13 +228,13 @@ function toggleFilters(state) {
|
||||
align-items: center;
|
||||
align-self: stretch;
|
||||
justify-content: center;
|
||||
padding: 0 .5rem;
|
||||
padding: 0 .25rem;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
color: var(--shadow);
|
||||
|
||||
&.order {
|
||||
padding: 0 1rem 0 .25rem;
|
||||
padding: 0 .5rem 0 .25rem;
|
||||
}
|
||||
|
||||
.icon {
|
||||
|
||||
@@ -75,6 +75,3 @@ defineProps({
|
||||
|
||||
const emit = defineEmits(['change', 'input', 'enable']);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
|
||||
@@ -67,13 +67,18 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<span class="filter-name tag-name">{{ tag.name }}</span>
|
||||
|
||||
<span class="tag-details">
|
||||
<span class="filter-name tag-name">
|
||||
<span
|
||||
v-if="tag.count"
|
||||
class="filter-count"
|
||||
>{{ tag.count }}</span>
|
||||
class="filter-text"
|
||||
:title="tag.name"
|
||||
>{{ tag.name }}</span>
|
||||
|
||||
<span class="tag-details">
|
||||
<span
|
||||
v-if="tag.count"
|
||||
class="filter-count"
|
||||
>{{ tag.count }}</span>
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -170,7 +175,7 @@ function toggleTag(tag) {
|
||||
|
||||
<style scoped>
|
||||
.filter-items {
|
||||
max-height: 15rem;
|
||||
max-height: 10rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
|
||||
@@ -205,6 +205,7 @@ async function setRange(prop, value) {
|
||||
}
|
||||
|
||||
.label {
|
||||
height: 100%;
|
||||
padding: 0 .5rem;
|
||||
|
||||
&:hover:not(.disabled) {
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
@update="updateFilter"
|
||||
/>
|
||||
|
||||
<ChannelsFilter
|
||||
:filters="filters"
|
||||
:channels="aggChannels"
|
||||
@update="updateFilter"
|
||||
/>
|
||||
|
||||
<ActorsFilter
|
||||
:filters="filters"
|
||||
:actors="aggActors"
|
||||
@@ -63,10 +69,12 @@ import { parse } from 'path-to-regexp';
|
||||
import navigate from '#/src/navigate.js';
|
||||
import { get } from '#/src/api.js';
|
||||
import events from '#/src/events.js';
|
||||
import { getActorIdentifier, parseActorIdentifier } from '#/src/query.js';
|
||||
|
||||
import Filters from '#/components/filters/filters.vue';
|
||||
import ActorsFilter from '#/components/filters/actors.vue';
|
||||
import TagsFilter from '#/components/filters/tags.vue';
|
||||
import ChannelsFilter from '#/components/filters/channels.vue';
|
||||
import Scene from './tile.vue';
|
||||
import Pagination from '../pagination/pagination.vue';
|
||||
|
||||
@@ -85,19 +93,31 @@ const { pageProps, routeParams, urlParsed } = inject('pageContext');
|
||||
const { scope } = routeParams;
|
||||
|
||||
const {
|
||||
actor,
|
||||
actor: pageActor,
|
||||
tag: pageTag,
|
||||
channel: pageChannel,
|
||||
} = pageProps;
|
||||
|
||||
const scenes = ref(pageProps.scenes);
|
||||
const aggActors = ref(pageProps.aggActors);
|
||||
const aggTags = ref(pageProps.aggTags);
|
||||
const aggChannels = ref(pageProps.aggChannels);
|
||||
|
||||
const currentPage = ref(Number(routeParams.page));
|
||||
const total = ref(Number(pageProps.total));
|
||||
|
||||
const actorIds = urlParsed.search.actors?.split(',').map((identifier) => parseActorIdentifier(identifier)?.id).filter(Boolean) || [];
|
||||
const queryActors = actorIds.map((urlActorId) => aggActors.value.find((aggActor) => aggActor.id === urlActorId)).filter(Boolean);
|
||||
|
||||
const networks = Object.fromEntries(aggChannels.value.map((channel) => (channel.type === 'network' ? channel : channel.parent)).filter(Boolean).map((parent) => [`_${parent.slug}`, parent]));
|
||||
const channels = Object.fromEntries(aggChannels.value.filter((channel) => channel.type === 'channel').map((channel) => [channel.slug, channel]));
|
||||
|
||||
const queryChannel = networks[urlParsed.search.e] || channels[urlParsed.search.e];
|
||||
|
||||
const filters = ref({
|
||||
actors: urlParsed.search.actors?.split(',').filter(Boolean).map((actorId) => Number(actorId)) || [],
|
||||
tags: urlParsed.search.tags?.split(',').filter(Boolean) || [],
|
||||
channel: queryChannel,
|
||||
actors: queryActors,
|
||||
});
|
||||
|
||||
function getPath(targetScope, preserveQuery) {
|
||||
@@ -127,15 +147,16 @@ async function search(resetPage = true) {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
const query = {
|
||||
tags: filters.value.tags.join(','),
|
||||
};
|
||||
const query = {};
|
||||
|
||||
console.log('actor id', actor?.id);
|
||||
const entity = filters.value.channel || pageChannel;
|
||||
const entitySlug = entity?.type === 'network' ? `_${entity.slug}` : entity?.slug;
|
||||
|
||||
const res = await get('/scenes', {
|
||||
...query,
|
||||
actors: [actor?.id, filters.value.actors].filter(Boolean).join(','), // if we're on an actor page, that actor ID needs to be included
|
||||
actors: [pageActor, ...filters.value.actors].filter(Boolean).map((filterActor) => getActorIdentifier(filterActor)).join(','), // if we're on an actor page, that actor ID needs to be included
|
||||
tags: [pageTag?.slug, ...filters.value.tags].filter(Boolean).join(','),
|
||||
entity: entitySlug,
|
||||
scope,
|
||||
page: currentPage.value, // client uses param rather than query pagination
|
||||
});
|
||||
@@ -145,21 +166,19 @@ async function search(resetPage = true) {
|
||||
aggTags.value = res.aggTags;
|
||||
total.value = res.total;
|
||||
|
||||
console.log(scenes.value);
|
||||
|
||||
events.emit('scrollUp');
|
||||
|
||||
navigate(getPath(scope, false), {
|
||||
...query,
|
||||
actors: filters.value.actors.join(',') || undefined, // don't include actor page ID in query, already a parameter
|
||||
actors: filters.value.actors.map((filterActor) => getActorIdentifier(filterActor)).join(',') || undefined, // don't include page actor ID in query, already a parameter
|
||||
tags: filters.value.tags.join(',') || undefined,
|
||||
e: filters.value.channel?.type === 'network' ? `_${filters.value.channel.slug}` : (filters.value.channel?.slug || undefined),
|
||||
}, { redirect: false });
|
||||
}
|
||||
|
||||
function updateFilter(prop, value, reload = true) {
|
||||
filters.value[prop] = value;
|
||||
|
||||
console.log(prop, value);
|
||||
|
||||
if (reload) {
|
||||
search();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user