@reltio/components 1.4.1928 → 1.4.1930
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.
- package/cjs/BasicTable/basicTableViewState.d.ts +63 -15
- package/cjs/BasicTable/basicTableViewState.js +38 -20
- package/cjs/BasicTable/basicTableViewState.test.js +20 -0
- package/cjs/contexts/ProfileTablesContext/index.d.ts +6 -0
- package/cjs/contexts/ProfileTablesContext/index.js +8 -0
- package/cjs/helpers/basicTable.d.ts +3 -1
- package/cjs/helpers/basicTable.js +12 -1
- package/cjs/hooks/useMarkers/helpers.d.ts +8 -0
- package/cjs/hooks/useMarkers/helpers.js +56 -0
- package/cjs/hooks/useMarkers/index.d.ts +2 -0
- package/cjs/hooks/useMarkers/index.js +7 -0
- package/cjs/hooks/useMarkers/nestedHelpers.d.ts +2 -0
- package/cjs/hooks/useMarkers/nestedHelpers.js +31 -0
- package/cjs/hooks/useMarkers/nestedHelpers.test.d.ts +1 -0
- package/cjs/hooks/useMarkers/nestedHelpers.test.js +235 -0
- package/cjs/hooks/useMarkers/referenceHelpers.d.ts +2 -0
- package/cjs/hooks/useMarkers/referenceHelpers.js +180 -0
- package/cjs/hooks/useMarkers/referenceHelpers.test.d.ts +1 -0
- package/cjs/hooks/useMarkers/referenceHelpers.test.js +490 -0
- package/cjs/hooks/useMarkers/resolveHelpers.d.ts +8 -0
- package/cjs/hooks/useMarkers/resolveHelpers.js +70 -0
- package/cjs/hooks/useMarkers/useMarkers.d.ts +5 -0
- package/cjs/hooks/useMarkers/useMarkers.js +30 -0
- package/cjs/hooks/useSavedState/useSavedState.d.ts +1 -1
- package/cjs/hooks/useSavedStateForEntityType/useSavedStateForEntityType.d.ts +1 -1
- package/cjs/index.d.ts +5 -2
- package/cjs/index.js +9 -2
- package/cjs/test-utils/index.js +1 -1
- package/cjs/types/basicTable.d.ts +5 -0
- package/cjs/types/preferences.d.ts +8 -0
- package/cjs/types/preferences.js +2 -0
- package/esm/BasicTable/basicTableViewState.d.ts +63 -15
- package/esm/BasicTable/basicTableViewState.js +37 -19
- package/esm/BasicTable/basicTableViewState.test.js +20 -0
- package/esm/contexts/ProfileTablesContext/index.d.ts +6 -0
- package/esm/contexts/ProfileTablesContext/index.js +5 -0
- package/esm/helpers/basicTable.d.ts +3 -1
- package/esm/helpers/basicTable.js +10 -0
- package/esm/hooks/useMarkers/helpers.d.ts +8 -0
- package/esm/hooks/useMarkers/helpers.js +49 -0
- package/esm/hooks/useMarkers/index.d.ts +2 -0
- package/esm/hooks/useMarkers/index.js +2 -0
- package/esm/hooks/useMarkers/nestedHelpers.d.ts +2 -0
- package/esm/hooks/useMarkers/nestedHelpers.js +27 -0
- package/esm/hooks/useMarkers/nestedHelpers.test.d.ts +1 -0
- package/esm/hooks/useMarkers/nestedHelpers.test.js +233 -0
- package/esm/hooks/useMarkers/referenceHelpers.d.ts +2 -0
- package/esm/hooks/useMarkers/referenceHelpers.js +176 -0
- package/esm/hooks/useMarkers/referenceHelpers.test.d.ts +1 -0
- package/esm/hooks/useMarkers/referenceHelpers.test.js +488 -0
- package/esm/hooks/useMarkers/resolveHelpers.d.ts +8 -0
- package/esm/hooks/useMarkers/resolveHelpers.js +66 -0
- package/esm/hooks/useMarkers/useMarkers.d.ts +5 -0
- package/esm/hooks/useMarkers/useMarkers.js +26 -0
- package/esm/hooks/useSavedState/useSavedState.d.ts +1 -1
- package/esm/hooks/useSavedStateForEntityType/useSavedStateForEntityType.d.ts +1 -1
- package/esm/index.d.ts +5 -2
- package/esm/index.js +4 -1
- package/esm/test-utils/index.js +1 -1
- package/esm/types/basicTable.d.ts +5 -0
- package/esm/types/preferences.d.ts +8 -0
- package/esm/types/preferences.js +1 -0
- package/package.json +15 -12
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { assocPath } from 'ramda';
|
|
49
|
+
import { decodeAddress } from '@reltio/mdm-sdk';
|
|
50
|
+
import { getPointsFromReference } from './referenceHelpers';
|
|
51
|
+
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { decodeAddress: jest.fn() })); });
|
|
52
|
+
describe('from reference strategy test', function () {
|
|
53
|
+
var servicesPath = '/nui/services';
|
|
54
|
+
var defaultMetadata = {
|
|
55
|
+
entityTypes: [
|
|
56
|
+
{
|
|
57
|
+
uri: 'configuration/entityTypes/Location',
|
|
58
|
+
attributes: [
|
|
59
|
+
{
|
|
60
|
+
name: 'GeoLocation',
|
|
61
|
+
uri: 'configuration/entityTypes/Location/attributes/GeoLocation',
|
|
62
|
+
type: 'Nested',
|
|
63
|
+
attributes: [
|
|
64
|
+
{
|
|
65
|
+
name: 'Latitude',
|
|
66
|
+
type: 'String',
|
|
67
|
+
uri: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'Longitude',
|
|
71
|
+
type: 'String',
|
|
72
|
+
uri: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude'
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
geoLocationAttributes: [
|
|
78
|
+
{
|
|
79
|
+
latitude: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
80
|
+
longitude: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude'
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
uri: 'configuration/entityTypes/EntityTypeWithLocation',
|
|
86
|
+
attributes: [
|
|
87
|
+
{
|
|
88
|
+
uri: 'configuration/entityTypes/EntityTypeWithLocation/attributes/Address',
|
|
89
|
+
referencedEntityTypeURI: 'configuration/entityTypes/Location',
|
|
90
|
+
name: 'Address',
|
|
91
|
+
type: 'String'
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
uri: 'configuration/entityTypes/EntityTypeWithLocationAndAttribute',
|
|
97
|
+
attributes: [
|
|
98
|
+
{
|
|
99
|
+
uri: 'configuration/entityTypes/EntityTypeWithLocationAndAttribute/attributes/Address',
|
|
100
|
+
referencedEntityTypeURI: 'configuration/entityTypes/Location',
|
|
101
|
+
name: 'Address',
|
|
102
|
+
type: 'String'
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
geoLocationAttributes: [
|
|
106
|
+
{
|
|
107
|
+
latitude: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
108
|
+
longitude: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude'
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
var defaultEntities = [
|
|
115
|
+
{
|
|
116
|
+
uri: 'entities/111',
|
|
117
|
+
label: 'label',
|
|
118
|
+
type: 'configuration/entityTypes/Location',
|
|
119
|
+
attributes: {
|
|
120
|
+
GeoLocation: [
|
|
121
|
+
{
|
|
122
|
+
uri: 'entities/111/attributes/GeoLocation/222',
|
|
123
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation',
|
|
124
|
+
ov: true,
|
|
125
|
+
value: {
|
|
126
|
+
Longitude: [
|
|
127
|
+
{
|
|
128
|
+
uri: 'entities/111/attributes/GeoLocation/222/Longitude/333',
|
|
129
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
|
|
130
|
+
ov: true,
|
|
131
|
+
value: '123'
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
Latitude: [
|
|
135
|
+
{
|
|
136
|
+
uri: 'entities/111/attributes/GeoLocation/222/Latitude/444',
|
|
137
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
138
|
+
ov: true,
|
|
139
|
+
value: '321'
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
];
|
|
148
|
+
beforeEach(function () {
|
|
149
|
+
jest.resetAllMocks();
|
|
150
|
+
});
|
|
151
|
+
it('should work well for Location entities with geolocation attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
152
|
+
var points;
|
|
153
|
+
return __generator(this, function (_a) {
|
|
154
|
+
switch (_a.label) {
|
|
155
|
+
case 0: return [4 /*yield*/, getPointsFromReference(servicesPath, defaultMetadata, defaultEntities)];
|
|
156
|
+
case 1:
|
|
157
|
+
points = _a.sent();
|
|
158
|
+
expect(points[0].id).toBe('entities/111');
|
|
159
|
+
expect(points[0].entity).toEqual(defaultEntities[0]);
|
|
160
|
+
expect(points[0].label).toBe('label');
|
|
161
|
+
expect(points[0].point).toEqual({ lat: 321, lng: 123 });
|
|
162
|
+
return [2 /*return*/];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}); });
|
|
166
|
+
it('should work well if an attribute has more than one value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
167
|
+
var entities, points, lisbonLocation, berlinLocation;
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
switch (_a.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
entities = [
|
|
172
|
+
{
|
|
173
|
+
uri: 'entities/111',
|
|
174
|
+
label: 'label',
|
|
175
|
+
attributes: {
|
|
176
|
+
Address: [
|
|
177
|
+
{
|
|
178
|
+
uri: 'entities/111/attributes/Address/222',
|
|
179
|
+
label: 'Lisbon',
|
|
180
|
+
value: {
|
|
181
|
+
GeoLocation: [
|
|
182
|
+
{
|
|
183
|
+
uri: 'entities/111/attributes/Address/222/GeoLocation/333',
|
|
184
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation',
|
|
185
|
+
value: {
|
|
186
|
+
Longitude: [
|
|
187
|
+
{
|
|
188
|
+
uri: 'entities/111/attributes/Address/222/GeoLocation/333/Longitude/123',
|
|
189
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
|
|
190
|
+
value: '123'
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
Latitude: [
|
|
194
|
+
{
|
|
195
|
+
uri: 'entities/111/attributes/Address/222/GeoLocation/333/Latitude/321',
|
|
196
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
197
|
+
value: '321'
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
uri: 'entities/111/attributes/Address/123',
|
|
207
|
+
label: 'Berlin',
|
|
208
|
+
value: {
|
|
209
|
+
GeoLocation: [
|
|
210
|
+
{
|
|
211
|
+
uri: 'entities/111/attributes/Address/123/GeoLocation/444',
|
|
212
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation',
|
|
213
|
+
value: {
|
|
214
|
+
Longitude: [
|
|
215
|
+
{
|
|
216
|
+
uri: 'entities/111/attributes/Address/123/GeoLocation/444/Longitude/124',
|
|
217
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
|
|
218
|
+
value: '124'
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
Latitude: [
|
|
222
|
+
{
|
|
223
|
+
uri: 'entities/111/attributes/Address/123/GeoLocation/444/Latitude/320',
|
|
224
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
225
|
+
value: '320'
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
type: 'configuration/entityTypes/EntityTypeWithLocationAndAttribute'
|
|
236
|
+
}
|
|
237
|
+
];
|
|
238
|
+
return [4 /*yield*/, getPointsFromReference(servicesPath, defaultMetadata, entities)];
|
|
239
|
+
case 1:
|
|
240
|
+
points = _a.sent();
|
|
241
|
+
expect(points.length).toBe(2);
|
|
242
|
+
lisbonLocation = points[0], berlinLocation = points[1];
|
|
243
|
+
expect(lisbonLocation.label).toBe('Lisbon');
|
|
244
|
+
expect(lisbonLocation.point).toEqual({ lat: 321, lng: 123 });
|
|
245
|
+
expect(berlinLocation.label).toBe('Berlin');
|
|
246
|
+
expect(berlinLocation.point).toEqual({ lat: 320, lng: 124 });
|
|
247
|
+
return [2 /*return*/];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}); });
|
|
251
|
+
it('should get geo location attributes from geo location section even it is not defined in metadata', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
252
|
+
var entities, points;
|
|
253
|
+
return __generator(this, function (_a) {
|
|
254
|
+
switch (_a.label) {
|
|
255
|
+
case 0:
|
|
256
|
+
entities = [
|
|
257
|
+
{
|
|
258
|
+
uri: 'entities/111',
|
|
259
|
+
label: 'label',
|
|
260
|
+
attributes: {
|
|
261
|
+
Address: [
|
|
262
|
+
{
|
|
263
|
+
uri: 'entities/111/attributes/Address/123',
|
|
264
|
+
label: 'label',
|
|
265
|
+
value: {
|
|
266
|
+
GeoLocation: [
|
|
267
|
+
{
|
|
268
|
+
uri: 'entities/111/attributes/Address/123/GeoLocation/444',
|
|
269
|
+
type: 'configuration/entityTypes/EntityTypeWithLocation/attributes/Address/attributes/GeoLocation',
|
|
270
|
+
value: {
|
|
271
|
+
Longitude: [
|
|
272
|
+
{
|
|
273
|
+
uri: 'entities/111/attributes/Address/123/GeoLocation/444/Longitude/124',
|
|
274
|
+
type: 'configuration/entityTypes/EntityTypeWithLocation/attributes/Address/attributes/GeoLocation/attributes/Longitude',
|
|
275
|
+
value: '123'
|
|
276
|
+
}
|
|
277
|
+
],
|
|
278
|
+
Latitude: [
|
|
279
|
+
{
|
|
280
|
+
uri: 'entities/111/attributes/Address/123/GeoLocation/444/Latitude/320',
|
|
281
|
+
type: 'configuration/entityTypes/EntityTypeWithLocation/attributes/Address/attributes/GeoLocation/attributes/Latitude',
|
|
282
|
+
value: '321'
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
},
|
|
292
|
+
type: 'configuration/entityTypes/EntityTypeWithLocation'
|
|
293
|
+
}
|
|
294
|
+
];
|
|
295
|
+
return [4 /*yield*/, getPointsFromReference(servicesPath, defaultMetadata, entities)];
|
|
296
|
+
case 1:
|
|
297
|
+
points = _a.sent();
|
|
298
|
+
expect(points[0].id).toBe('entities/111/attributes/Address/123/GeoLocation/444');
|
|
299
|
+
expect(points[0].entity).toEqual(entities[0]);
|
|
300
|
+
expect(points[0].label).toBe('label');
|
|
301
|
+
expect(points[0].point).toEqual({
|
|
302
|
+
id: 'entities/111/attributes/Address/123/GeoLocation/444',
|
|
303
|
+
lat: 321,
|
|
304
|
+
lng: 123
|
|
305
|
+
});
|
|
306
|
+
return [2 /*return*/];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}); });
|
|
310
|
+
it('should try to resolve it by entity label if there are no geolocation attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
311
|
+
var entities, points;
|
|
312
|
+
return __generator(this, function (_a) {
|
|
313
|
+
switch (_a.label) {
|
|
314
|
+
case 0:
|
|
315
|
+
entities = [
|
|
316
|
+
{
|
|
317
|
+
label: 'label',
|
|
318
|
+
attributes: {},
|
|
319
|
+
type: 'configuration/entityTypes/Location',
|
|
320
|
+
uri: 'entities/111'
|
|
321
|
+
}
|
|
322
|
+
];
|
|
323
|
+
decodeAddress.mockImplementation(function (_a) {
|
|
324
|
+
var address = _a.address;
|
|
325
|
+
if (address === 'label') {
|
|
326
|
+
return Promise.resolve({ success: true, location: { lat: 321, lng: 123 } });
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
return Promise.reject('error');
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
return [4 /*yield*/, getPointsFromReference(servicesPath, defaultMetadata, entities)];
|
|
333
|
+
case 1:
|
|
334
|
+
points = _a.sent();
|
|
335
|
+
expect(points[0].id).toBe('entities/111');
|
|
336
|
+
expect(points[0].entity).toEqual(entities[0]);
|
|
337
|
+
expect(points[0].label).toBe('label');
|
|
338
|
+
expect(points[0].point).toEqual({ lat: 321, lng: 123 });
|
|
339
|
+
return [2 /*return*/];
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}); });
|
|
343
|
+
it('should not fail if entity type is not found in metadata', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
344
|
+
var entities, points;
|
|
345
|
+
return __generator(this, function (_a) {
|
|
346
|
+
switch (_a.label) {
|
|
347
|
+
case 0:
|
|
348
|
+
entities = [
|
|
349
|
+
{
|
|
350
|
+
label: 'label',
|
|
351
|
+
attributes: {},
|
|
352
|
+
type: 'configuration/entityTypes/LocationNotFromMD',
|
|
353
|
+
uri: 'entities/111'
|
|
354
|
+
}
|
|
355
|
+
];
|
|
356
|
+
return [4 /*yield*/, getPointsFromReference(servicesPath, defaultMetadata, entities)];
|
|
357
|
+
case 1:
|
|
358
|
+
points = _a.sent();
|
|
359
|
+
expect(points).toEqual([]);
|
|
360
|
+
return [2 /*return*/];
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}); });
|
|
364
|
+
it('should try to resolve it by ref entity label if no geolocation attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
365
|
+
var entities, points;
|
|
366
|
+
return __generator(this, function (_a) {
|
|
367
|
+
switch (_a.label) {
|
|
368
|
+
case 0:
|
|
369
|
+
entities = [
|
|
370
|
+
{
|
|
371
|
+
uri: 'entities/111',
|
|
372
|
+
label: 'label',
|
|
373
|
+
attributes: {
|
|
374
|
+
Address: [{ label: 'addressLabel', value: {}, uri: 'entities/111/attributes/Address/123' }]
|
|
375
|
+
},
|
|
376
|
+
type: 'configuration/entityTypes/EntityTypeWithLocation'
|
|
377
|
+
}
|
|
378
|
+
];
|
|
379
|
+
decodeAddress.mockImplementation(function (_a) {
|
|
380
|
+
var address = _a.address;
|
|
381
|
+
if (address === 'addressLabel') {
|
|
382
|
+
return Promise.resolve({ success: true, location: { lat: 321, lng: 123 } });
|
|
383
|
+
}
|
|
384
|
+
else if (address === 'label') {
|
|
385
|
+
return Promise.resolve({ success: true, location: { lat: 321, lng: 123 } });
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
return Promise.reject('error');
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
return [4 /*yield*/, getPointsFromReference(servicesPath, defaultMetadata, entities)];
|
|
392
|
+
case 1:
|
|
393
|
+
points = _a.sent();
|
|
394
|
+
expect(points[0].id).toBe('entities/111/attributes/Address/123');
|
|
395
|
+
expect(points[0].entity).toEqual(entities[0]);
|
|
396
|
+
expect(points[0].label).toBe('addressLabel');
|
|
397
|
+
expect(points[0].point).toEqual({ lat: 321, lng: 123 });
|
|
398
|
+
return [2 /*return*/];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
}); });
|
|
402
|
+
it('should work well for Location entities with multiple geolocation attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
403
|
+
var metadata, entities, points;
|
|
404
|
+
return __generator(this, function (_a) {
|
|
405
|
+
switch (_a.label) {
|
|
406
|
+
case 0:
|
|
407
|
+
metadata = {
|
|
408
|
+
entityTypes: [{ uri: 'configuration/entityTypes/Location', attributes: [] }]
|
|
409
|
+
};
|
|
410
|
+
entities = [
|
|
411
|
+
{
|
|
412
|
+
uri: 'entities/111',
|
|
413
|
+
label: 'label',
|
|
414
|
+
attributes: {
|
|
415
|
+
GeoLocation: [
|
|
416
|
+
{
|
|
417
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation',
|
|
418
|
+
uri: 'entities/111/attributes/GeoLocation/111',
|
|
419
|
+
value: {
|
|
420
|
+
Longitude: [
|
|
421
|
+
{
|
|
422
|
+
uri: 'entities/111/attributes/GeoLocation/111/Longitude/222',
|
|
423
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
|
|
424
|
+
value: '222'
|
|
425
|
+
}
|
|
426
|
+
],
|
|
427
|
+
Latitude: [
|
|
428
|
+
{
|
|
429
|
+
uri: 'entities/111/attributes/GeoLocation/111/Latitude/111',
|
|
430
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
431
|
+
value: '111'
|
|
432
|
+
}
|
|
433
|
+
]
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation',
|
|
438
|
+
uri: 'entities/111/attributes/GeoLocation/222',
|
|
439
|
+
value: {
|
|
440
|
+
Longitude: [
|
|
441
|
+
{
|
|
442
|
+
uri: 'entities/111/attributes/GeoLocation/222/Longitude/444',
|
|
443
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Longitude',
|
|
444
|
+
value: '444'
|
|
445
|
+
}
|
|
446
|
+
],
|
|
447
|
+
Latitude: [
|
|
448
|
+
{
|
|
449
|
+
uri: 'entities/111/attributes/GeoLocation/222/Latitude/333',
|
|
450
|
+
type: 'configuration/entityTypes/Location/attributes/GeoLocation/attributes/Latitude',
|
|
451
|
+
value: '333'
|
|
452
|
+
}
|
|
453
|
+
]
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
]
|
|
457
|
+
},
|
|
458
|
+
type: 'configuration/entityTypes/Location'
|
|
459
|
+
}
|
|
460
|
+
];
|
|
461
|
+
return [4 /*yield*/, getPointsFromReference(servicesPath, metadata, entities)];
|
|
462
|
+
case 1:
|
|
463
|
+
points = _a.sent();
|
|
464
|
+
expect(points[0].id).toEqual('entities/111/attributes/GeoLocation/111');
|
|
465
|
+
expect(points[0].entity).toEqual(entities[0]);
|
|
466
|
+
expect(points[0].point).toEqual({ id: 'entities/111/attributes/GeoLocation/111', lat: 111, lng: 222 });
|
|
467
|
+
expect(points[1].id).toEqual('entities/111/attributes/GeoLocation/222');
|
|
468
|
+
expect(points[1].entity).toEqual(entities[0]);
|
|
469
|
+
expect(points[1].point).toEqual({ id: 'entities/111/attributes/GeoLocation/222', lat: 333, lng: 444 });
|
|
470
|
+
return [2 /*return*/];
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
}); });
|
|
474
|
+
it('should not consider attributes with masking while constructing point', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
475
|
+
var metadata, points;
|
|
476
|
+
return __generator(this, function (_a) {
|
|
477
|
+
switch (_a.label) {
|
|
478
|
+
case 0:
|
|
479
|
+
metadata = assocPath(['entityTypes', 0, 'attributes', 0, 'attributes', 0, 'masking'], { regex: '***' }, defaultMetadata);
|
|
480
|
+
return [4 /*yield*/, getPointsFromReference(servicesPath, metadata, defaultEntities)];
|
|
481
|
+
case 1:
|
|
482
|
+
points = _a.sent();
|
|
483
|
+
expect(points).toEqual([]);
|
|
484
|
+
return [2 /*return*/];
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
}); });
|
|
488
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Entity, GeoPoint, Metadata } from '@reltio/mdm-sdk';
|
|
2
|
+
type Props = {
|
|
3
|
+
servicesPath: string;
|
|
4
|
+
metadata: Metadata;
|
|
5
|
+
entities: Entity[];
|
|
6
|
+
};
|
|
7
|
+
export declare const resolveMarkers: ({ servicesPath, metadata, entities }: Props) => Promise<GeoPoint[]>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
46
|
+
import { getPointsFromNested } from './nestedHelpers';
|
|
47
|
+
import { getPointsFromReference } from './referenceHelpers';
|
|
48
|
+
import { isEqualGeoPoints } from './helpers';
|
|
49
|
+
export var resolveMarkers = function (_a) {
|
|
50
|
+
var servicesPath = _a.servicesPath, metadata = _a.metadata, entities = _a.entities;
|
|
51
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
+
var nestedResult, refResult;
|
|
53
|
+
return __generator(this, function (_b) {
|
|
54
|
+
switch (_b.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
nestedResult = getPointsFromNested(metadata, entities);
|
|
57
|
+
return [4 /*yield*/, getPointsFromReference(servicesPath, metadata, entities)];
|
|
58
|
+
case 1:
|
|
59
|
+
refResult = _b.sent();
|
|
60
|
+
return [2 /*return*/, __spreadArray(__spreadArray([], nestedResult, true), refResult.filter(function (geoPoint) {
|
|
61
|
+
return !nestedResult.some(function (nestedPoint) { return isEqualGeoPoints(geoPoint, nestedPoint); });
|
|
62
|
+
}), true)];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useSafePromise } from '../useSafePromise';
|
|
3
|
+
import { useMdmMetadata, useMdmServicesPath } from '../../contexts/MdmModuleContext';
|
|
4
|
+
import { filterWrongLat } from './helpers';
|
|
5
|
+
import { resolveMarkers } from './resolveHelpers';
|
|
6
|
+
export var useMarkers = function (entities) {
|
|
7
|
+
var _a = useState([]), markers = _a[0], setMarkers = _a[1];
|
|
8
|
+
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
9
|
+
var safePromise = useSafePromise();
|
|
10
|
+
var metadata = useMdmMetadata();
|
|
11
|
+
var servicesPath = useMdmServicesPath();
|
|
12
|
+
useEffect(function () {
|
|
13
|
+
setLoading(true);
|
|
14
|
+
safePromise(resolveMarkers({ metadata: metadata, servicesPath: servicesPath, entities: entities }))
|
|
15
|
+
.then(function (markers) {
|
|
16
|
+
setMarkers(markers.filter(filterWrongLat));
|
|
17
|
+
})
|
|
18
|
+
.catch(function () {
|
|
19
|
+
setMarkers([]);
|
|
20
|
+
})
|
|
21
|
+
.finally(function () {
|
|
22
|
+
setLoading(false);
|
|
23
|
+
});
|
|
24
|
+
}, [metadata, servicesPath, entities, resolveMarkers, safePromise]);
|
|
25
|
+
return { markers: markers, loading: loading };
|
|
26
|
+
};
|
package/esm/index.d.ts
CHANGED
|
@@ -222,6 +222,7 @@ export { MaskedAttributesProvider, useMaskAttributeValue, useUnmaskAttributeValu
|
|
|
222
222
|
export { RowCollapseContext as BasicTableRowCollapseContext } from './contexts/RowCollapseContext';
|
|
223
223
|
export { BasicTableContext } from './contexts/BasicTableContext';
|
|
224
224
|
export { HiddenAttributesContext } from './contexts/HiddenAttributesContext';
|
|
225
|
+
export { ProfileTablesContext } from './contexts/ProfileTablesContext';
|
|
225
226
|
export { useScrollToAttributeError } from './hooks/useScrollToAttributeError';
|
|
226
227
|
export { useMatchesColumnsData } from './hooks/useMatchesColumnsData';
|
|
227
228
|
export { useActions } from './hooks/useActions';
|
|
@@ -260,7 +261,8 @@ export { useClickableChartStyle as useClickableStyle } from './hooks/useClickabl
|
|
|
260
261
|
export { useDynamicRowCellHeight } from './hooks/useDynamicRowCellHeight';
|
|
261
262
|
export { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
|
262
263
|
export { useMaskedAttribute } from './hooks/useMaskedAttribute';
|
|
263
|
-
export {
|
|
264
|
+
export { useMarkers, resolveMarkers } from './hooks/useMarkers';
|
|
265
|
+
export { buildColumnsFilter, buildColumnsSizeById, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
264
266
|
export { enrichDataWithPercents } from './helpers/charts';
|
|
265
267
|
export { showDefaultErrorMessage, showErrorMessage } from './helpers/errors';
|
|
266
268
|
export { getChecked, getValue, isControlOrCommandPressed } from './helpers/events';
|
|
@@ -268,7 +270,8 @@ export { mergeClasses } from './helpers/classes';
|
|
|
268
270
|
export type { AttributeFiltersComponentProps } from './AttributesFiltersBuilder';
|
|
269
271
|
export type { ChartData } from './types/charts';
|
|
270
272
|
export type { AddInlineAttributeEvent, DeleteInlineAttributeEvent, EditInlineAttributeEvent, IgnoreInlineAttributeEvent, PinInlineAttributeEvent } from './types/inlineAttributes';
|
|
271
|
-
export type { ColumnData, ColumnFilter, Sorting, GroupedColumnsData, GroupedColumns, RenderRowCellProps, RowId, ElementsRowsData, TableRowsData, RowValue } from './types/basicTable';
|
|
273
|
+
export type { ColumnData, ColumnSize, ColumnFilter, Sorting, GroupedColumnsData, GroupedColumns, RenderRowCellProps, RowId, ElementsRowsData, TableRowsData, RowValue } from './types/basicTable';
|
|
274
|
+
export * from './types/preferences';
|
|
272
275
|
export * from './types';
|
|
273
276
|
export * from './constants';
|
|
274
277
|
export { TestPerspectivesSettingsProvider } from './test-utils/TestPerspectiveSettingsProvider';
|