Added experimental edit page and revision history.
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
import { stringify } from '@brillout/json-serializer/stringify'; /* eslint-disable-line import/extensions */
|
||||
|
||||
import { fetchScenes, fetchScenesById } from '../scenes.js';
|
||||
import {
|
||||
fetchScenes,
|
||||
fetchScenesById,
|
||||
createSceneRevision,
|
||||
} from '../scenes.js';
|
||||
|
||||
import { parseActorIdentifier } from '../query.js';
|
||||
import { getIdsBySlug } from '../cache.js';
|
||||
import slugify from '../../utils/slugify.js';
|
||||
import { HttpError } from '../errors.js';
|
||||
import promiseProps from '../../utils/promise-props.js';
|
||||
|
||||
export async function curateScenesQuery(query) {
|
||||
@@ -197,6 +203,18 @@ export async function fetchScenesGraphql(query, req) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchSceneApi(req, res) {
|
||||
const [scene] = await fetchScenesById([Number(req.params.sceneId)], { reqUser: req.user });
|
||||
|
||||
console.log(req.params.sceneId, scene);
|
||||
|
||||
if (!scene) {
|
||||
throw new HttpError(`No scene with ID ${req.params.sceneId} found`, 404);
|
||||
}
|
||||
|
||||
res.send(scene);
|
||||
}
|
||||
|
||||
export async function fetchScenesByIdGraphql(query, req) {
|
||||
const scenes = await fetchScenesById([].concat(query.id, query.ids).filter(Boolean), {
|
||||
reqUser: req.user,
|
||||
@@ -209,3 +227,9 @@ export async function fetchScenesByIdGraphql(query, req) {
|
||||
|
||||
return scenes[0];
|
||||
}
|
||||
|
||||
export async function createSceneRevisionApi(req, res) {
|
||||
await createSceneRevision(Number(req.params.sceneId), req.body, req.user);
|
||||
|
||||
res.status(204).send();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user