Upgraded dependencies, bumped to Node 24.
This commit is contained in:
@@ -1,3 +1,80 @@
|
||||
<script setup>
|
||||
import { computed, inject, ref, useId } from 'vue';
|
||||
|
||||
import abbreviateNumber from '#/src/utils/abbreviate-number.js';
|
||||
|
||||
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 sortAlphaTooltipId = useId();
|
||||
const sortCountTooltipId = useId();
|
||||
|
||||
const { pageProps } = inject('pageContext');
|
||||
const { channel: pageChannel } = pageProps;
|
||||
|
||||
function sort(channelA, channelB) {
|
||||
if (order.value === 'count') {
|
||||
return channelB.count - channelA.count;
|
||||
}
|
||||
|
||||
return channelA.name.localeCompare(channelB.name);
|
||||
}
|
||||
|
||||
const entities = 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))));
|
||||
|
||||
const networks = Object.values(filteredChannels.reduce((acc, channel) => {
|
||||
if (!acc[channel.id] && (channel.type === 'network' || !channel.parent || channel.isIndependent)) { // network may have already been created by a child
|
||||
acc[channel.id] = {
|
||||
...channel,
|
||||
children: [],
|
||||
};
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (!acc[channel.id] && channel.parent && !acc[channel.parent.id] && (channel.type === 'channel' || channel.type === 'studio')) {
|
||||
acc[channel.parent.id] = {
|
||||
...channel.parent,
|
||||
children: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (!acc[channel.id] && channel.parent && (channel.type === 'channel' || channel.type === 'studio')) {
|
||||
acc[channel.parent.id].children.push(channel);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {}))
|
||||
.map((network) => ({
|
||||
...network,
|
||||
children: network.children?.sort(sort),
|
||||
count: network.count || network.children?.reduce((acc, channel) => acc + channel.count, 0),
|
||||
}))
|
||||
.sort(sort)
|
||||
.flatMap((network) => [network, ...(network.children || [])]);
|
||||
|
||||
return networks;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="filter channels-container">
|
||||
<div class="filters-sort">
|
||||
@@ -14,7 +91,7 @@
|
||||
|
||||
<div
|
||||
v-show="order === 'name'"
|
||||
v-tooltip="'Sorted alphanumerically'"
|
||||
v-tooltip="{ content: 'Sorted alphanumerically', ariaId: sortAlphaTooltipId }"
|
||||
class="filter-sort order noselect"
|
||||
@click="order = 'count'"
|
||||
>
|
||||
@@ -23,7 +100,7 @@
|
||||
|
||||
<div
|
||||
v-show="order === 'count'"
|
||||
v-tooltip="'Sorted by number of scenes'"
|
||||
v-tooltip="{ content: 'Sorted by number of scenes', ariaId: sortCountTooltipId }"
|
||||
class="filter-sort order noselect"
|
||||
@click="order = 'name'"
|
||||
>
|
||||
@@ -77,7 +154,7 @@
|
||||
v-if="filters.entity?.id === entity.id"
|
||||
icon="cross2"
|
||||
class="filter-remove"
|
||||
@click.native.stop="emit('update', 'entity', null)"
|
||||
@click.stop="emit('update', 'entity', null)"
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
@@ -87,81 +164,6 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, inject } from 'vue';
|
||||
|
||||
import abbreviateNumber from '#/src/utils/abbreviate-number.js';
|
||||
|
||||
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;
|
||||
|
||||
function sort(channelA, channelB) {
|
||||
if (order.value === 'count') {
|
||||
return channelB.count - channelA.count;
|
||||
}
|
||||
|
||||
return channelA.name.localeCompare(channelB.name);
|
||||
}
|
||||
|
||||
const entities = 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))));
|
||||
|
||||
const networks = Object.values(filteredChannels.reduce((acc, channel) => {
|
||||
if (!acc[channel.id] && (channel.type === 'network' || !channel.parent || channel.isIndependent)) { // network may have already been created by a child
|
||||
acc[channel.id] = {
|
||||
...channel,
|
||||
children: [],
|
||||
};
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (!acc[channel.id] && channel.parent && !acc[channel.parent.id] && (channel.type === 'channel' || channel.type === 'studio')) {
|
||||
acc[channel.parent.id] = {
|
||||
...channel.parent,
|
||||
children: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (!acc[channel.id] && channel.parent && (channel.type === 'channel' || channel.type === 'studio')) {
|
||||
acc[channel.parent.id].children.push(channel);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {}))
|
||||
.map((network) => ({
|
||||
...network,
|
||||
children: network.children?.sort(sort),
|
||||
count: network.count || network.children?.reduce((acc, channel) => acc + channel.count, 0),
|
||||
}))
|
||||
.sort(sort)
|
||||
.flatMap((network) => [network, ...(network.children || [])]);
|
||||
|
||||
return networks;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.filter-items {
|
||||
max-height: 15rem;
|
||||
|
||||
Reference in New Issue
Block a user