Class PDFTemplateSection

The section of a multi-sections template for PDF printing of entities.

Hierarchy

Constructors

  • Object initialization, setting all the default values.

    Parameters

    • Optional newData: any

      the data to load, optional

    • Optional options: any

      custom 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);
      // ...

    Returns PDFTemplateSection

Properties

border?: boolean

Whether to show a border around the section.

The content of the 12 columns of a ROW section. Each element of the array may contain:

  • A PDFTemplateSimpleField or PDFTemplateSimpleField;
  • -, to indicate that the field in the previous column span over the represented column;
  • null, to indicate a blank column.
context?: string

The context to consider for the data of a INNER_SECTION or REPEATED_INNER_SECTION (inception).

description?: string

A description to help identify the section in the template.

innerTemplate?: PDFTemplateSection[]

The inner template for a INNER_SECTION or REPEATED_INNER_SECTION (inception).

title?: Label

The 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.

Methods

  • Return an attribute in a cleaned standard that force-cast the element.

    Parameters

    • origin: any

      the origin attribute, to cast

    • castFunction: ((x) => any)

      the cast function, e.g. Boolean, Number, String, x => new CustomClass(x), etc.

        • (x): any
        • Parameters

          • x: any

          Returns any

    • Optional defaultVal: any

      if set, the fallback value instead of null

    Returns any

    cleaned attribute

  • Return an array in a cleaned standard that force-cast each element, keeping only the valid ones.

    Parameters

    • origin: any[]

      the origin array, to cast and check

    • castFunction: ((x) => any)

      the cast function, e.g. x => String(x) or x => new CustomClass(x)

        • (x): any
        • Parameters

          • x: any

          Returns any

    • Optional defaultVal: any

      if set, the fallback value instead of null

    Returns any[]

    cleaned array

  • Whether the column identified by the index contains or not a field. It returns false in case the section isn't of type ROW.

    Parameters

    • indexInColumns: number

    Returns boolean

  • Given the index of a column containing a field, return on how many columns the field spans.

    Parameters

    • indexInColumns: number

    Returns number

  • Whether the column identified by the index is empty or not.

    Parameters

    • indexInColumns: number

    Returns boolean

  • Load the attributes from an already existing resource.

    Parameters

    • x: any

      the data to load

    • Optional languages: Languages

      custom options to apply; they will depend on the child resource

      Typical implementation:

      super.load(newData);
      this.attr = this.clean(newData.attr, String);
      this.attr2 = this.clean(newData.attr2, Number, 0);
      this.attr3 = this.clean(newData.attr3, a => new Date(a), Date.now());
      this.arr = this.cleanArray(arr, String);
      // ...

    Returns void

  • Remove a field from the columns that it occupied before.

    Parameters

    • colIndex: number

    Returns void

  • Load 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.

    Parameters

    • newData: any

      the data to load

    • safeData: any

      the attributes to force to specific values

    • Optional options: any

      custom 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.

    Returns void

  • Valide the object's attributes, performing all the checkings.

    Parameters

    Returns string[]

    errors if empty, the checkings are successfully passed.

    Typical implementation:

    const e = super.validate();
    if(this.iE(this.attr)) e.push(`attr`);
    // ...
    return e;

Generated using TypeDoc