blob: 95f0da43de4801ebc21b9fc5c3e3a35f40e5bcef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import { Col } from "./DocCreatorMenu";
import { FieldSettings } from "./FieldTypes/Field";
import { Template } from "./Template";
import { TemplateLayouts } from "./TemplateBackend";
export class TemplateManager {
templates: Template[] = [];
constructor(templateSettings: FieldSettings[]) {
this.templates = this.initializeTemplates(templateSettings);
}
initializeTemplates = (templateSettings: FieldSettings[]): Template[] => {
const initializedTemplates: Template[] = [];
templateSettings.forEach(settings => initializedTemplates.push(new Template(settings)));
return initializedTemplates;
}
getValidTemplates = (cols: Col[]): Template[] => {
return this.templates.filter(template => template.isValidTemplate(cols));
}
addTemplate = (newTemplate: Template) =>{
this.templates.push(newTemplate);
}
removeTemplate = (template: Template) => {
this.templates.splice(this.templates.indexOf(template), 1);
}
}
|