feat: Add date/time template options to template titles
This commit is contained in:
@@ -1,5 +1,26 @@
|
||||
import { Transaction } from "sequelize";
|
||||
import { Document, Event, User } from "@server/models";
|
||||
import DocumentHelper from "@server/models/helpers/DocumentHelper";
|
||||
|
||||
type Props = {
|
||||
id?: string;
|
||||
title: string;
|
||||
text: string;
|
||||
publish?: boolean;
|
||||
collectionId?: string;
|
||||
parentDocumentId?: string | null;
|
||||
importId?: string;
|
||||
templateDocument?: Document | null;
|
||||
publishedAt?: Date;
|
||||
template?: boolean;
|
||||
createdAt?: Date;
|
||||
updatedAt?: Date;
|
||||
user: User;
|
||||
editorVersion?: string;
|
||||
source?: "import";
|
||||
ip?: string;
|
||||
transaction: Transaction;
|
||||
};
|
||||
|
||||
export default async function documentCreator({
|
||||
title = "",
|
||||
@@ -20,25 +41,7 @@ export default async function documentCreator({
|
||||
source,
|
||||
ip,
|
||||
transaction,
|
||||
}: {
|
||||
id?: string;
|
||||
title: string;
|
||||
text: string;
|
||||
publish?: boolean;
|
||||
collectionId?: string;
|
||||
parentDocumentId?: string | null;
|
||||
importId?: string;
|
||||
templateDocument?: Document | null;
|
||||
publishedAt?: Date;
|
||||
template?: boolean;
|
||||
createdAt?: Date;
|
||||
updatedAt?: Date;
|
||||
user: User;
|
||||
editorVersion?: string;
|
||||
source?: "import";
|
||||
ip?: string;
|
||||
transaction: Transaction;
|
||||
}): Promise<Document> {
|
||||
}: Props): Promise<Document> {
|
||||
const templateId = templateDocument ? templateDocument.id : undefined;
|
||||
const document = await Document.create(
|
||||
{
|
||||
@@ -56,7 +59,9 @@ export default async function documentCreator({
|
||||
templateId,
|
||||
publishedAt,
|
||||
importId,
|
||||
title: templateDocument ? templateDocument.title : title,
|
||||
title: templateDocument
|
||||
? DocumentHelper.replaceTemplateVariables(templateDocument.title, user)
|
||||
: title,
|
||||
text: templateDocument ? templateDocument.text : text,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user