template improvements & handlebars helpers
This commit is contained in:
parent
de5e4afffb
commit
14957c2abc
3 changed files with 41 additions and 16 deletions
|
@ -138,12 +138,7 @@ export async function getMemberPrintoutById(req: Request, res: Response): Promis
|
|||
template: "member",
|
||||
saveToDisk: false,
|
||||
data: {
|
||||
today: new Date().toLocaleDateString("de-DE", {
|
||||
weekday: "long",
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
}),
|
||||
today: new Date(),
|
||||
member,
|
||||
memberships,
|
||||
awards,
|
||||
|
|
|
@ -4,6 +4,33 @@ import TemplateUsageService from "../service/configuration/templateUsageService"
|
|||
import Handlebars, { template } from "handlebars";
|
||||
import { FileSystemHelper } from "./fileSystemHelper";
|
||||
|
||||
Handlebars.registerHelper("date", function (aString) {
|
||||
return new Date(aString).toLocaleDateString("de-DE", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("longdate", function (aString) {
|
||||
return new Date(aString).toLocaleDateString("de-DE", {
|
||||
weekday: "long",
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("datetime", function (aString) {
|
||||
return new Date(aString).toLocaleDateString("de-DE", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
});
|
||||
|
||||
export abstract class TemplateHelper {
|
||||
static getTemplateFromFile(template: string) {
|
||||
return FileSystemHelper.readTemplateFile(`/src/templates/${template}.template.html`);
|
||||
|
|
|
@ -6,33 +6,36 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
{{member.salutation.salutation}} {{member.lastname}} {{member.firstname}}{{#if member.nameaffix}} -
|
||||
{{member.salutation.salutation}} {{member.lastname}}, {{member.firstname}}{{#if member.nameaffix}} -
|
||||
{{member.nameaffix}}{{/if}}
|
||||
</h1>
|
||||
<p>Mitglieds-Ausdruck Stand {{today}}</p>
|
||||
<p>Mitglieds-Ausdruck Stand {{longdate today}}</p>
|
||||
<br />
|
||||
|
||||
<p>geboren: {{member.birthdate}}</p>
|
||||
<p>eingetreten: {{member.firstMembershipEntry.start}}</p>
|
||||
<p>geboren: {{date member.birthdate}}</p>
|
||||
<p>eingetreten: {{date member.firstMembershipEntry.start}}</p>
|
||||
{{#if member.lastMembershipEntry?.end}}
|
||||
<p>ausgetreten: {{member.lastMembershipEntry.end}}</p>
|
||||
<p>ausgetreten: {{date member.lastMembershipEntry.end}}</p>
|
||||
{{/if}} {{#if memberships.length}}
|
||||
<br />
|
||||
<h2>Mitgliedschaften</h2>
|
||||
{{#each memberships}}
|
||||
<div>
|
||||
<h3>{{this.status.status}}: {{this.start}} - {{#if this.end}}{{this.end}}{{else}}heute{{/if}}</h3>
|
||||
<h3>{{this.status.status}}: {{date this.start}} bis {{#if this.end}}{{date this.end}}{{else}}heute{{/if}}</h3>
|
||||
{{#if this.terminationReason}}
|
||||
<p>beendet, weil:{{this.terminationReason}}</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
<br />
|
||||
{{/each}} {{/if}} {{#if memberships.length}}
|
||||
{{/each}} {{/if}} {{#if positions.length}}
|
||||
<br />
|
||||
<h2>Vereinsämter</h2>
|
||||
{{#each positions}}
|
||||
<div>
|
||||
<h3>{{this.executivePosition.position}}: {{this.start}} - {{#if this.end}}{{this.end}}{{else}}heute{{/if}}</h3>
|
||||
<h3>
|
||||
{{this.executivePosition.position}}: {{date this.start}} bis {{#if this.end}}{{date
|
||||
this.end}}{{else}}heute{{/if}}
|
||||
</h3>
|
||||
{{#if this.note}}
|
||||
<p>Notiz: {{this.note}}</p>
|
||||
{{/if}}
|
||||
|
@ -43,7 +46,7 @@
|
|||
<h2>Auszeichnungen</h2>
|
||||
{{#each awards}}
|
||||
<div>
|
||||
<h3>{{this.award.award}}: {{this.date}}</h3>
|
||||
<h3>{{this.award.award}}: {{date this.date}}</h3>
|
||||
{{#if this.given}}
|
||||
<p>wurde vergeben</p>
|
||||
{{else}}
|
||||
|
@ -58,7 +61,7 @@
|
|||
<h2>Qualifikationen</h2>
|
||||
{{#each qualifications}}
|
||||
<div>
|
||||
<h3>{{this.qualification.qualification}}: {{this.date}}</h3>
|
||||
<h3>{{this.qualification.qualification}}: {{date this.date}}</h3>
|
||||
{{#if this.terminationReason}}
|
||||
<p>beendet, weil:{{this.terminationReason}}</p>
|
||||
{{/if}} {{#if this.note}}
|
||||
|
|
Loading…
Add table
Reference in a new issue