@contrail/documents 1.1.20 → 1.1.21

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.
@@ -36,7 +36,7 @@ export declare const HARD_CODED_TEXT: {
36
36
  'frame.colorCount': string;
37
37
  };
38
38
  export declare class DynamicTextUtil {
39
- static getDynamicTextValue(dynamicTextElement: DocumentElement, property: TypeProperty, propertyLevel: string, frame: {
39
+ static getDynamicTextValue(dynamicTextElement: DocumentElement, property: TypeProperty, frame: {
40
40
  name: string;
41
41
  id?: string;
42
42
  }, componentModels: any[], ownerReferenceModel?: any): string;
@@ -49,7 +49,7 @@ const frameProperties = [
49
49
  'frame.colorCount',
50
50
  ];
51
51
  class DynamicTextUtil {
52
- static getDynamicTextValue(dynamicTextElement, property, propertyLevel, frame, componentModels, ownerReferenceModel = null) {
52
+ static getDynamicTextValue(dynamicTextElement, property, frame, componentModels, ownerReferenceModel = null) {
53
53
  var _a, _b, _c, _d;
54
54
  if (!dynamicTextElement.propertyBindings || !dynamicTextElement.propertyBindings.text) {
55
55
  return exports.CLICK_TO_CONFIGURE;
@@ -98,22 +98,6 @@ class DynamicTextUtil {
98
98
  property = null;
99
99
  }
100
100
  const frameMemberValues = [];
101
- if (propertyLevel) {
102
- componentModels = componentModels.filter((model) => {
103
- var _a;
104
- const entity = entityType === 'item' ? model === null || model === void 0 ? void 0 : model.item : model === null || model === void 0 ? void 0 : model.projectItem;
105
- return (_a = entity === null || entity === void 0 ? void 0 : entity.roles) === null || _a === void 0 ? void 0 : _a.includes(propertyLevel);
106
- });
107
- const uniqueIds = new Set();
108
- componentModels = componentModels.filter((model) => {
109
- var _a, _b;
110
- const id = entityType === 'item' ? (_a = model === null || model === void 0 ? void 0 : model.item) === null || _a === void 0 ? void 0 : _a.id : (_b = model === null || model === void 0 ? void 0 : model.projectItem) === null || _b === void 0 ? void 0 : _b.id;
111
- if (!id || uniqueIds.has(id))
112
- return false;
113
- uniqueIds.add(id);
114
- return true;
115
- });
116
- }
117
101
  componentModels.forEach((elementModel) => {
118
102
  frameMemberValues.push(util_1.ObjectUtil.getByPath(elementModel, bindingProperty));
119
103
  });
@@ -183,8 +167,8 @@ class DynamicTextUtil {
183
167
  }
184
168
  const formatter = new types_1.PropertyValueFormatter();
185
169
  if (displayFunction === DynamicTextDisplayFunction.AVERAGE) {
186
- const memberNumValues = memberValues.filter(Number);
187
- text = formatter.formatValueForProperty(memberNumValues.reduce((a, b) => a + b, 0) / memberValues.length, property);
170
+ memberValues = memberValues.filter(Number);
171
+ text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0) / memberValues.length, property);
188
172
  }
189
173
  else if (displayFunction === DynamicTextDisplayFunction.SUM) {
190
174
  memberValues = memberValues.filter(Number);
@@ -206,13 +190,8 @@ class DynamicTextUtil {
206
190
  text = formatter.formatValueForProperty(memberValues[memberValues.length - 1], property);
207
191
  }
208
192
  else if (displayFunction === DynamicTextDisplayFunction.MIN) {
209
- const minValue = Math.min(...memberValues.filter((e) => e !== null && e !== undefined));
210
- if (minValue > 0 && (memberValues.includes(null) || memberValues.includes(undefined))) {
211
- text = '';
212
- }
213
- else {
214
- text = formatter.formatValueForProperty(minValue, property);
215
- }
193
+ memberValues = memberValues.filter((e) => e !== null && e !== undefined);
194
+ text = formatter.formatValueForProperty(Math.min(...memberValues), property);
216
195
  }
217
196
  else if (displayFunction === DynamicTextDisplayFunction.MAX) {
218
197
  memberValues = memberValues.filter((e) => e !== null && e !== undefined);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.1.20",
3
+ "version": "1.1.21",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",