@contrail/document-generation
Advanced tools
Comparing version 2.0.12 to 2.0.13
@@ -57,2 +57,3 @@ import { DataGroupStructure } from "@contrail/data-grouping"; | ||
isHidden?: boolean; | ||
size?: SizeDefinition; | ||
} |
@@ -7,3 +7,4 @@ import { DocumentPropertyDefinition } from "../interfaces"; | ||
static generatePropertyTextElement(model: any, property: DocumentPropertyDefinition, options: DocumentElement, formatter: PropertyValueFormatter, position: PositionDefinition, isComponent?: boolean): DocumentElement; | ||
static generatePropertyAnnotationElement(data: any, property: DocumentPropertyDefinition, size: SizeDefinition, position: PositionDefinition): DocumentElement; | ||
static generatePropertyImageElement(data: any, property: DocumentPropertyDefinition, imageDimension: SizeDefinition, position: PositionDefinition): DocumentElement; | ||
} |
@@ -15,4 +15,8 @@ "use strict"; | ||
const formatter = new types_1.PropertyValueFormatter(); | ||
let index = 0; | ||
for (let property of properties) { | ||
let element; | ||
if (index === 0 && property.slug === 'annotation') { | ||
yPosition = -15; | ||
} | ||
if (property.propertyDefinition) { | ||
@@ -29,2 +33,6 @@ const fontSize = ((_b = (_a = property.style) === null || _a === void 0 ? void 0 : _a.font) === null || _b === void 0 ? void 0 : _b.size) || 12; | ||
} | ||
else if (property.slug === 'annotation') { | ||
element = DocumentPropertyUtil.generatePropertyAnnotationElement(data, property, property.size, { x: xPosition, y: yPosition }); | ||
yPosition += element.size.height - 10; | ||
} | ||
else { | ||
@@ -37,2 +45,3 @@ const imageHeight = imageDimension.height || imageDimension.width || 125; | ||
elements.push(element); | ||
index++; | ||
} | ||
@@ -63,2 +72,14 @@ return elements; | ||
} | ||
static generatePropertyAnnotationElement(data, property, size, position) { | ||
const element = { | ||
type: "annotation", | ||
size: size, | ||
propertyBindings: { annotation: 'annotation' }, | ||
position | ||
}; | ||
if (property.isHidden) { | ||
element.isHidden = property.isHidden; | ||
} | ||
return element; | ||
} | ||
static generatePropertyImageElement(data, property, imageDimension, position) { | ||
@@ -65,0 +86,0 @@ const imageUrl = util_1.ObjectUtil.getByPath(data, `viewable.mediumViewableDownloadUrl`); |
{ | ||
"name": "@contrail/document-generation", | ||
"version": "2.0.12", | ||
"version": "2.0.13", | ||
"description": "Utilities for automatic generation of documents.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
783519
1769