@contrail/documents 1.3.2 → 1.3.4

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.
@@ -12,5 +12,5 @@ export declare class DocumentElementPropertyBindingHandler {
12
12
  static bindPropertiesToElement(element: DocumentElement, model: DocumentElementModel): void;
13
13
  static isContentTypeWebViewable(contentType: string): boolean;
14
14
  static adjustPropertyElements(element: DocumentElement, elements: DocumentElement[], model: any): void;
15
- static clearOrSetColorBindingsOnStyleChange(element: DocumentElement, changes: DocumentElement): void;
15
+ static setBackgroundColorBindings(element: DocumentElement): void;
16
16
  }
@@ -11,7 +11,7 @@ class DocumentElementPropertyBindingHandler {
11
11
  });
12
12
  }
13
13
  static bindPropertiesToElement(element, model) {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
15
15
  const localModel = Object.assign({}, model);
16
16
  if (!element.propertyBindings) {
17
17
  return;
@@ -24,7 +24,15 @@ class DocumentElementPropertyBindingHandler {
24
24
  const isNestedPropertyAccess = pathParts.length > 2;
25
25
  let propertyValue = util_1.ObjectUtil.getByPath(localModel, modelIndex);
26
26
  if ((propertyValue === null || propertyValue === void 0 ? void 0 : propertyValue.name) && !isNestedPropertyAccess) {
27
- propertyValue = propertyValue.name;
27
+ const isItemObjectReference = pathParts[0] === 'item';
28
+ const isItemOptionProperty = pathParts[1] === 'itemOption';
29
+ const isOptionReference = ((_a = propertyValue === null || propertyValue === void 0 ? void 0 : propertyValue.roles) === null || _a === void 0 ? void 0 : _a.indexOf('option')) !== -1;
30
+ if (isItemObjectReference && !isItemOptionProperty && isOptionReference) {
31
+ propertyValue = `${propertyValue.name} - ${propertyValue.optionName || propertyValue.name}`;
32
+ }
33
+ else {
34
+ propertyValue = propertyValue.name;
35
+ }
28
36
  }
29
37
  if (propertyValue === null || propertyValue === undefined) {
30
38
  propertyValue = '';
@@ -32,12 +40,12 @@ class DocumentElementPropertyBindingHandler {
32
40
  util_1.ObjectUtil.setByPath(element, propertyKey, propertyValue);
33
41
  }
34
42
  const isImage = ['image', 'svg'].includes(element.type);
35
- if (((_b = (_a = element.propertyBindings) === null || _a === void 0 ? void 0 : _a.url) === null || _b === void 0 ? void 0 : _b.indexOf('viewable')) !== -1 && isImage) {
43
+ if (((_c = (_b = element.propertyBindings) === null || _b === void 0 ? void 0 : _b.url) === null || _c === void 0 ? void 0 : _c.indexOf('viewable')) !== -1 && isImage) {
36
44
  element.alternateUrls = {};
37
- let highResUrl = ((_c = model === null || model === void 0 ? void 0 : model.viewable) === null || _c === void 0 ? void 0 : _c.largeViewableDownloadUrl) || ((_d = model === null || model === void 0 ? void 0 : model.viewable) === null || _d === void 0 ? void 0 : _d.largeViewableUrl);
45
+ let highResUrl = ((_d = model === null || model === void 0 ? void 0 : model.viewable) === null || _d === void 0 ? void 0 : _d.largeViewableDownloadUrl) || ((_e = model === null || model === void 0 ? void 0 : model.viewable) === null || _e === void 0 ? void 0 : _e.largeViewableUrl);
38
46
  let originalFile;
39
47
  let viewableObject;
40
- const content = (_e = model === null || model === void 0 ? void 0 : model.viewable) === null || _e === void 0 ? void 0 : _e.content;
48
+ const content = (_f = model === null || model === void 0 ? void 0 : model.viewable) === null || _f === void 0 ? void 0 : _f.content;
41
49
  if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
42
50
  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); });
43
51
  viewableObject = primaryContent;
@@ -59,11 +67,11 @@ class DocumentElementPropertyBindingHandler {
59
67
  if (originalFile) {
60
68
  element.alternateUrls.originalFile = originalFile;
61
69
  }
62
- let lowResUrl = ((_f = model === null || model === void 0 ? void 0 : model.viewable) === null || _f === void 0 ? void 0 : _f.mediumViewableDownloadUrl) || ((_g = model === null || model === void 0 ? void 0 : model.viewable) === null || _g === void 0 ? void 0 : _g.mediumViewableUrl);
70
+ let lowResUrl = ((_g = model === null || model === void 0 ? void 0 : model.viewable) === null || _g === void 0 ? void 0 : _g.mediumViewableDownloadUrl) || ((_h = model === null || model === void 0 ? void 0 : model.viewable) === null || _h === void 0 ? void 0 : _h.mediumViewableUrl);
63
71
  if (lowResUrl) {
64
72
  element.alternateUrls.lowResolution = lowResUrl;
65
73
  }
66
- let tinyResUrl = ((_h = model === null || model === void 0 ? void 0 : model.viewable) === null || _h === void 0 ? void 0 : _h.tinyViewableDownloadUrl) || ((_j = model === null || model === void 0 ? void 0 : model.viewable) === null || _j === void 0 ? void 0 : _j.tinyViewableUrl);
74
+ let tinyResUrl = ((_j = model === null || model === void 0 ? void 0 : model.viewable) === null || _j === void 0 ? void 0 : _j.tinyViewableDownloadUrl) || ((_k = model === null || model === void 0 ? void 0 : model.viewable) === null || _k === void 0 ? void 0 : _k.tinyViewableUrl);
67
75
  if (tinyResUrl) {
68
76
  element.alternateUrls.tinyResolution = tinyResUrl;
69
77
  }
@@ -106,20 +114,20 @@ class DocumentElementPropertyBindingHandler {
106
114
  }
107
115
  }
108
116
  }
109
- static clearOrSetColorBindingsOnStyleChange(element, changes) {
117
+ static setBackgroundColorBindings(element) {
110
118
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
111
- if (((_a = changes === null || changes === void 0 ? void 0 : changes.style) === null || _a === void 0 ? void 0 : _a.backgroundColor) && ((_b = element === null || element === void 0 ? void 0 : element.propertyBindings) === null || _b === void 0 ? void 0 : _b['style.backgroundColor'])) {
119
+ if (((_a = element === null || element === void 0 ? void 0 : element.style) === null || _a === void 0 ? void 0 : _a.backgroundColor) && ((_b = element === null || element === void 0 ? void 0 : element.propertyBindings) === null || _b === void 0 ? void 0 : _b['style.backgroundColor'])) {
112
120
  delete element.propertyBindings['style.backgroundColor'];
113
121
  (_c = element.propertyBindings) === null || _c === void 0 ? true : delete _c['style.color'];
114
122
  }
115
- else if (((_d = changes === null || changes === void 0 ? void 0 : changes.style) === null || _d === void 0 ? void 0 : _d.backgroundColor) === '' && ((_e = element === null || element === void 0 ? void 0 : element.propertyBindings) === null || _e === void 0 ? void 0 : _e.text)) {
123
+ else if (((_d = element === null || element === void 0 ? void 0 : element.style) === null || _d === void 0 ? void 0 : _d.backgroundColor) === '' && ((_e = element === null || element === void 0 ? void 0 : element.propertyBindings) === null || _e === void 0 ? void 0 : _e.text)) {
116
124
  element.propertyBindings['style.backgroundColor'] = `${element.propertyBindings.text}.hexCode`;
117
125
  element.propertyBindings['style.color'] = `${element.propertyBindings.text}.textColorHexCode`;
118
126
  }
119
- if (((_f = changes === null || changes === void 0 ? void 0 : changes.style) === null || _f === void 0 ? void 0 : _f.color) && ((_g = element === null || element === void 0 ? void 0 : element.propertyBindings) === null || _g === void 0 ? void 0 : _g['style.color'])) {
127
+ if (((_f = element === null || element === void 0 ? void 0 : element.style) === null || _f === void 0 ? void 0 : _f.color) && ((_g = element === null || element === void 0 ? void 0 : element.propertyBindings) === null || _g === void 0 ? void 0 : _g['style.color'])) {
120
128
  delete element.propertyBindings['style.color'];
121
129
  }
122
- else if (((_h = changes === null || changes === void 0 ? void 0 : changes.style) === null || _h === void 0 ? void 0 : _h.color) === '' && ((_j = element === null || element === void 0 ? void 0 : element.propertyBindings) === null || _j === void 0 ? void 0 : _j.text)) {
130
+ else if (((_h = element === null || element === void 0 ? void 0 : element.style) === null || _h === void 0 ? void 0 : _h.color) === '' && ((_j = element === null || element === void 0 ? void 0 : element.propertyBindings) === null || _j === void 0 ? void 0 : _j.text)) {
123
131
  element.propertyBindings['style.color'] = `${element.propertyBindings.text}.textColorHexCode`;
124
132
  }
125
133
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",