template duplication
This commit is contained in:
parent
6cb8ca0a12
commit
71480ecc97
2 changed files with 38 additions and 0 deletions
|
@ -48,6 +48,35 @@ export async function createTemplate(req: Request, res: Response): Promise<any>
|
|||
res.status(200).send(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description clone template
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function cloneTemplate(req: Request, res: Response): Promise<any> {
|
||||
const cloneId = req.body.cloneId;
|
||||
|
||||
const { template, description, design, html } = await TemplateService.getById(cloneId);
|
||||
|
||||
let createTemplate: CreateTemplateCommand = {
|
||||
template: "",
|
||||
description: "",
|
||||
};
|
||||
let id = await TemplateCommandHandler.create(createTemplate);
|
||||
|
||||
let updateTemplate: UpdateTemplateCommand = {
|
||||
id: id,
|
||||
template: template + " - Kopie",
|
||||
description: description,
|
||||
design: design,
|
||||
html: html,
|
||||
};
|
||||
await TemplateCommandHandler.update(updateTemplate);
|
||||
|
||||
res.status(200).send(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description update template
|
||||
* @param req {Request} Express req object
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import express, { Request, Response } from "express";
|
||||
import {
|
||||
cloneTemplate,
|
||||
createTemplate,
|
||||
deleteTemplate,
|
||||
getAllTemplates,
|
||||
|
@ -26,6 +27,14 @@ router.post(
|
|||
}
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/clone",
|
||||
PermissionHelper.passCheckMiddleware("create", "settings", "template"),
|
||||
async (req: Request, res: Response) => {
|
||||
await cloneTemplate(req, res);
|
||||
}
|
||||
);
|
||||
|
||||
router.patch(
|
||||
"/:id",
|
||||
PermissionHelper.passCheckMiddleware("update", "settings", "template"),
|
||||
|
|
Loading…
Reference in a new issue