Added new actor dialog to admin panel, removed create mode from actor edit page.
This commit is contained in:
@@ -373,8 +373,6 @@ import {
|
||||
post,
|
||||
} from '#/src/api.js';
|
||||
|
||||
import events from '#/src/events.js';
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
|
||||
const user = pageContext.user;
|
||||
@@ -642,48 +640,7 @@ const groupMap = {
|
||||
weight: 'size',
|
||||
};
|
||||
|
||||
async function submitCreate() {
|
||||
submitting.value = true;
|
||||
|
||||
try {
|
||||
const newActor = {
|
||||
actor: Object.fromEntries(Array.from(['name', 'gender']).flatMap((key) => {
|
||||
if (!edits.value[key]) {
|
||||
throw new Error(`Missing ${key}`);
|
||||
}
|
||||
|
||||
if (edits.value[key] && typeof edits.value[key] === 'object' && !Array.isArray(edits.value[key])) {
|
||||
return Object.entries(edits.value[key]).map(([valueKey, value]) => [keyMap[key]?.[valueKey] || valueKey, value]);
|
||||
}
|
||||
|
||||
return [[key, edits.value[key]]];
|
||||
})),
|
||||
comment: comment.value,
|
||||
};
|
||||
|
||||
const { actor: createdActor } = await post('/actors', newActor, {
|
||||
successFeedback: 'Actor has been added.',
|
||||
appendErrorMessage: true,
|
||||
});
|
||||
|
||||
actor.value = createdActor;
|
||||
} catch (error) {
|
||||
events.emit('feedback', {
|
||||
type: 'error',
|
||||
message: error.message,
|
||||
});
|
||||
}
|
||||
|
||||
submitting.value = false;
|
||||
submitted.value = true;
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!actor.value) {
|
||||
submitCreate();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
submitting.value = true;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// import { redirect } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
||||
import { match } from 'path-to-regexp';
|
||||
|
||||
const path = '/actor/(edit|new)/:actorId?/:actorSlug?';
|
||||
const path = '/actor/edit/:actorId/:actorSlug?';
|
||||
const urlMatch = match(path, { decode: decodeURIComponent });
|
||||
|
||||
export default (pageContext) => {
|
||||
|
||||
Reference in New Issue
Block a user