Object initialization, setting all the default values.
Optional
newData: anythe data to load, optional
Optional
options: anycustom options to apply; they will depend on the child resource
Usually, there is no need to implement the constructor; implicitly, it will call the load
of the child resource
and therefore loading all the resources with default values.
If needed, this is the suggested implementation:
super();
this.load(x);
// ...
Optional
borderWhether to show a border around the section.
Optional
columnsThe content of the 12 columns of a ROW section. Each element of the array may contain:
PDFTemplateSimpleField
or PDFTemplateSimpleField
;-
, to indicate that the field in the previous column span over the represented column;Optional
contextThe context to consider for the data of a INNER_SECTION or REPEATED_INNER_SECTION (inception).
Optional
descriptionA description to help identify the section in the template.
Optional
innerThe inner template for a INNER_SECTION or REPEATED_INNER_SECTION (inception).
Optional
titleThe title of a HEADER section or INNER_SECTION (or REPATED_INNER_SECTION).
It's a Label (markdown) supporting variables substitution (e.g. Here's **@myVar**
).
Note: the var substitution is made on runtime data, based on the section's context.
The type of section.
Return an attribute in a cleaned standard that force-cast the element.
the origin attribute, to cast
the cast function, e.g. Boolean
, Number
, String
, x => new CustomClass(x)
, etc.
Optional
defaultVal: anyif set, the fallback value instead of null
cleaned attribute
Return an array in a cleaned standard that force-cast each element, keeping only the valid ones.
the origin array, to cast and check
the cast function, e.g. x => String(x)
or x => new CustomClass(x)
Optional
defaultVal: anyif set, the fallback value instead of null
cleaned array
Shortcut to Utils.isEmpty to check the emptiness of a field.
Optional
type: isEmptyFieldTypesCheck whether the section is among one of the types selected.
Rest
...types: PDFTemplateSectionTypes[]Load the attributes from an already existing resource.
Optional
languages: LanguagesLoad the attributes from an already existing resource and then force some attributes to assume safeData values. The function is usually used in the back-end to mix together db data with new data, without the risk of changing ids and other attributes which are managed in appositely curated scenario.
the data to load
the attributes to force to specific values
Optional
options: anycustom options to apply; they will depend on the child resource
Typical implementation:
super.safeLoad(newData, safeData);
this.keyAttr = safeData.keyAttr;
this.importantAttr = safeData.importantAttr;
this.isDraft = safeData.isDraft;
// ...
Note well: there is no need to call this.load()
, since it's implicitly called from super.safeLoad()
,
which will anyway use the child version of the method.
Valide the object's attributes, performing all the checkings.
Optional
variables: (LabelVariable | StringVariable)[]errors if empty, the checkings are successfully passed.
Typical implementation:
const e = super.validate();
if(this.iE(this.attr)) e.push(`attr`);
// ...
return e;
The section of a multi-sections template for PDF printing of entities.