@contrail/document-generation
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -79,6 +79,4 @@ "use strict"; | ||
static generateGroupHeading(dataGroup, template, position, span) { | ||
console.log("generateGroupHeading: ", dataGroup.name, span); | ||
const elements = []; | ||
const heading = documents_1.DocumentElementFactory.createTextElement("Placeholder", {}); | ||
console.log("template.frameGroupHeaderTemplate.size.height: ", template.frameGroupHeaderTemplate.size.height); | ||
heading.style = { border: { width: 1, color: "rgba(0,0,0,0)" }, color: "#000000", backgroundColor: template.frameGroupHeaderTemplate.style.backgroundColor || 'black' }; | ||
@@ -85,0 +83,0 @@ heading.text = `<p><span style=\"font-size: ${template.frameGroupHeaderTemplate.style.font.size}pt;\"><strong><span style=\"color: ${template.frameGroupHeaderTemplate.style.color};\">${dataGroup.name}</span></strong></span></p>`; |
@@ -5,4 +5,5 @@ "use strict"; | ||
const documents_1 = require("@contrail/documents"); | ||
const component_grid_generator_1 = require("./component-grid-generator"); | ||
const component_grid_generator_1 = require("./components/component-grid-generator"); | ||
const util_1 = require("@contrail/util"); | ||
const document_util_1 = require("./util/document-util"); | ||
class FrameGenerator { | ||
@@ -25,7 +26,11 @@ static generateFrameForDataGroup(dataGroup, framePosition, template) { | ||
gridPosition.y = gridPosition.y + frameHeaderDimensions.height + HEADER_MARGIN; | ||
const componentGridPosition = util_1.ObjectUtil.cloneDeep(gridPosition); | ||
const componentGridSize = template.frameSize; | ||
const relativeGridPosition = document_util_1.DocumentUtil.getRelativePosition(framePosition, gridPosition); | ||
const frameSize = template.frameSize; | ||
const idealGridSize = { | ||
width: frameSize.width - relativeGridPosition.x - FRAME_PADDING, | ||
height: frameSize.height - relativeGridPosition.y - FRAME_PADDING | ||
}; | ||
elements.push(util_1.ObjectUtil.cloneDeep(frame)); | ||
elements.push(...this.generateFrameHeaderForDataGroup(dataGroup, headerPosition, template, frameHeaderDimensions)); | ||
elements.push(...component_grid_generator_1.ComponentGridGenerator.generateComponentGrid(dataGroup.data, componentGridPosition, template.componentGridTemplate, componentGridSize)); | ||
elements.push(...component_grid_generator_1.ComponentGridGenerator.generateComponentGrid(dataGroup.data, gridPosition, template.componentGridTemplate, idealGridSize)); | ||
return elements; | ||
@@ -32,0 +37,0 @@ } |
import { DataGroupStructure } from "@contrail/data-grouping"; | ||
import { PositionDefinition, SizeDefinition, Document, DocumentElement } from "@contrail/documents"; | ||
import { PositionDefinition, SizeDefinition, DocumentElement, StyleDefinition } from "@contrail/documents"; | ||
import { TypeProperty } from "@contrail/types"; | ||
export declare enum Orientation { | ||
@@ -25,2 +26,3 @@ HORIZONTAL = "horizontal", | ||
componentTemplate: ComponentTemplate; | ||
componentPadding?: number; | ||
gridDimensions: { | ||
@@ -32,3 +34,16 @@ rows: number; | ||
export interface ComponentTemplate { | ||
templateDocument: Document; | ||
propertyTemplate?: ComponentPropertyTemplate; | ||
} | ||
export interface ComponentPropertyTemplate { | ||
imageDimension?: SizeDefinition; | ||
imageLocation?: 'top' | 'right' | 'left' | 'bottom'; | ||
textHorizontalAlignment?: 'center' | 'right' | 'left'; | ||
properties: Array<ComponentPropertyDefinition>; | ||
} | ||
export interface ComponentPropertyDefinition { | ||
style?: StyleDefinition; | ||
propertyDefinition: TypeProperty; | ||
slug: string; | ||
typeRootSlug: string; | ||
includeLabel?: boolean; | ||
} |
@@ -13,3 +13,3 @@ "use strict"; | ||
const document_generator_1 = require("../document-generator"); | ||
const test_data_1 = require("../test-data"); | ||
const interfaces_1 = require("../interfaces"); | ||
const sdk_1 = require("@contrail/sdk"); | ||
@@ -22,10 +22,103 @@ const fs = require("fs"); | ||
const generator = new document_generator_1.DocumentGenerator(); | ||
const orgSlug = 'new-balance-prod'; | ||
const orgSlug = 'converse-prod'; | ||
yield loginSDK(orgSlug); | ||
const assortmentId = 'OBZc68qwHM0Xsw4k'; | ||
const documentTemplateDefinition = test_data_1.VERTICAL_DOCUMENT_TEMPLATE; | ||
const assortmentId = 'Z7nTOauGtuuiU9UC'; | ||
const itemType = yield new sdk_1.Types().getType({ path: 'item' }); | ||
const projectItemType = yield new sdk_1.Types().getType({ path: 'project-item' }); | ||
const PROPERTY_COMPONENT_TEMPLATE = { | ||
imageDimension: { width: 600 }, | ||
imageLocation: 'top', | ||
textHorizontalAlignment: 'center', | ||
properties: [{ | ||
propertyDefinition: itemType.typeProperties.find(p => p.slug === 'name'), | ||
typeRootSlug: 'item', | ||
slug: "name", | ||
style: { | ||
font: { | ||
size: 14, | ||
weight: 'bold', | ||
}, | ||
color: 'rgba(0,0,0,.5)', | ||
} | ||
}, { | ||
propertyDefinition: itemType.typeProperties.find(p => p.slug === 'optionName'), | ||
typeRootSlug: 'item', | ||
slug: "optionName", | ||
style: { | ||
font: { | ||
size: 10, | ||
weight: 'bold', | ||
}, | ||
color: 'green', | ||
} | ||
}, { | ||
propertyDefinition: itemType.typeProperties.find(p => p.slug === 'category'), | ||
typeRootSlug: 'item', | ||
slug: "category", | ||
includeLabel: true, | ||
}, { | ||
propertyDefinition: itemType.typeProperties.find(p => p.slug === 'designTheme'), | ||
typeRootSlug: 'item', | ||
slug: "designTheme", | ||
includeLabel: true, | ||
}, { | ||
propertyDefinition: itemType.typeProperties.find(p => p.slug === 'baseStyleNumber'), | ||
typeRootSlug: 'item', | ||
slug: "baseStyleNumber", | ||
}, { | ||
propertyDefinition: itemType.typeProperties.find(p => p.slug === 'closureType'), | ||
typeRootSlug: 'item', | ||
slug: "closureType", | ||
includeLabel: true, | ||
}, { | ||
propertyDefinition: itemType.typeProperties.find(p => p.slug === 'colorFamily'), | ||
typeRootSlug: 'item', | ||
slug: "colorFamily", | ||
includeLabel: true, | ||
}, { | ||
propertyDefinition: projectItemType.typeProperties.find(p => p.slug === 'colorwayStatus'), | ||
slug: "colorwayStatus", | ||
typeRootSlug: 'project-item', | ||
includeLabel: true, | ||
}] | ||
}; | ||
const documentTemplateDefinition = { | ||
frameOrientation: interfaces_1.Orientation.VERTICAL, | ||
frameSize: { width: 1200, height: 675 }, | ||
framePadding: 30, | ||
frameHeaderTemplate: { | ||
style: { | ||
color: '#000000', | ||
font: { | ||
size: 20 | ||
}, | ||
backgroundColor: '#FFFFFF', | ||
}, | ||
size: { | ||
height: 60, | ||
} | ||
}, | ||
frameGroupHeaderTemplate: { | ||
style: { | ||
color: '#ffffff', | ||
font: { | ||
size: 20 | ||
}, | ||
backgroundColor: 'black', | ||
}, | ||
size: { | ||
height: 60, | ||
} | ||
}, | ||
componentGridTemplate: { | ||
gridDimensions: { cols: 8, rows: 2 }, | ||
componentPadding: 5, | ||
componentTemplate: { | ||
propertyTemplate: PROPERTY_COMPONENT_TEMPLATE | ||
} | ||
} | ||
}; | ||
const groupingProperties = [ | ||
{ | ||
property: itemType.typeProperties.find(p => p.slug === 'modelSeries'), | ||
property: itemType.typeProperties.find(p => p.slug === 'designPack'), | ||
scope: 'item', | ||
@@ -35,8 +128,14 @@ sort: sdk_1.SortOrderOptions.ASC, | ||
}, { | ||
property: itemType.typeProperties.find(p => p.slug === 'gender'), | ||
property: itemType.typeProperties.find(p => p.slug === 'category'), | ||
scope: 'item', | ||
sort: sdk_1.SortOrderOptions.ASC, | ||
values: null, | ||
}, { | ||
property: itemType.typeProperties.find(p => p.slug === 'class'), | ||
scope: 'item', | ||
sort: sdk_1.SortOrderOptions.ASC, | ||
values: null, | ||
}, | ||
]; | ||
documentTemplateDefinition.componentGridTemplate.componentTemplate.propertyTemplate = PROPERTY_COMPONENT_TEMPLATE; | ||
const dataGroup = yield getDataGroupStructure(assortmentId, groupingProperties, documentTemplateDefinition); | ||
@@ -43,0 +142,0 @@ const params = { |
import { DataGroupStructure } from "@contrail/data-grouping"; | ||
import { ComponentGridTemplate, DocumentTemplate } from "./interfaces"; | ||
import { Document } from '@contrail/documents'; | ||
export declare const TEST_ITEM_MODEL: { | ||
@@ -71,5 +70,4 @@ item: { | ||
export declare const TEST_TWO_LEVEL_ROOT_GROUP: DataGroupStructure; | ||
export declare const ITEM_COMPONENT_TEMPLATE: Document; | ||
export declare const COMPONENT_GRID_TEMPLATE: ComponentGridTemplate; | ||
export declare const HORIZONTAL_DOCUMENT_TEMPLATE: DocumentTemplate; | ||
export declare const VERTICAL_DOCUMENT_TEMPLATE: DocumentTemplate; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERTICAL_DOCUMENT_TEMPLATE = exports.HORIZONTAL_DOCUMENT_TEMPLATE = exports.COMPONENT_GRID_TEMPLATE = exports.ITEM_COMPONENT_TEMPLATE = exports.TEST_TWO_LEVEL_ROOT_GROUP = exports.TEST_ROOT_GROUP = exports.TEST_GROUP_2 = exports.TEST_GROUP = exports.TEST_ITEM_MODEL = void 0; | ||
exports.VERTICAL_DOCUMENT_TEMPLATE = exports.HORIZONTAL_DOCUMENT_TEMPLATE = exports.COMPONENT_GRID_TEMPLATE = exports.TEST_TWO_LEVEL_ROOT_GROUP = exports.TEST_ROOT_GROUP = exports.TEST_GROUP_2 = exports.TEST_GROUP = exports.TEST_ITEM_MODEL = void 0; | ||
const types_1 = require("@contrail/types"); | ||
@@ -107,47 +107,11 @@ const interfaces_1 = require("./interfaces"); | ||
}; | ||
exports.ITEM_COMPONENT_TEMPLATE = { | ||
elements: [{ | ||
type: "image", | ||
size: { width: 125, height: 125 }, | ||
propertyBindings: { url: 'viewable.mediumViewableDownloadUrl' } | ||
}, { | ||
type: "text", | ||
position: { x: 0, y: 126 }, | ||
size: { height: 25, width: 125 }, | ||
style: { | ||
font: { | ||
size: 8, | ||
} | ||
}, | ||
propertyBindings: { text: 'item.name' } | ||
}, { | ||
type: "text", | ||
position: { x: 0, y: 151 }, | ||
size: { height: 25, width: 125 }, | ||
style: { | ||
font: { | ||
size: 8, | ||
}, | ||
color: 'rgba(0,0,0,.5)', | ||
}, | ||
propertyBindings: { text: 'item.optionName' } | ||
}, { | ||
type: "text", | ||
position: { x: 0, y: 151 }, | ||
size: { height: 25, width: 125 }, | ||
style: { | ||
font: { | ||
size: 8, | ||
}, | ||
color: 'rgba(0,0,0,.5)', | ||
}, | ||
propertyBindings: { text: 'item.gender' } | ||
}, | ||
] | ||
}; | ||
exports.COMPONENT_GRID_TEMPLATE = { | ||
gridDimensions: { cols: 7, rows: 3 }, | ||
componentTemplate: { | ||
templateDocument: exports.ITEM_COMPONENT_TEMPLATE | ||
} | ||
propertyTemplate: { | ||
properties: [], | ||
imageLocation: 'top', | ||
} | ||
}, | ||
componentPadding: 20 | ||
}; | ||
@@ -154,0 +118,0 @@ exports.HORIZONTAL_DOCUMENT_TEMPLATE = { |
{ | ||
"name": "@contrail/document-generation", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Utilities for automatic generation of documents.", | ||
@@ -45,7 +45,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@contrail/data-grouping": "^1.0.11", | ||
"@contrail/data-grouping": "^1.0.13", | ||
"@contrail/documents": "^1.0.44", | ||
"@contrail/types": "^3.0.27", | ||
"@contrail/util": "^1.0.26" | ||
"@contrail/util": "^1.0.27" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1088941
23
976
2
+ Added@contrail/data-grouping@1.0.34(transitive)
+ Added@contrail/types@3.0.82(transitive)
- Removed@contrail/data-grouping@1.0.39(transitive)
- Removed@contrail/types@3.0.83(transitive)
Updated@contrail/util@^1.0.27