@contrail/document-generation 2.1.14 → 2.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,7 +11,7 @@ class BoardDocumentGenerator {
|
|
|
11
11
|
constructor() { }
|
|
12
12
|
static generateDocumentElements(options, typeMap) {
|
|
13
13
|
if (typeMap && document_dynamic_text_element_util_1.DocumentDynamicTextElementUtil.typeMap === undefined) {
|
|
14
|
-
document_dynamic_text_element_util_1.DocumentDynamicTextElementUtil.typeMap
|
|
14
|
+
document_dynamic_text_element_util_1.DocumentDynamicTextElementUtil.setTypeMap(typeMap);
|
|
15
15
|
}
|
|
16
16
|
const elements = [];
|
|
17
17
|
const structure = options.data.dataGroup;
|
|
@@ -134,7 +134,7 @@ class BoardDocumentGenerator {
|
|
|
134
134
|
static findDeepestSubgroups(group, subgroups, totalDepth, currentDepth, stopAtSecondary) {
|
|
135
135
|
if (currentDepth === totalDepth && group.subGroups.length > 0) {
|
|
136
136
|
if (!group.isSecondaryGroup &&
|
|
137
|
-
group.subGroups.filter(
|
|
137
|
+
group.subGroups.filter(subgroup => subgroup.name === group.subGroups[0].name).length > 1) {
|
|
138
138
|
subgroups.push(group.subGroups[0]);
|
|
139
139
|
}
|
|
140
140
|
else {
|
|
@@ -2,6 +2,8 @@ import { DataGroup } from '@contrail/data-grouping';
|
|
|
2
2
|
import { DocumentElement } from '@contrail/documents';
|
|
3
3
|
export declare class DocumentDynamicTextElementUtil {
|
|
4
4
|
static typeMap: any;
|
|
5
|
+
static propertyMapByType: any;
|
|
5
6
|
static isDynamicText(element: any): any;
|
|
6
7
|
static handleDynamicText(element: DocumentElement, dataGroup: DataGroup, frameTitle?: any): void;
|
|
8
|
+
static setTypeMap(typeMap: any): void;
|
|
7
9
|
}
|
|
@@ -2,29 +2,61 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DocumentDynamicTextElementUtil = void 0;
|
|
4
4
|
const documents_1 = require("@contrail/documents");
|
|
5
|
+
const types_1 = require("@contrail/types");
|
|
5
6
|
const document_text_element_util_1 = require("./document-text-element-util");
|
|
6
7
|
class DocumentDynamicTextElementUtil {
|
|
7
8
|
static isDynamicText(element) {
|
|
8
9
|
return element.type === 'text' && element.propertyBindings && element.propertyBindingsMetaData;
|
|
9
10
|
}
|
|
10
11
|
static handleDynamicText(element, dataGroup, frameTitle = null) {
|
|
11
|
-
var _a;
|
|
12
|
+
var _a, _b, _c;
|
|
12
13
|
const propertyBindingsText = element.propertyBindings.text;
|
|
14
|
+
let propertyLevel = (_a = element.propertyBindingsMetaData) === null || _a === void 0 ? void 0 : _a.propertyLevel;
|
|
15
|
+
let property = null;
|
|
16
|
+
let componentModels = dataGroup.data;
|
|
13
17
|
const frame = {
|
|
14
18
|
name: frameTitle || dataGroup.name,
|
|
15
19
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
if (propertyBindingsText) {
|
|
21
|
+
const [entityType, propertySlug] = propertyBindingsText === null || propertyBindingsText === void 0 ? void 0 : propertyBindingsText.split('.');
|
|
22
|
+
property = (_b = this.propertyMapByType[entityType]) === null || _b === void 0 ? void 0 : _b.properties[propertySlug];
|
|
23
|
+
if (!propertyLevel &&
|
|
24
|
+
(property === null || property === void 0 ? void 0 : property.propertyLevel) &&
|
|
25
|
+
[types_1.PropertyLevel.OPTION, types_1.PropertyLevel.FAMILY].includes(property.propertyLevel)) {
|
|
26
|
+
propertyLevel = property.propertyLevel;
|
|
27
|
+
}
|
|
28
|
+
if (propertyLevel && propertyLevel === types_1.PropertyLevel.FAMILY) {
|
|
29
|
+
componentModels = JSON.parse(JSON.stringify(dataGroup.data));
|
|
30
|
+
componentModels.forEach(d => {
|
|
31
|
+
var _a;
|
|
32
|
+
const entity = d[entityType];
|
|
33
|
+
if (entity && ['item', 'project-item'].includes(entity.entityType) && ((_a = entity.roles) === null || _a === void 0 ? void 0 : _a.includes('option'))) {
|
|
34
|
+
if (entity.itemFamily) {
|
|
35
|
+
d[entityType] = entity.itemFamily;
|
|
36
|
+
}
|
|
37
|
+
else if (entity.familyProjectItem) {
|
|
38
|
+
d[entityType] = entity.familyProjectItem;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
21
43
|
}
|
|
22
|
-
let text = documents_1.DynamicTextUtil.getDynamicTextValue(element, property, frame,
|
|
23
|
-
if (((
|
|
44
|
+
let text = documents_1.DynamicTextUtil.getDynamicTextValue(element, property, propertyLevel, frame, componentModels);
|
|
45
|
+
if (((_c = element.text) === null || _c === void 0 ? void 0 : _c.toString().indexOf('</')) > -1) {
|
|
24
46
|
const styleDefinition = document_text_element_util_1.DocumentTextElementUtil.extractStyleFromInline(element.text);
|
|
25
47
|
text = document_text_element_util_1.DocumentTextElementUtil.applyInLineStyling(text, styleDefinition);
|
|
26
48
|
}
|
|
27
49
|
element.text = text;
|
|
28
50
|
}
|
|
51
|
+
static setTypeMap(typeMap) {
|
|
52
|
+
DocumentDynamicTextElementUtil.typeMap = typeMap;
|
|
53
|
+
Object.keys(DocumentDynamicTextElementUtil.typeMap).forEach(type => {
|
|
54
|
+
DocumentDynamicTextElementUtil.propertyMapByType[type] = { properties: {} };
|
|
55
|
+
typeMap[type].typeProperties.forEach(p => {
|
|
56
|
+
DocumentDynamicTextElementUtil.propertyMapByType[type].properties[p.slug] = p;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
29
60
|
}
|
|
30
61
|
exports.DocumentDynamicTextElementUtil = DocumentDynamicTextElementUtil;
|
|
62
|
+
DocumentDynamicTextElementUtil.propertyMapByType = {};
|