@@ -23,6 +23,10 @@ function DocumentNew() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function createDocument() {
|
async function createDocument() {
|
||||||
const params = queryString.parse(location.search);
|
const params = queryString.parse(location.search);
|
||||||
|
const parentDocumentId = params.parentDocumentId?.toString();
|
||||||
|
const parentDocument = parentDocumentId
|
||||||
|
? documents.get(parentDocumentId)
|
||||||
|
: undefined;
|
||||||
let collection;
|
let collection;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -31,7 +35,8 @@ function DocumentNew() {
|
|||||||
}
|
}
|
||||||
const document = await documents.create({
|
const document = await documents.create({
|
||||||
collectionId: collection?.id,
|
collectionId: collection?.id,
|
||||||
parentDocumentId: params.parentDocumentId?.toString(),
|
parentDocumentId,
|
||||||
|
fullWidth: parentDocument?.fullWidth,
|
||||||
templateId: params.templateId?.toString(),
|
templateId: params.templateId?.toString(),
|
||||||
template: params.template === "true" ? true : false,
|
template: params.template === "true" ? true : false,
|
||||||
title: "",
|
title: "",
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ type Props = {
|
|||||||
collectionId?: string | null;
|
collectionId?: string | null;
|
||||||
parentDocumentId?: string | null;
|
parentDocumentId?: string | null;
|
||||||
importId?: string;
|
importId?: string;
|
||||||
templateDocument?: Document | null;
|
|
||||||
publishedAt?: Date;
|
publishedAt?: Date;
|
||||||
template?: boolean;
|
template?: boolean;
|
||||||
|
templateDocument?: Document | null;
|
||||||
|
fullWidth?: boolean;
|
||||||
createdAt?: Date;
|
createdAt?: Date;
|
||||||
updatedAt?: Date;
|
updatedAt?: Date;
|
||||||
user: User;
|
user: User;
|
||||||
@@ -33,12 +34,13 @@ export default async function documentCreator({
|
|||||||
publish,
|
publish,
|
||||||
collectionId,
|
collectionId,
|
||||||
parentDocumentId,
|
parentDocumentId,
|
||||||
|
template,
|
||||||
templateDocument,
|
templateDocument,
|
||||||
|
fullWidth,
|
||||||
importId,
|
importId,
|
||||||
createdAt,
|
createdAt,
|
||||||
// allows override for import
|
// allows override for import
|
||||||
updatedAt,
|
updatedAt,
|
||||||
template,
|
|
||||||
user,
|
user,
|
||||||
editorVersion,
|
editorVersion,
|
||||||
publishedAt,
|
publishedAt,
|
||||||
@@ -76,6 +78,7 @@ export default async function documentCreator({
|
|||||||
createdById: user.id,
|
createdById: user.id,
|
||||||
template,
|
template,
|
||||||
templateId,
|
templateId,
|
||||||
|
fullWidth,
|
||||||
publishedAt,
|
publishedAt,
|
||||||
importId,
|
importId,
|
||||||
title: templateDocument
|
title: templateDocument
|
||||||
|
|||||||
@@ -1267,6 +1267,7 @@ router.post(
|
|||||||
publish,
|
publish,
|
||||||
collectionId,
|
collectionId,
|
||||||
parentDocumentId,
|
parentDocumentId,
|
||||||
|
fullWidth,
|
||||||
templateId,
|
templateId,
|
||||||
template,
|
template,
|
||||||
} = ctx.input.body;
|
} = ctx.input.body;
|
||||||
@@ -1320,6 +1321,7 @@ router.post(
|
|||||||
parentDocumentId,
|
parentDocumentId,
|
||||||
templateDocument,
|
templateDocument,
|
||||||
template,
|
template,
|
||||||
|
fullWidth,
|
||||||
user,
|
user,
|
||||||
editorVersion,
|
editorVersion,
|
||||||
ip: ctx.request.ip,
|
ip: ctx.request.ip,
|
||||||
|
|||||||
@@ -289,6 +289,9 @@ export const DocumentsCreateSchema = BaseSchema.extend({
|
|||||||
/** Create doc with this template */
|
/** Create doc with this template */
|
||||||
templateId: z.string().uuid().optional(),
|
templateId: z.string().uuid().optional(),
|
||||||
|
|
||||||
|
/** Boolean to denote if the doc should occupy full width */
|
||||||
|
fullWidth: z.boolean().optional(),
|
||||||
|
|
||||||
/** Whether to create a template doc */
|
/** Whether to create a template doc */
|
||||||
template: z.boolean().optional(),
|
template: z.boolean().optional(),
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user