idea-toolbox
Version:
IDEA's utility functions
160 lines (159 loc) • 5.43 kB
TypeScript
import { Label } from './label.model';
import { LabelVariable } from './labelVariable.model';
import { Languages } from './languages.model';
import { Resource } from './resource.model';
import { StringVariable } from './stringVariable.model';
/**
* The PDF-printable version of an entity, that contains variables and inner contextes as defined by either a
* `PDFTemplateBlueprint` or `PDFTemplateSectionBlueprint`.
*/
export declare abstract class PDFEntity extends Resource {
/**
* Either one of the two:
* - '@variableXYZ', representing an attribute of the entity.
* - '_innerContext' | '__innerCustomContext', to represent a child object that will contain itself variables
* and inner contextes.
*/
[index: string]: any;
}
/**
* The section of a multi-sections template for PDF printing of entities.
*/
export declare class PDFTemplateSection extends Resource {
/**
* The type of section.
*/
type: PDFTemplateSectionTypes;
/**
* A description to help identify the section in the template.
*/
description?: string;
/**
* Whether to show a border around the section.
*/
border?: boolean;
/**
* 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.
*/
columns?: (PDFTemplateSimpleField | PDFTemplateComplexField | string)[];
/**
* 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.
*/
title?: Label;
/**
* The context to consider for the data of a INNER_SECTION or REPEATED_INNER_SECTION (inception).
*/
context?: string;
/**
* The inner template for a INNER_SECTION or REPEATED_INNER_SECTION (inception).
*/
innerTemplate?: PDFTemplateSection[];
load(x: any, languages?: Languages): void;
validate(languages: Languages, variables?: (LabelVariable | StringVariable)[]): string[];
/**
* Check whether the section is among one of the types selected.
*/
isEither(...types: PDFTemplateSectionTypes[]): boolean;
/**
* Whether the column identified by the index is empty or not.
*/
isColumnEmpty(indexInColumns: number): boolean;
/**
* Whether the column identified by the index contains or not a field.
* It returns false in case the section isn't of type ROW.
*/
doesColumnContainAField(indexInColumns: number): boolean;
/**
* Given the index of a column containing a field, return on how many columns the field spans.
*/
getColumnFieldSize(indexInColumns: number): number;
/**
* Remove a field from the columns that it occupied before.
*/
removeFieldFromOccupiedColumns(colIndex: number): void;
}
/**
* The type of sections for a PDF template.
*/
export declare enum PDFTemplateSectionTypes {
PAGE_BREAK = 0,
BLANK_ROW = 1,
ROW = 2,
HEADER = 3,
INNER_SECTION = 4,
REPEATED_INNER_SECTION = 5
}
/**
* A simple field, with a direct reference to a variable, depending on the current section's context.
*/
export declare class PDFTemplateSimpleField extends Resource {
/**
* The field's label.
*/
label: Label;
/**
* The direct reference to a variable to substitute (e.g. `@myVar`).
* Note: the variable substitution is made on runtime data, based on the section's context.
*/
code: string;
load(x: any, languages: Languages): void;
/**
* Quickly recognize the nature of the field (simple/complex).
*/
isComplex(): boolean;
}
/**
* A complex field, with a content depending on the current section's context.
*/
export declare class PDFTemplateComplexField extends Resource {
/**
* A Label (markdown support) that may contain variables to subsitute (e.g. `Here's **@myVar**`).
* Note: the variable substitution is made on runtime data, based on the section's context.
*/
content: Label;
load(x: any, languages: Languages): void;
/**
* Quickly recognize the nature of the field (simple/complex).
*/
isComplex(): boolean;
}
/**
* It represents the blueprint that defines how the PDF template is structured, based on the project's data.
*/
export interface PDFTemplateBlueprint {
/**
* A description to identify the templates of this blueprint.
*/
description: string;
/**
* The variables available in templates of this blueprint.
*/
variables: LabelVariable[];
/**
* The blueprints of inner sections.
*/
innerBlueprints?: PDFTemplateSectionBlueprint[];
}
/**
* It represent the blueprint of an inner section of a PDF template blueprint.
*/
export interface PDFTemplateSectionBlueprint extends PDFTemplateBlueprint {
/**
* An icon to visually recognize this blueprint's sections.
*/
icon: string;
/**
* The context to access data of this blueprint's sections.
*/
context: string;
/**
* The type of this blueprint's sections.
*/
type: PDFTemplateSectionTypes;
}