Added pagination and total to revisions.
This commit is contained in:
@@ -5,8 +5,10 @@ import { computed, inject, ref } from 'vue';
|
||||
import Avatar from '#/components/edit/avatar.vue';
|
||||
import Socials from '#/components/edit/revision-socials.vue';
|
||||
import Checkbox from '#/components/form/checkbox.vue';
|
||||
import Pagination from '#/components/pagination/pagination.vue';
|
||||
|
||||
import { get, post } from '#/src/api.js';
|
||||
import navigate from '#/src/navigate.js';
|
||||
import { formatDuration } from '#/utils/format.js';
|
||||
|
||||
defineProps({
|
||||
@@ -31,10 +33,14 @@ const moviesById = computed(() => Object.fromEntries(movies.value.map((movie) =>
|
||||
const avatarsById = computed(() => Object.fromEntries(avatars.value.map((avatar) => [avatar.id, avatar])));
|
||||
|
||||
const feedbacks = ref({});
|
||||
const showReviewed = ref(false);
|
||||
const showReviewed = ref(Object.hasOwn(pageContext.urlParsed.search, 'final'));
|
||||
const reviewedRevisions = ref(new Set());
|
||||
const expanded = ref(new Set());
|
||||
|
||||
const total = ref(pageContext.pageProps.revisionTotal);
|
||||
const page = Number(pageContext.routeParams.page) || 1;
|
||||
const limit = Number(pageContext.urlParsed.search.limit) || 100;
|
||||
|
||||
const mappedKeys = {
|
||||
actors: actorsById,
|
||||
// tags: tagsById,
|
||||
@@ -163,7 +169,8 @@ const curatedRevisions = computed(() => revisions.value.map((revision) => {
|
||||
async function reloadRevisions() {
|
||||
const updatedRevisions = await get(`/revisions/${domain}`, {
|
||||
isFinalized: showReviewed.value ? undefined : false,
|
||||
limit: 50,
|
||||
page,
|
||||
limit,
|
||||
});
|
||||
|
||||
actors.value = updatedRevisions.actors;
|
||||
@@ -171,6 +178,14 @@ async function reloadRevisions() {
|
||||
movies.value = updatedRevisions.movies;
|
||||
avatars.value = updatedRevisions.avatars;
|
||||
revisions.value = updatedRevisions.revisions;
|
||||
total.value = updatedRevisions.total;
|
||||
|
||||
navigate(pageContext.urlParsed.pathname, {
|
||||
...pageContext.urlParsed.search,
|
||||
final: showReviewed.value || undefined,
|
||||
}, {
|
||||
redirect: false,
|
||||
});
|
||||
}
|
||||
|
||||
async function reviewRevision(revision, isApproved) {
|
||||
@@ -208,10 +223,12 @@ async function banEditor(revision) {
|
||||
<template>
|
||||
<div class="page">
|
||||
<div
|
||||
v-if="context === 'admin'"
|
||||
class="revs-header"
|
||||
>
|
||||
<span class="revs-total">{{ total }} revisions</span>
|
||||
|
||||
<Checkbox
|
||||
v-if="context === 'admin'"
|
||||
label="Show finalized"
|
||||
:checked="showReviewed"
|
||||
@change="(checked) => { showReviewed = checked; reloadRevisions(); }"
|
||||
@@ -388,13 +405,12 @@ async function banEditor(revision) {
|
||||
class="rev-compact"
|
||||
@click="expanded.add(rev.id)"
|
||||
>
|
||||
|
||||
<span class="rev-scene nolink noshrink"><template v-if="context !== 'scene' && context !== 'actor'">{{ rev.sceneId || rev.actorId }}</template>@{{ rev.hash.slice(0, 6) }}</span>
|
||||
|
||||
<span
|
||||
v-if="context !== 'scene'"
|
||||
class="rev-title nolink ellipsis"
|
||||
>{{ rev.base.title }}</span>
|
||||
>{{ rev.base.title || rev.base.name }}</span>
|
||||
|
||||
<span class="rev-summary">
|
||||
<span class="summary-deltas ellipsis">{{ rev.deltas.map((delta) => delta.key).join(', ') }}</span>
|
||||
@@ -431,6 +447,13 @@ async function banEditor(revision) {
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<Pagination
|
||||
v-if="total"
|
||||
:total="total"
|
||||
:page="page"
|
||||
:limit="limit"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -443,13 +466,20 @@ async function banEditor(revision) {
|
||||
|
||||
.revs-header {
|
||||
display: flex;
|
||||
margin-bottom: 1rem;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
padding: .5rem .5rem .75rem .5rem;
|
||||
width: 100%;
|
||||
|
||||
.check-container {
|
||||
display: inline-flex;
|
||||
}
|
||||
}
|
||||
|
||||
.revs-total {
|
||||
color: var(--shadow-strong-10);
|
||||
}
|
||||
|
||||
.revs {
|
||||
width: 100%;
|
||||
flex-grow: 1;
|
||||
|
||||
Reference in New Issue
Block a user