Sorting aggregated actors by scene count back-end, showing disclaimer when limit is reached.

This commit is contained in:
2024-02-29 01:40:11 +01:00
parent 2125a91524
commit 92c2b1866b
10 changed files with 172 additions and 130 deletions

View File

@@ -1,56 +1,61 @@
<template>
<div class="filter actors-container">
<div
v-if="isAggActorsLimited"
class="filter-disclaimer"
>Some actors may not be listed, apply a filter or search to narrow down results.</div>
<div class="filters-sort">
<input
v-model="search"
type="search"
:placeholder="`Filter ${actors.length} actors`"
class="input input-inline filters-search"
>
<div
class="filter-sort noselect"
@click="selectGender"
>
<div
v-if="!selectedGender"
class="gender-unselected"
><Icon icon="genders" /></div>
<Gender
v-else
:gender="selectedGender"
class="gender"
/>
</div>
<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 = 'name'"
>
<Icon
icon="sort-numeric-desc"
/>
</div>
</div>
<div
v-if="availableActors.length === 0"
class="filter-empty"
>No actors</div>
<template v-else>
<div class="filters-sort">
<input
v-model="search"
type="search"
:placeholder="`Filter ${actors.length} actors`"
class="input input-inline filters-search"
>
<div
class="filter-sort noselect"
@click="selectGender"
>
<div
v-if="!selectedGender"
class="gender-unselected"
><Icon icon="genders" /></div>
<Gender
v-else
:gender="selectedGender"
class="gender"
/>
</div>
<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 = 'name'"
>
<Icon
icon="sort-numeric-desc"
/>
</div>
</div>
<ul
v-for="(actor, index) in selectedActors"
:key="`actor-${actor.id}`"
@@ -110,12 +115,14 @@ const emit = defineEmits(['update']);
const search = ref('');
const searchRegexp = computed(() => new RegExp(search.value, 'i'));
const selectedGender = ref(null);
const order = ref('name');
const order = ref('count');
const { pageProps } = inject('pageContext');
const pageContext = inject('pageContext');
const pageProps = pageContext.pageProps;
const { actor: pageActor } = pageProps;
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
@@ -130,6 +137,7 @@ const availableActors = computed(() => props.actors
}));
const genders = computed(() => [null, ...['female', 'male', 'transsexual', 'other'].filter((gender) => props.actors.some((actor) => actor.gender === gender))]);
const isAggActorsLimited = computed(() => props.actors.length >= pageContext.env.maxAggregateSize);
function toggleActor(actor, combine) {
if (props.filters.actors.some((filterActor) => filterActor.id === actor.id)) {

View File

@@ -1,36 +1,36 @@
<template>
<div class="filter channels-container">
<div class="filters-sort">
<input
v-model="search"
type="search"
:placeholder="`Filter ${channels.length} 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 = 'name'"
>
<Icon icon="sort-numeric-desc" />
</div>
</div>
<div
v-if="entities.length === 0"
class="filter-empty"
>No channels</div>
<template v-else>
<div class="filters-sort">
<input
v-model="search"
type="search"
:placeholder="`Filter ${channels.length} 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 = 'name'"
>
<Icon icon="sort-numeric-desc" />
</div>
</div>
<ul
class="filter-items nolist"
>
@@ -128,14 +128,14 @@ const entities = computed(() => {
return acc;
}
if (!acc[channel.parent.id] && channel.type === 'channel') {
if (channel.parent && !acc[channel.parent.id] && channel.type === 'channel') {
acc[channel.parent.id] = {
...channel.parent,
children: [],
};
}
if (channel.type === 'channel') {
if (channel.parent && channel.type === 'channel') {
acc[channel.parent.id].children.push(channel);
}

View File

@@ -290,6 +290,15 @@ function toggleFilters(state) {
color: var(--shadow);
font-style: italic;
}
.filter-disclaimer {
background: var(--notice);
color: var(--highlight-strong-30);
padding: .25rem .5rem;
box-shadow: inset 0 0 3px var(--shadow-weak-30);
line-height: 1.25;
font-size: .9rem;
}
</style>
<style scoped>

View File

@@ -1,50 +1,50 @@
<template>
<div class="filter tags-container">
<div class="filters-sort">
<input
v-model="search"
type="search"
:placeholder="`Filter ${tags.length} tags`"
class="input input-inline filters-search"
>
<div
v-show="order === 'priority'"
class="filter-sort order noselect"
@click="order = 'name'"
>
<Icon
icon="star"
/>
</div>
<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>
<div
v-if="tags.length === 0"
v-if="groupedTags.available.length === 0"
class="filter-empty"
>No tags</div>
<template v-else>
<div class="filters-sort">
<input
v-model="search"
type="search"
:placeholder="`Filter ${tags.length} tags`"
class="input input-inline filters-search"
>
<div
v-show="order === 'priority'"
class="filter-sort order noselect"
@click="order = 'name'"
>
<Icon
icon="star"
/>
</div>
<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
v-for="(group, groupKey) in groupedTags"
:key="groupKey"