@reltio/components 1.4.832 → 1.4.833

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.
@@ -15,6 +15,6 @@ export declare const useModifiedEntity: ({ entity, onLoad, onModify, onError }:
15
15
  onPinAttribute: ({ attributeValue }: import("../../attributes/inline").PinInlineAttributeEvent) => void;
16
16
  onIgnoreAttribute: ({ attributeValue }: import("../../attributes/inline").IgnoreInlineAttributeEvent) => void;
17
17
  onEditAttribute: (event: EditInlineAttributeEvent) => void;
18
- newlyCreatedNestedAttributes: string[];
18
+ newlyCreatedAttributes: string[];
19
19
  };
20
20
  export {};
@@ -22,16 +22,17 @@ var useAttributeActions_1 = require("./useAttributeActions");
22
22
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
23
23
  var ramda_1 = require("ramda");
24
24
  var core_1 = require("../../../core");
25
+ var emptyArray = [];
25
26
  var useModifiedEntity = function (_a) {
26
27
  var entity = _a.entity, _b = _a.onLoad, onLoad = _b === void 0 ? core_1.noop : _b, _c = _a.onModify, onModify = _c === void 0 ? core_1.noop : _c, _d = _a.onError, onError = _d === void 0 ? core_1.noop : _d;
27
28
  var _e = react_1.useState(null), modifiedEntity = _e[0], setModifiedEntity = _e[1];
28
29
  var _f = react_1.useState(null), crosswalksMap = _f[0], setCrosswalksMap = _f[1];
29
30
  var temporaryAttributes = react_1.useRef([]);
30
- var futureNestedAttributes = react_1.useRef([]);
31
- var resetFutureNestedAttributes = react_1.useCallback(function () {
32
- futureNestedAttributes.current = [];
31
+ var crosswalkForNewAttributes = react_1.useRef(null);
32
+ var resetCrosswalkForNewAttributes = react_1.useCallback(function () {
33
+ crosswalkForNewAttributes.current = null;
33
34
  }, []);
34
- var _g = react_1.useState([]), newlyCreatedNestedAttributes = _g[0], setNewlyCreatedNestedAttributes = _g[1];
35
+ var _g = react_1.useState(emptyArray), newlyCreatedAttributes = _g[0], setNewlyCreatedAttributes = _g[1];
35
36
  var groupCrosswalksByAttrUri = function (crosswalks) {
36
37
  if (crosswalks === void 0) { crosswalks = []; }
37
38
  return crosswalks.reduce(function (acc, crosswalk) {
@@ -42,23 +43,28 @@ var useModifiedEntity = function (_a) {
42
43
  }, {});
43
44
  };
44
45
  react_1.useEffect(function () {
45
- if ((modifiedEntity === null || modifiedEntity === void 0 ? void 0 : modifiedEntity.uri) === (entity === null || entity === void 0 ? void 0 : entity.uri)) {
46
- setNewlyCreatedNestedAttributes(futureNestedAttributes.current
47
- .map(function (nestedAttrUri) { var _a; return (_a = mdm_sdk_1.findNewAttributeValueByTempUri(entity, nestedAttrUri)) === null || _a === void 0 ? void 0 : _a.uri; })
48
- .filter(function (uri) { return !!uri; }));
46
+ var newCrosswalksMap = {
47
+ entity: groupCrosswalksByAttrUri(entity === null || entity === void 0 ? void 0 : entity.crosswalks),
48
+ relation: ramda_1.pipe(mdm_sdk_1.getRelationCrosswalks, groupCrosswalksByAttrUri)(entity)
49
+ };
50
+ if ((modifiedEntity === null || modifiedEntity === void 0 ? void 0 : modifiedEntity.uri) === (entity === null || entity === void 0 ? void 0 : entity.uri) && crosswalkForNewAttributes.current) {
51
+ var ownerType = crosswalkForNewAttributes.current.ownerType;
52
+ var newAttributes = Object.keys(newCrosswalksMap[ownerType]);
53
+ var oldAttributes = Object.keys(crosswalksMap[ownerType]);
54
+ setNewlyCreatedAttributes(ramda_1.difference(newAttributes, oldAttributes));
49
55
  }
50
56
  else {
51
- setNewlyCreatedNestedAttributes([]);
57
+ setNewlyCreatedAttributes(emptyArray);
52
58
  }
53
- resetFutureNestedAttributes();
59
+ resetCrosswalkForNewAttributes();
54
60
  setModifiedEntity(entity);
55
- setCrosswalksMap({
56
- entity: groupCrosswalksByAttrUri(entity === null || entity === void 0 ? void 0 : entity.crosswalks),
57
- relation: ramda_1.pipe(mdm_sdk_1.getRelationCrosswalks, groupCrosswalksByAttrUri)(entity)
58
- });
61
+ setCrosswalksMap(newCrosswalksMap);
59
62
  temporaryAttributes.current = [];
60
63
  }, [entity]);
61
- var handleError = react_1.useCallback(ramda_1.pipe(onError, resetFutureNestedAttributes), [onError, resetFutureNestedAttributes]);
64
+ var handleError = react_1.useCallback(ramda_1.pipe(onError, resetCrosswalkForNewAttributes), [
65
+ onError,
66
+ resetCrosswalkForNewAttributes
67
+ ]);
62
68
  var _h = useAttributeActions_1.useAttributeActions({
63
69
  onLoad: onLoad,
64
70
  onSuccess: onModify,
@@ -118,10 +124,7 @@ var useModifiedEntity = function (_a) {
118
124
  attributeValue: mdm_sdk_1.findAttributeValueByUri(editedEntity, tempAttributeUri),
119
125
  crosswalk: crosswalk
120
126
  });
121
- var parentUri = mdm_sdk_1.getParentUri(uri_1);
122
- if (!mdm_sdk_1.isFirstLevelAttributeValueUri(uri_1) && mdm_sdk_1.isTempUri(parentUri)) {
123
- futureNestedAttributes.current.push(parentUri);
124
- }
127
+ crosswalkForNewAttributes.current = crosswalk;
125
128
  }
126
129
  }
127
130
  else {
@@ -136,7 +139,7 @@ var useModifiedEntity = function (_a) {
136
139
  onPinAttribute: pinAttribute,
137
140
  onIgnoreAttribute: ignoreAttribute,
138
141
  onEditAttribute: onEditAttribute,
139
- newlyCreatedNestedAttributes: newlyCreatedNestedAttributes
142
+ newlyCreatedAttributes: newlyCreatedAttributes
140
143
  };
141
144
  };
142
145
  exports.useModifiedEntity = useModifiedEntity;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.832",
3
+ "version": "1.4.833",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "@date-io/moment": "^1.3.5",
8
8
  "@react-google-maps/api": "^2.7.0",
9
- "@reltio/mdm-module": "^1.4.832",
10
- "@reltio/mdm-sdk": "^1.4.832",
9
+ "@reltio/mdm-module": "^1.4.833",
10
+ "@reltio/mdm-sdk": "^1.4.833",
11
11
  "classnames": "^2.2.5",
12
12
  "frontend-collective-react-dnd-scrollzone": "^1.0.2",
13
13
  "nanoid": "^2.0.0",