Fixed pagination. Added entity page channel tile expand.

This commit is contained in:
2024-01-25 03:07:26 +01:00
parent 0b3f98826b
commit d739975d36
29 changed files with 1056 additions and 128 deletions

View File

@@ -32,7 +32,7 @@
</span>
<span
v-if="actor.origin.country"
v-if="actor.origin?.country"
:title="`Born in ${actor.origin.country.name}`"
class="country"
>

View File

@@ -0,0 +1,51 @@
<template>
<a
:href="`/${entity.type}/${entity.slug}`"
class="entity"
>
<img
v-if="entity.hasLogo"
:src="entity.isIndependent ? `/logos/${entity.slug}/entity.png` : `/logos/${entity.parent?.slug}/${entity.slug}.png`"
:alt="entity.name"
class="logo"
>
<span v-else>{{ entity.name }}</span>
</a>
</template>
<script setup>
defineProps({
entity: {
type: Object,
default: null,
},
});
</script>
<style scoped>
.entity {
width: 15rem;
height: 6rem;
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
padding: 1rem;
border-radius: .5rem;
background: var(--grey-dark-40);
color: var(--text-light);
font-size: 1.25rem;
font-weight: bold;
&:hover {
box-shadow: 0 0 3px var(--shadow);
}
}
.logo {
height: 100%;
width: 100%;
object-fit: contain;
}
</style>

View File

@@ -0,0 +1,94 @@
<template>
<li
:key="`filter-actor-${actor.id}`"
class="filter-item"
:class="{ selected: filters.actors.some((filterActor) => filterActor.id === actor.id), first: type === 'available' && index === 0 && filters.actors.length > 0 }"
@click="emit('actor', actor)"
>
<div
class="filter-include"
@click.stop="toggleActor(actor)"
>
<Icon
icon="checkmark"
class="filter-add"
/>
<Icon
icon="cross2"
class="filter-remove"
/>
</div>
<span class="filter-name actor-name">
<span
class="filter-text"
:title="actor.name"
>{{ actor.name }}</span>
<span class="filter-details">
<div class="actor-gender">
<Gender
:gender="actor.gender"
class="gender"
/>
</div>
<span
v-if="actor.count"
class="filter-count"
>{{ actor.count }}</span>
</span>
</span>
</li>
</template>
<script setup>
import Gender from '#/components/actors/gender.vue';
defineProps({
actor: {
type: Object,
default: null,
},
index: {
type: Number,
default: null,
},
filters: {
type: Object,
default: null,
},
type: {
type: String,
default: 'available',
},
toggleActor: {
type: Function,
default: null,
},
});
const emit = defineEmits(['actor']);
</script>
<style scoped>
.filter-name {
align-items: stretch;
}
.actor-name {
display: flex;
align-items: stretch;
}
.actor-gender {
width: 1rem;
display: flex;
align-items: center;
.gender {
display: flex;
}
}
</style>

View File

@@ -4,7 +4,7 @@
<input
v-model="search"
type="search"
placeholder="Filter actors"
:placeholder="`Filter ${actors.length} actors`"
class="input input-inline filters-search"
>
@@ -46,60 +46,44 @@
</div>
<ul
v-for="(group, groupKey) in groupedActors"
:key="groupKey"
v-for="(actor, index) in selectedActors"
:key="`actor-${actor.id}`"
class="filter-items nolist"
>
<li
v-for="(actor, index) in group"
:key="`filter-actor-${actor.id}`"
class="filter-item"
: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"
@click.stop="toggleActor(actor)"
>
<Icon
icon="checkmark"
class="filter-add"
/>
<Icon
icon="cross2"
class="filter-remove"
/>
</div>
<span class="filter-name actor-name">
<span
class="filter-text"
:title="actor.name"
>{{ actor.name }}</span>
<span class="filter-details">
<div class="actor-gender">
<Gender
:gender="actor.gender"
class="gender"
/>
</div>
<span
v-if="actor.count"
class="filter-count"
>{{ actor.count }}</span>
</span>
</span>
</li>
<Actor
:actor="actor"
:index="index"
:filters="filters"
:toggle-actor="toggleActor"
type="selected"
@actor="(actor) => emit('update', 'actors', [actor])"
/>
</ul>
<UseVirtualList
:list="availableActors"
:options="{ itemHeight: 30 }"
class="filter-items nolist"
>
<template #default="{ data: actor, index }">
<Actor
:actor="actor"
:index="index"
:filters="filters"
:toggle-actor="toggleActor"
type="available"
@actor="(actor) => emit('update', 'actors', [actor])"
/>
</template>
</UseVirtualList>
</div>
</template>
<script setup>
import { ref, computed, inject } from 'vue';
import { UseVirtualList } from '@vueuse/components';
import Actor from '#/components/filters/actor.vue';
import Gender from '#/components/actors/gender.vue';
const props = defineProps({
@@ -123,21 +107,19 @@ const order = ref('name');
const { pageProps } = inject('pageContext');
const { actor: pageActor } = pageProps;
const groupedActors = computed(() => ({
selected: props.filters.actors.map((filterActor) => props.actors.find((actor) => actor.id === filterActor.id)).filter(Boolean),
available: props.actors
.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))
.sort((actorA, actorB) => {
if (order.value === 'count') {
return actorB.count - actorA.count;
}
const selectedActors = computed(() => props.filters.actors.map((filterActor) => props.actors.find((actor) => actor.id === filterActor.id)).filter(Boolean));
const availableActors = computed(() => props.actors
.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))
.sort((actorA, actorB) => {
if (order.value === 'count') {
return actorB.count - actorA.count;
}
return actorA.name.localeCompare(actorB.name);
}),
}));
return actorA.name.localeCompare(actorB.name);
}));
const genders = computed(() => [null, ...['female', 'male', 'transsexual', 'other'].filter((gender) => props.actors.some((actor) => actor.gender === gender))]);
@@ -171,22 +153,8 @@ function selectGender() {
border-top: solid 1px var(--shadow-weak-30);
}
.filter-name {
align-items: stretch;
}
.actor-name {
display: flex;
align-items: stretch;
}
.actor-gender {
width: 1rem;
display: flex;
align-items: center;
.gender {
display: flex;
}
.list {
height: 15rem;
overflow-y: auto;
}
</style>

View File

@@ -4,7 +4,7 @@
<input
v-model="search"
type="search"
placeholder="Filter channels"
:placeholder="`Filter ${channels.length} channels`"
class="input input-inline filters-search"
>
@@ -113,7 +113,10 @@ const entities = computed(() => {
return Object.values(filteredChannels.reduce((acc, channel) => {
if (!channel.parent || channel.isIndependent) {
acc[channel.id] = channel;
acc[channel.id] = {
...channel,
children: [],
};
return acc;
}
@@ -151,7 +154,7 @@ const entities = computed(() => {
.filter-item.channel {
.filter-text .icon {
width: 1.5rem;
width: 2.25rem;
height: 1rem;
transform: rotate(-135deg);
fill: var(--shadow-weak-30);
@@ -160,7 +163,7 @@ const entities = computed(() => {
}
.favicon {
width: 1rem;
width: 1.75rem;
height: 1rem;
margin-right: .5rem;
object-fit: contain;

View File

@@ -266,7 +266,7 @@ function toggleFilters(state) {
}
.filter-count {
width: 1.5rem;
width: 1.75rem;
display: flex;
align-items: center;
justify-content: center;

View File

@@ -4,7 +4,7 @@
<input
v-model="search"
type="search"
placeholder="Filter tags"
:placeholder="`Filter ${tags.length} tags`"
class="input input-inline filters-search"
>

View File

@@ -149,8 +149,14 @@ function go(page, event) {
function getPath(page) {
const path = parse(routeParams.path)
.map((segment) => (segment.name === 'page' ? String(page) : routeParams[segment.name] || segment))
.join('/');
.map((segment) => {
if (segment.name === 'page') {
return `/${page}`;
}
return `${segment.prefix || ''}${routeParams[segment.name] || segment}`;
})
.join('');
if (props.includeQuery && urlParsed.searchOriginal) {
return `${path}${urlParsed.searchOriginal}`;
@@ -165,6 +171,7 @@ function getPath(page) {
height: 5rem;
display: flex;
justify-content: center;
flex-shrink: 0;
box-sizing: border-box;
padding: 1rem;
font-size: 0;

View File

@@ -1,6 +1,6 @@
<template>
<div
class="page"
class="scenes-page"
>
<Filters
v-if="showFilters"
@@ -34,9 +34,23 @@
class="scenes-header"
>
<div class="meta">{{ total }} results</div>
<select
v-model="scope"
class="input"
@change="search"
>
<option value="likes">Likes</option>
<option value="latest">Latest</option>
<option value="upcoming">Upcoming</option>
<option value="new">New</option>
</select>
</div>
<nav class="scopes">
<nav
v-if="showScopeTabs"
class="scopes"
>
<Link
:href="getPath('latest')"
class="scope nolink"
@@ -103,15 +117,18 @@ defineProps({
type: Boolean,
default: true,
},
showScopeTabs: {
type: Boolean,
default: false,
},
});
const { pageProps, routeParams, urlParsed } = inject('pageContext');
const { scope } = routeParams;
const {
actor: pageActor,
tag: pageTag,
channel: pageChannel,
entity: pageEntity,
} = pageProps;
const scenes = ref(pageProps.scenes);
@@ -120,6 +137,7 @@ const aggTags = ref(pageProps.aggTags || []);
const aggChannels = ref(pageProps.aggChannels || []);
const currentPage = ref(Number(routeParams.page));
const scope = ref(routeParams.scope);
const total = ref(Number(pageProps.total));
const loading = ref(false);
@@ -138,19 +156,17 @@ const filters = ref({
});
function getPath(targetScope, preserveQuery) {
const path = parse(routeParams.path)
.map((segment) => {
if (segment.name === 'scope') {
return targetScope;
}
const path = parse(routeParams.path).map((segment) => {
if (segment.name === 'scope') {
return `${segment.prefix}${targetScope}`;
}
if (segment.name === 'page') {
return 1;
}
if (segment.name === 'page') {
return `${segment.prefix}${1}`;
}
return routeParams[segment.name] || segment;
})
.join('/');
return `${segment.prefix || ''}${routeParams[segment.name] || segment}`;
}).join('');
if (preserveQuery && urlParsed.searchOriginal) {
return `${path}${urlParsed.searchOriginal}`;
@@ -166,7 +182,7 @@ async function search(resetPage = true) {
const query = {};
const entity = filters.value.entity || pageChannel;
const entity = filters.value.entity || pageEntity;
const entitySlug = entity?.type === 'network' ? `_${entity.slug}` : entity?.slug;
loading.value = true;
@@ -176,7 +192,7 @@ async function search(resetPage = true) {
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(','),
e: entitySlug,
scope,
scope: scope.value,
page: currentPage.value, // client uses param rather than query pagination
});
@@ -184,12 +200,13 @@ async function search(resetPage = true) {
aggActors.value = res.aggActors;
aggTags.value = res.aggTags;
aggChannels.value = res.aggChannels;
total.value = res.total;
total.value = res.total;
loading.value = false;
events.emit('scrollUp');
navigate(getPath(scope, false), {
navigate(getPath(scope.value, false), {
...query,
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,
@@ -207,7 +224,7 @@ function updateFilter(prop, value, reload = true) {
</script>
<style scoped>
.page {
.scenes-page {
display: flex;
background: var(--background-base-10);
position: relative;
@@ -216,7 +233,7 @@ function updateFilter(prop, value, reload = true) {
.scenes-header {
display: flex;
align-items: center;
padding: 1rem 0 .25rem 3rem;
padding: .5rem 1rem .25rem 3rem;
}
.scenes-container {
@@ -236,7 +253,7 @@ function updateFilter(prop, value, reload = true) {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
gap: .75rem .5rem;
padding: 1rem;
padding: .5rem 1rem 1rem 1rem;
}
.scopes {