patches v1.3.8 #80
3 changed files with 35 additions and 3 deletions
|
@ -6,6 +6,7 @@ import InternalException from "../exceptions/internalException";
|
||||||
import UserService from "../service/management/userService";
|
import UserService from "../service/management/userService";
|
||||||
import { BACKUP_COPIES, BACKUP_INTERVAL } from "../env.defaults";
|
import { BACKUP_COPIES, BACKUP_INTERVAL } from "../env.defaults";
|
||||||
import DatabaseActionException from "../exceptions/databaseActionException";
|
import DatabaseActionException from "../exceptions/databaseActionException";
|
||||||
|
import { availableTemplates } from "../type/templateTypes";
|
||||||
|
|
||||||
export type BackupSection =
|
export type BackupSection =
|
||||||
| "member"
|
| "member"
|
||||||
|
@ -743,11 +744,30 @@ export default abstract class BackupHelper {
|
||||||
.values(data?.["template"] ?? [])
|
.values(data?.["template"] ?? [])
|
||||||
.orIgnore()
|
.orIgnore()
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
let templates = await this.transactionManager.getRepository("template").find();
|
||||||
|
let dataWithMappedId = (data?.["template_usage"] ?? [])
|
||||||
|
.filter((d) => availableTemplates.includes(d.scope))
|
||||||
|
.map((d) => ({
|
||||||
|
...d,
|
||||||
|
headerHeightId: templates.find((template) => template.template == d.headerHeight.template)?.id ?? null,
|
||||||
|
footerHeightId: templates.find((template) => template.template == d.footerHeight.template)?.id ?? null,
|
||||||
|
headerId: templates.find((template) => template.template == d.header.template)?.id ?? null,
|
||||||
|
bodyId: templates.find((template) => template.template == d.body.template)?.id ?? null,
|
||||||
|
footerId: templates.find((template) => template.template == d.footer.template)?.id ?? null,
|
||||||
|
}));
|
||||||
|
availableTemplates.forEach((at) => {
|
||||||
|
if (!dataWithMappedId.some((d) => d.scope == at)) {
|
||||||
|
dataWithMappedId.push({
|
||||||
|
scope: at,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
await this.transactionManager
|
await this.transactionManager
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
.insert()
|
.insert()
|
||||||
.into("template_usage")
|
.into("template_usage")
|
||||||
.values(data?.["template_usage"] ?? [])
|
.values(dataWithMappedId)
|
||||||
.orIgnore()
|
.orIgnore()
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { PermissionModule } from "../type/permissionTypes";
|
||||||
import TemplateUsageService from "../service/configuration/templateUsageService";
|
import TemplateUsageService from "../service/configuration/templateUsageService";
|
||||||
import Handlebars, { template } from "handlebars";
|
import Handlebars, { template } from "handlebars";
|
||||||
import { FileSystemHelper } from "./fileSystemHelper";
|
import { FileSystemHelper } from "./fileSystemHelper";
|
||||||
|
import { TemplateFormat } from "../type/templateTypes";
|
||||||
|
|
||||||
export abstract class TemplateHelper {
|
export abstract class TemplateHelper {
|
||||||
static getTemplateFromFile(template: string) {
|
static getTemplateFromFile(template: string) {
|
||||||
|
@ -40,7 +41,7 @@ export abstract class TemplateHelper {
|
||||||
bodyData = {},
|
bodyData = {},
|
||||||
footerData = {},
|
footerData = {},
|
||||||
}: {
|
}: {
|
||||||
module: `${PermissionModule}` | `${PermissionModule}.${string}`;
|
module: TemplateFormat;
|
||||||
title?: string;
|
title?: string;
|
||||||
headerData?: any;
|
headerData?: any;
|
||||||
bodyData?: any;
|
bodyData?: any;
|
||||||
|
@ -88,7 +89,7 @@ export abstract class TemplateHelper {
|
||||||
footerData = {},
|
footerData = {},
|
||||||
customTemplate,
|
customTemplate,
|
||||||
}: {
|
}: {
|
||||||
module: `${PermissionModule}` | `${PermissionModule}.${string}`;
|
module: TemplateFormat;
|
||||||
title?: string;
|
title?: string;
|
||||||
headerData?: any;
|
headerData?: any;
|
||||||
bodyData?: any;
|
bodyData?: any;
|
||||||
|
|
11
src/type/templateTypes.ts
Normal file
11
src/type/templateTypes.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { PermissionModule } from "./permissionTypes";
|
||||||
|
|
||||||
|
export type TemplateFormat = `${PermissionModule}` | `${PermissionModule}.${string}`;
|
||||||
|
|
||||||
|
export const availableTemplates: Array<TemplateFormat> = [
|
||||||
|
"member",
|
||||||
|
"listprint",
|
||||||
|
"listprint.member",
|
||||||
|
"newsletter",
|
||||||
|
"protocol",
|
||||||
|
];
|
Loading…
Add table
Reference in a new issue