@contrail/documents 1.1.24 → 1.1.25
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.
|
@@ -6,7 +6,7 @@ const common_1 = require("./types/common");
|
|
|
6
6
|
const util_1 = require("@contrail/util");
|
|
7
7
|
class DocumentElementPropertyBindingHandler {
|
|
8
8
|
static bindPropertiesToElements(elements, model) {
|
|
9
|
-
elements.map(
|
|
9
|
+
elements.map(el => {
|
|
10
10
|
this.bindPropertiesToElement(el, model);
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -20,7 +20,12 @@ class DocumentElementPropertyBindingHandler {
|
|
|
20
20
|
}
|
|
21
21
|
for (const propertyKey of Object.keys(element.propertyBindings)) {
|
|
22
22
|
const modelIndex = element.propertyBindings[propertyKey];
|
|
23
|
+
const pathParts = modelIndex.split('.');
|
|
24
|
+
const isNestedPropertyAccess = pathParts.length > 2;
|
|
23
25
|
let propertyValue = util_1.ObjectUtil.getByPath(localModel, modelIndex);
|
|
26
|
+
if ((propertyValue === null || propertyValue === void 0 ? void 0 : propertyValue.name) && !isNestedPropertyAccess) {
|
|
27
|
+
propertyValue = propertyValue.name;
|
|
28
|
+
}
|
|
24
29
|
if (propertyValue === null || propertyValue === undefined) {
|
|
25
30
|
propertyValue = '';
|
|
26
31
|
}
|
|
@@ -34,7 +39,7 @@ class DocumentElementPropertyBindingHandler {
|
|
|
34
39
|
let viewableObject;
|
|
35
40
|
const content = (_e = model === null || model === void 0 ? void 0 : model.viewable) === null || _e === void 0 ? void 0 : _e.content;
|
|
36
41
|
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
37
|
-
const primaryContent = content.find(
|
|
42
|
+
const primaryContent = content.find(c => { var _a; return (c === null || c === void 0 ? void 0 : c.id) === ((_a = model === null || model === void 0 ? void 0 : model.viewable) === null || _a === void 0 ? void 0 : _a.primaryViewableId); });
|
|
38
43
|
viewableObject = primaryContent;
|
|
39
44
|
}
|
|
40
45
|
else {
|
|
@@ -98,7 +98,7 @@ class DynamicTextUtil {
|
|
|
98
98
|
property = null;
|
|
99
99
|
}
|
|
100
100
|
const frameMemberValues = [];
|
|
101
|
-
componentModels.forEach(elementModel => {
|
|
101
|
+
componentModels.forEach((elementModel) => {
|
|
102
102
|
frameMemberValues.push(util_1.ObjectUtil.getByPath(elementModel, bindingProperty));
|
|
103
103
|
});
|
|
104
104
|
if (frameMemberValues.length > 0) {
|
|
@@ -179,9 +179,9 @@ class DynamicTextUtil {
|
|
|
179
179
|
}
|
|
180
180
|
else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
|
|
181
181
|
text = Array.from(new Set(memberValues
|
|
182
|
-
.filter(e => e !== null && e !== undefined)
|
|
182
|
+
.filter((e) => e !== null && e !== undefined)
|
|
183
183
|
.flat()
|
|
184
|
-
.map(e => formatter.formatValueForProperty(e, property))))
|
|
184
|
+
.map((e) => formatter.formatValueForProperty(e, property))))
|
|
185
185
|
.sort()
|
|
186
186
|
.join(', ');
|
|
187
187
|
}
|
|
@@ -193,31 +193,31 @@ class DynamicTextUtil {
|
|
|
193
193
|
text = formatter.formatValueForProperty(memberValues[memberValues.length - 1], property);
|
|
194
194
|
}
|
|
195
195
|
else if (displayFunction === DynamicTextDisplayFunction.MIN) {
|
|
196
|
-
memberValues = memberValues.filter(e => e !== null && e !== undefined);
|
|
196
|
+
memberValues = memberValues.filter((e) => e !== null && e !== undefined);
|
|
197
197
|
text = formatter.formatValueForProperty(Math.min(...memberValues), property);
|
|
198
198
|
}
|
|
199
199
|
else if (displayFunction === DynamicTextDisplayFunction.MAX) {
|
|
200
|
-
memberValues = memberValues.filter(e => e !== null && e !== undefined);
|
|
200
|
+
memberValues = memberValues.filter((e) => e !== null && e !== undefined);
|
|
201
201
|
text = formatter.formatValueForProperty(Math.max(...memberValues), property);
|
|
202
202
|
}
|
|
203
203
|
return text;
|
|
204
204
|
}
|
|
205
205
|
static getItemCount(countType, componentModels) {
|
|
206
|
-
const elementModels = componentModels.map(elementModel => {
|
|
206
|
+
const elementModels = componentModels.map((elementModel) => {
|
|
207
207
|
return elementModel.item || elementModel.color;
|
|
208
208
|
});
|
|
209
209
|
let count = 0;
|
|
210
210
|
if (countType === 'itemFamilyCount') {
|
|
211
|
-
count = new Set(elementModels.filter(model => model.entityType === 'item').map(model => model === null || model === void 0 ? void 0 : model.itemFamilyId))
|
|
211
|
+
count = new Set(elementModels.filter((model) => model.entityType === 'item').map((model) => model === null || model === void 0 ? void 0 : model.itemFamilyId))
|
|
212
212
|
.size;
|
|
213
213
|
}
|
|
214
214
|
else if (countType === 'itemOptionCount') {
|
|
215
215
|
count = new Set(elementModels
|
|
216
|
-
.filter(model => model.entityType === 'item' && model.roles.includes('option'))
|
|
217
|
-
.map(model => model === null || model === void 0 ? void 0 : model.id)).size;
|
|
216
|
+
.filter((model) => model.entityType === 'item' && model.roles.includes('option'))
|
|
217
|
+
.map((model) => model === null || model === void 0 ? void 0 : model.id)).size;
|
|
218
218
|
}
|
|
219
219
|
else if (countType === 'colorCount') {
|
|
220
|
-
count = new Set(elementModels.filter(model => model.entityType === 'color').map(model => model === null || model === void 0 ? void 0 : model.id)).size;
|
|
220
|
+
count = new Set(elementModels.filter((model) => model.entityType === 'color').map((model) => model === null || model === void 0 ? void 0 : model.id)).size;
|
|
221
221
|
}
|
|
222
222
|
return count.toString();
|
|
223
223
|
}
|