Optionally showing aliases in actors admin.
This commit is contained in:
@@ -22,6 +22,12 @@
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<Checkbox
|
||||||
|
label="Show aliased"
|
||||||
|
:checked="showAliased"
|
||||||
|
@change="(checked) => { showAliased = checked; searchActors(); }"
|
||||||
|
/>
|
||||||
|
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<button
|
<button
|
||||||
class="button"
|
class="button"
|
||||||
@@ -67,11 +73,17 @@
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td
|
<td
|
||||||
v-tooltip="actor.entity?.name || 'Global'"
|
v-tooltip="actor.alias ? `#${actor.alias.id} ${actor.alias.name}` : (actor.entity?.name || 'Global')"
|
||||||
class="actor-entity ellipsis"
|
class="actor-entity ellipsis"
|
||||||
>
|
>
|
||||||
|
<Icon
|
||||||
|
v-if="actor.alias"
|
||||||
|
icon="at-sign"
|
||||||
|
class="actor-alias"
|
||||||
|
/>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
v-if="actor.entity"
|
v-else-if="actor.entity"
|
||||||
:src="`/logos/${actor.entity.slug}/favicon_dark.png`"
|
:src="`/logos/${actor.entity.slug}/favicon_dark.png`"
|
||||||
class="actor-favicon"
|
class="actor-favicon"
|
||||||
>
|
>
|
||||||
@@ -170,6 +182,7 @@ const actors = ref(pageProps.actors);
|
|||||||
const selectedActors = ref(new Set([]));
|
const selectedActors = ref(new Set([]));
|
||||||
const activeActor = ref(null);
|
const activeActor = ref(null);
|
||||||
const actorQuery = ref(urlParsed.search.q || null);
|
const actorQuery = ref(urlParsed.search.q || null);
|
||||||
|
const showAliased = ref(Object.hasOwn(urlParsed.search, 'alias'));
|
||||||
|
|
||||||
const lastSelectedIndex = ref(null);
|
const lastSelectedIndex = ref(null);
|
||||||
const holdingShift = ref(false);
|
const holdingShift = ref(false);
|
||||||
@@ -197,7 +210,10 @@ function selectActors(selectedActor, isChecked, index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function searchActors() {
|
async function searchActors() {
|
||||||
navigate('/admin/actors', { q: actorQuery.value || undefined }, { redirect: true });
|
navigate('/admin/actors', {
|
||||||
|
q: actorQuery.value || undefined,
|
||||||
|
alias: showAliased.value || undefined,
|
||||||
|
}, { redirect: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -288,6 +304,11 @@ onMounted(() => {
|
|||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actor-alias {
|
||||||
|
fill: var(--primary);
|
||||||
|
padding: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
th.actor-actions {
|
th.actor-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
||||||
|
|
||||||
import { fetchActors } from '#/src/actors.js';
|
import { fetchActors } from '#/src/actors.js';
|
||||||
|
import { curateActorsQuery } from '#/src/web/actors.js';
|
||||||
import verifyAbility from '#/utils/verify-ability.js';
|
import verifyAbility from '#/utils/verify-ability.js';
|
||||||
|
|
||||||
export default async function onBeforeRender(pageContext) {
|
export default async function onBeforeRender(pageContext) {
|
||||||
@@ -8,9 +9,7 @@ export default async function onBeforeRender(pageContext) {
|
|||||||
throw render(404);
|
throw render(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { actors } = await fetchActors({
|
const { actors } = await fetchActors(curateActorsQuery(pageContext.urlParsed.search), {
|
||||||
query: pageContext.urlParsed.search.q,
|
|
||||||
}, {
|
|
||||||
limit: 100,
|
limit: 100,
|
||||||
order: pageContext.urlParsed.search.order?.split('.') || ['likes', 'desc'],
|
order: pageContext.urlParsed.search.order?.split('.') || ['likes', 'desc'],
|
||||||
}, pageContext.user);
|
}, pageContext.user);
|
||||||
|
|||||||
@@ -396,9 +396,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
|||||||
.innerJoin('actors', 'actors.id', 'actors_stashed.actor_id')
|
.innerJoin('actors', 'actors.id', 'actors_stashed.actor_id')
|
||||||
.where('stash_id', filters.stashId);
|
.where('stash_id', filters.stashId);
|
||||||
} else {
|
} else {
|
||||||
builder
|
builder.select(knex.raw('*, weight() as _score'));
|
||||||
.select(knex.raw('*, weight() as _score'))
|
|
||||||
.where('alias_for', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filters.query) {
|
if (filters.query) {
|
||||||
@@ -409,7 +407,13 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filters.isGlobal) {
|
console.log('FILTERS', filters);
|
||||||
|
|
||||||
|
if (!filters.includeAliased) {
|
||||||
|
builder.where('alias_for', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filters.requireGlobal) {
|
||||||
builder.where('entity_id', 0);
|
builder.where('entity_id', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ export function curateActorsQuery(query) {
|
|||||||
weight: query.weight?.split(',').map((weight) => Number(weight)),
|
weight: query.weight?.split(',').map((weight) => Number(weight)),
|
||||||
requireAvatar: query.avatar,
|
requireAvatar: query.avatar,
|
||||||
stashId: Number(query.stashId) || null,
|
stashId: Number(query.stashId) || null,
|
||||||
isGlobal: !!query.global,
|
isGlobal: Object.hasOwn(query, 'global'),
|
||||||
|
includeAliased: Object.hasOwn(query, 'alias'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user