datastake-daf 0.6.775 → 0.6.777
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/dist/components/index.js +2520 -2699
- package/dist/hooks/index.js +0 -72
- package/dist/pages/index.js +279 -287
- package/dist/utils/index.js +0 -13
- package/package.json +1 -1
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +76 -8
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +8 -116
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/utils.js +17 -73
- package/src/@daf/core/components/Dashboard/Map/helper.js +0 -1
- package/src/@daf/core/components/Dashboard/Map/hook.js +29 -53
- package/src/@daf/core/components/Dashboard/Map/style.js +5 -20
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/helper.js +3 -2
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/index.jsx +54 -22
- package/src/@daf/utils/object.js +1 -3
- package/src/hooks.js +1 -2
- package/src/utils.js +1 -1
package/dist/utils/index.js
CHANGED
|
@@ -7211,17 +7211,6 @@ function convertUndefinedToNull(obj) {
|
|
|
7211
7211
|
}
|
|
7212
7212
|
return obj;
|
|
7213
7213
|
}
|
|
7214
|
-
const removeKeysFromObject = (obj = {}, keys = []) => {
|
|
7215
|
-
if (typeof obj !== 'object' || obj === null) return obj;
|
|
7216
|
-
const result = {};
|
|
7217
|
-
for (const key of Object.keys(obj)) {
|
|
7218
|
-
if (!keys.includes(key)) {
|
|
7219
|
-
result[key] = obj[key];
|
|
7220
|
-
}
|
|
7221
|
-
}
|
|
7222
|
-
return result;
|
|
7223
|
-
};
|
|
7224
|
-
const hasKeyInObject = (obj, key) => Object.keys(obj || {}).includes(key);
|
|
7225
7214
|
|
|
7226
7215
|
({
|
|
7227
7216
|
t: PropTypes__default["default"].func,
|
|
@@ -14946,7 +14935,6 @@ exports.handleError = handleError;
|
|
|
14946
14935
|
exports.handleInfo = handleInfo;
|
|
14947
14936
|
exports.handleSuccess = handleSuccess;
|
|
14948
14937
|
exports.handleWarning = handleWarning;
|
|
14949
|
-
exports.hasKeyInObject = hasKeyInObject;
|
|
14950
14938
|
exports.hasNotChanged = hasNotChanged;
|
|
14951
14939
|
exports.isEmptyOrSpaces = isEmptyOrSpaces;
|
|
14952
14940
|
exports.isModuleApproved = isModuleApproved;
|
|
@@ -14962,7 +14950,6 @@ exports.modules = modules;
|
|
|
14962
14950
|
exports.nowToIso = nowToIso;
|
|
14963
14951
|
exports.processConfig = processConfig;
|
|
14964
14952
|
exports.propHasValue = propHasValue;
|
|
14965
|
-
exports.removeKeysFromObject = removeKeysFromObject;
|
|
14966
14953
|
exports.renderBreadCrumbs = renderBreadCrumbs;
|
|
14967
14954
|
exports.renderDateFormatted = renderDateFormatted;
|
|
14968
14955
|
exports.renderNumber = renderNumber;
|
package/package.json
CHANGED
|
@@ -88,10 +88,6 @@ export default function StakeholderIcon({
|
|
|
88
88
|
}, [parentId, allData]);
|
|
89
89
|
|
|
90
90
|
useEffect(() => {
|
|
91
|
-
if (selectedMarkersId.length === 0 || !isSelected) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
91
|
linkNodesData.map((node) => {
|
|
96
92
|
const isConnectingToStakeholder = node.isStakeholder;
|
|
97
93
|
const id = `${data.datastakeId}-${node.stakeholderId || node.datastakeId}`;
|
|
@@ -105,6 +101,13 @@ export default function StakeholderIcon({
|
|
|
105
101
|
const stakeholderLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
|
|
106
102
|
let endLatLng = L.latLng(node.gps.latitude, node.gps.longitude);
|
|
107
103
|
|
|
104
|
+
const areNextToEachOther =
|
|
105
|
+
targetMarkerIndex === index + 1 ||
|
|
106
|
+
targetMarkerIndex === index - 1 ||
|
|
107
|
+
(index === 0 && targetMarkerIndex === node.totalStakeholders - 1) ||
|
|
108
|
+
(targetMarkerIndex === 0 && index === node.totalStakeholders - 1);
|
|
109
|
+
const areOnlyTwoSiblings = node.totalStakeholders === 2;
|
|
110
|
+
|
|
108
111
|
if (isExtraSmallMarker(zoom) && !isForceOpen) {
|
|
109
112
|
createPolyline({
|
|
110
113
|
L,
|
|
@@ -115,7 +118,6 @@ export default function StakeholderIcon({
|
|
|
115
118
|
isSelected,
|
|
116
119
|
id,
|
|
117
120
|
listOfPolylines: polylinesRef.current,
|
|
118
|
-
animated: true,
|
|
119
121
|
});
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
@@ -135,8 +137,75 @@ export default function StakeholderIcon({
|
|
|
135
137
|
y + nodePoint.y + center.top,
|
|
136
138
|
);
|
|
137
139
|
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
140
|
+
|
|
141
|
+
if (isSibling && (!areNextToEachOther || areOnlyTwoSiblings)) {
|
|
142
|
+
if (areOnlyTwoSiblings) {
|
|
143
|
+
buildCurveWIthTwoSiblings({
|
|
144
|
+
mapRef,
|
|
145
|
+
startLatLng: stakeholderLatLng,
|
|
146
|
+
endLatLng,
|
|
147
|
+
zoom,
|
|
148
|
+
isSelected,
|
|
149
|
+
id,
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const total = node.totalStakeholders;
|
|
155
|
+
let from = index;
|
|
156
|
+
let to = targetMarkerIndex;
|
|
157
|
+
let flip = false;
|
|
158
|
+
|
|
159
|
+
const forwardDistance = (to - from + total) % total;
|
|
160
|
+
const backwardDistance = (from - to + total) % total;
|
|
161
|
+
|
|
162
|
+
if (backwardDistance < forwardDistance) {
|
|
163
|
+
[from, to] = [to, from];
|
|
164
|
+
flip = true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const intermediateIndices = [];
|
|
168
|
+
for (let i = 1; i < (to - from + total) % total; i++) {
|
|
169
|
+
intermediateIndices.push((from + i) % total);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const indices = [from, ...intermediateIndices, to];
|
|
173
|
+
|
|
174
|
+
const intermediatePoints = [];
|
|
175
|
+
|
|
176
|
+
for (const i of indices) {
|
|
177
|
+
const { x, y } = createCurvePath({
|
|
178
|
+
zoom,
|
|
179
|
+
totalMarkers: node.totalStakeholders,
|
|
180
|
+
markerIndex: i,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const point = centerPoint.add(L.point(x, y));
|
|
184
|
+
const latlng = mapRef.layerPointToLatLng(point);
|
|
185
|
+
intermediatePoints.push(latlng);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const latlngs = flip
|
|
189
|
+
? [endLatLng, ...intermediatePoints, stakeholderLatLng]
|
|
190
|
+
: [stakeholderLatLng, ...intermediatePoints, endLatLng];
|
|
191
|
+
|
|
192
|
+
const layerPoints = latlngs.map((latlng) => mapRef.latLngToLayerPoint(latlng));
|
|
193
|
+
|
|
194
|
+
const path = buildSmoothCurve(layerPoints, mapRef, flip);
|
|
195
|
+
|
|
196
|
+
const curve = L?.curve?.(path, {
|
|
197
|
+
color: "var(--base-gray-70)",
|
|
198
|
+
weight: isExtraSmallMarker(zoom) ? 0 : 1,
|
|
199
|
+
opacity: isSelected ? 1 : 0.5,
|
|
200
|
+
smoothFactor: 1,
|
|
201
|
+
id,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
mapRef.addLayer(curve);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
138
207
|
}
|
|
139
|
-
|
|
208
|
+
|
|
140
209
|
createPolyline({
|
|
141
210
|
L,
|
|
142
211
|
mapRef,
|
|
@@ -147,10 +216,9 @@ export default function StakeholderIcon({
|
|
|
147
216
|
isSelected,
|
|
148
217
|
id,
|
|
149
218
|
listOfPolylines: polylinesRef.current,
|
|
150
|
-
animated: true,
|
|
151
219
|
});
|
|
152
220
|
});
|
|
153
|
-
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen
|
|
221
|
+
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen]);
|
|
154
222
|
|
|
155
223
|
return (
|
|
156
224
|
<>
|
|
@@ -48,7 +48,6 @@ export default function LocationIcon({
|
|
|
48
48
|
const nodes = [];
|
|
49
49
|
const links = data.links || [];
|
|
50
50
|
|
|
51
|
-
// Add links from the location itself
|
|
52
51
|
links.forEach((link) => {
|
|
53
52
|
allData.forEach((d) => {
|
|
54
53
|
if (d.datastakeId === link) {
|
|
@@ -69,49 +68,8 @@ export default function LocationIcon({
|
|
|
69
68
|
});
|
|
70
69
|
});
|
|
71
70
|
|
|
72
|
-
// ADD: Also include links from this location's stakeholders
|
|
73
|
-
const stakeholders = data.stakeholders || [];
|
|
74
|
-
stakeholders.forEach((stakeholder) => {
|
|
75
|
-
const stakeholderLinks = stakeholder.links || [];
|
|
76
|
-
stakeholderLinks.forEach((link) => {
|
|
77
|
-
allData.forEach((d) => {
|
|
78
|
-
// Check if it's a direct location link
|
|
79
|
-
if (d.datastakeId === link) {
|
|
80
|
-
// Avoid duplicates
|
|
81
|
-
if (!nodes.find(n => n.datastakeId === link && !n.isStakeholder)) {
|
|
82
|
-
nodes.push({
|
|
83
|
-
...d,
|
|
84
|
-
fromStakeholderId: stakeholder.datastakeId,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Check if it's a stakeholder link
|
|
89
|
-
if (d.stakeholders && d.stakeholders.length > 0) {
|
|
90
|
-
d.stakeholders.forEach((targetStakeholder) => {
|
|
91
|
-
if (targetStakeholder.datastakeId === link) {
|
|
92
|
-
// Avoid duplicates
|
|
93
|
-
if (!nodes.find(n =>
|
|
94
|
-
n.isStakeholder &&
|
|
95
|
-
n.datastakeId === d.datastakeId &&
|
|
96
|
-
n.stakeholdersIndex === d.stakeholders.indexOf(targetStakeholder)
|
|
97
|
-
)) {
|
|
98
|
-
nodes.push({
|
|
99
|
-
...d,
|
|
100
|
-
isStakeholder: true,
|
|
101
|
-
totalStakeholders: d.stakeholders.length,
|
|
102
|
-
stakeholdersIndex: d.stakeholders.indexOf(targetStakeholder),
|
|
103
|
-
fromStakeholderId: stakeholder.datastakeId,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
71
|
return nodes;
|
|
114
|
-
}, [JSON.stringify(allData), JSON.stringify(data.links),
|
|
72
|
+
}, [JSON.stringify(allData), JSON.stringify(data.links), zoom]);
|
|
115
73
|
|
|
116
74
|
const stakeholdersOfLocation = useMemo(() => {
|
|
117
75
|
return data?.stakeholders || [];
|
|
@@ -132,16 +90,7 @@ export default function LocationIcon({
|
|
|
132
90
|
currentRoots.clear();
|
|
133
91
|
markersRef.current = [];
|
|
134
92
|
|
|
135
|
-
//
|
|
136
|
-
const shouldShowStakeholders = isSelected || stakeholdersOfLocation.some(stk =>
|
|
137
|
-
selectedMarkersId.includes(stk.datastakeId)
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
if (!shouldShowStakeholders || selectedMarkersId.length === 0) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Create new markers only when selected
|
|
93
|
+
// Create new markers
|
|
145
94
|
stakeholdersOfLocation.forEach((stakeholder, index) => {
|
|
146
95
|
const markerId = `${stakeholder.datastakeId}`;
|
|
147
96
|
const { x, y, radius, center } = getStakeholderPosition({
|
|
@@ -235,8 +184,6 @@ export default function LocationIcon({
|
|
|
235
184
|
isFromStakeholder: true,
|
|
236
185
|
isForceOpen,
|
|
237
186
|
listOfPolylines: polylinesRef.current,
|
|
238
|
-
stakeholderType: stakeholder.type,
|
|
239
|
-
animated: true,
|
|
240
187
|
});
|
|
241
188
|
});
|
|
242
189
|
|
|
@@ -252,67 +199,12 @@ export default function LocationIcon({
|
|
|
252
199
|
rootsMapRef.current.clear();
|
|
253
200
|
markersRef.current = [];
|
|
254
201
|
};
|
|
255
|
-
}, [stakeholdersOfLocation, selectedMarkersId, activeMarker
|
|
202
|
+
}, [stakeholdersOfLocation, selectedMarkersId, activeMarker]);
|
|
256
203
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (selectedMarkersId.length === 0) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// IMPORTANT: Only draw links if this location is actually selected
|
|
264
|
-
// Not just highlighted as part of the chain
|
|
265
|
-
if (!isSelected) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// Filter linkedNodesData to only include nodes that are in the selected chain
|
|
270
|
-
const relevantLinks = linkedNodesData.filter(node => {
|
|
271
|
-
// Check if the target node (location) is in the selected markers
|
|
272
|
-
const targetLocationInSelection = selectedMarkersId.includes(node.datastakeId);
|
|
273
|
-
|
|
274
|
-
// If connecting to a stakeholder, check if that stakeholder is selected
|
|
275
|
-
if (node.isStakeholder) {
|
|
276
|
-
const stakeholderInSelection = node.stakeholdersIndex !== undefined &&
|
|
277
|
-
selectedMarkersId.includes(node.datastakeId);
|
|
278
|
-
return stakeholderInSelection;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return targetLocationInSelection;
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
relevantLinks.forEach((node) => {
|
|
285
|
-
const id = node.fromStakeholderId
|
|
286
|
-
? `${node.fromStakeholderId}-${node.datastakeId}`
|
|
287
|
-
: `${data.datastakeId}-${node.datastakeId}`;
|
|
204
|
+
linkedNodesData.map((node) => {
|
|
205
|
+
const id = `${data.datastakeId}-${node.datastakeId}`;
|
|
288
206
|
const isConnectingToStakeholder = node.isStakeholder;
|
|
289
|
-
|
|
290
|
-
// If the link is from a stakeholder, start from the stakeholder position
|
|
291
|
-
let startLatLng;
|
|
292
|
-
if (node.fromStakeholderId) {
|
|
293
|
-
// Find the stakeholder index in this location's stakeholders
|
|
294
|
-
const stakeholderIndex = stakeholdersOfLocation.findIndex(
|
|
295
|
-
s => s.datastakeId === node.fromStakeholderId
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
if (stakeholderIndex !== -1) {
|
|
299
|
-
const { x, y } = getStakeholderPosition({
|
|
300
|
-
zoom,
|
|
301
|
-
totalMarkers: stakeholdersOfLocation.length,
|
|
302
|
-
markerIndex: stakeholderIndex,
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
const centerLatLng = L.latLng(data.gps.latitude, data.gps.longitude);
|
|
306
|
-
const centerPoint = mapRef.latLngToLayerPoint(centerLatLng);
|
|
307
|
-
const stakeholderPoint = centerPoint.add(L.point(x, y));
|
|
308
|
-
startLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
|
|
309
|
-
} else {
|
|
310
|
-
startLatLng = L.latLng(data.gps.latitude, data.gps.longitude);
|
|
311
|
-
}
|
|
312
|
-
} else {
|
|
313
|
-
startLatLng = L.latLng(data.gps.latitude, data.gps.longitude);
|
|
314
|
-
}
|
|
315
|
-
|
|
207
|
+
const centerLatLng = L.latLng(data.gps.latitude, data.gps.longitude);
|
|
316
208
|
let endLatLng = L.latLng(node.gps.latitude, node.gps.longitude);
|
|
317
209
|
const isConnectingToStakeholderSelected = selectedMarkersId.includes(node.datastakeId);
|
|
318
210
|
|
|
@@ -333,15 +225,15 @@ useEffect(() => {
|
|
|
333
225
|
createPolyline({
|
|
334
226
|
L,
|
|
335
227
|
mapRef,
|
|
336
|
-
startLatLng,
|
|
228
|
+
startLatLng: centerLatLng,
|
|
337
229
|
endLatLng,
|
|
230
|
+
|
|
338
231
|
isSelected: isConnectingToStakeholderSelected,
|
|
339
232
|
id,
|
|
340
233
|
zoom,
|
|
341
234
|
listOfPolylines: polylinesRef.current,
|
|
342
235
|
});
|
|
343
236
|
});
|
|
344
|
-
}, [linkedNodesData, selectedMarkersId, zoom, stakeholdersOfLocation, isSelected]);
|
|
345
237
|
|
|
346
238
|
return (
|
|
347
239
|
<Popover
|
|
@@ -5,14 +5,13 @@ const VILLAGE = "village";
|
|
|
5
5
|
const EXPORTER = "exporter";
|
|
6
6
|
const PROCESSOR = "mineralProcessor";
|
|
7
7
|
const DEPOT = "depot";
|
|
8
|
-
const OPERATOR = "miningOperator";
|
|
9
8
|
|
|
10
9
|
const MAX_EXTRA_SMALL_ZOOM_THRESHOLD = 2;
|
|
11
10
|
const MAX_SMALL_ZOOM_THRESHOLD = 3;
|
|
12
11
|
const MAX_MEDIUM_ZOOM_THRESHOLD = 6;
|
|
13
12
|
|
|
14
13
|
const LOCATION_TYPES = [MINE_SITE, VILLAGE];
|
|
15
|
-
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT
|
|
14
|
+
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT];
|
|
16
15
|
|
|
17
16
|
const RADIUS_SMALL = 15;
|
|
18
17
|
const RADIUS_MEDIUM = 35;
|
|
@@ -101,6 +100,7 @@ export function getStakeholderPosition({ zoom, totalMarkers, markerIndex }) {
|
|
|
101
100
|
|
|
102
101
|
let radius;
|
|
103
102
|
let center = {
|
|
103
|
+
// NOT BEING USED FOR NOW AND MAYBE NEVER
|
|
104
104
|
left: 0,
|
|
105
105
|
top: 0,
|
|
106
106
|
};
|
|
@@ -117,32 +117,6 @@ export function getStakeholderPosition({ zoom, totalMarkers, markerIndex }) {
|
|
|
117
117
|
return { x, y, center, radius, angleDeg };
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
function applyAnimationDirect(el, isShortLink) {
|
|
121
|
-
if (!(el instanceof SVGElement) || isShortLink) return;
|
|
122
|
-
|
|
123
|
-
el.style.strokeDasharray = "10, 10";
|
|
124
|
-
el.style.strokeDashoffset = "0";
|
|
125
|
-
|
|
126
|
-
el.style.animation = "dash-flow 1.2s linear infinite";
|
|
127
|
-
|
|
128
|
-
el.classList.add('animated-polyline');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function removeAnimationFromElement(element) {
|
|
132
|
-
if (!element) return;
|
|
133
|
-
|
|
134
|
-
element.classList.remove('animated-polyline');
|
|
135
|
-
element.style.animation = '';
|
|
136
|
-
element.style.strokeDasharray = '';
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function applyAnimationToPolyline(polyline, isShortLink) {
|
|
140
|
-
const element = polyline.getElement();
|
|
141
|
-
if (element) {
|
|
142
|
-
applyAnimationDirect(element, isShortLink);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
120
|
export function createPolyline({
|
|
147
121
|
L,
|
|
148
122
|
startLatLng,
|
|
@@ -153,62 +127,32 @@ export function createPolyline({
|
|
|
153
127
|
listOfPolylines = [],
|
|
154
128
|
isFromStakeholder = false,
|
|
155
129
|
isForceOpen = false,
|
|
156
|
-
stakeholderType = null,
|
|
157
|
-
animated = false,
|
|
158
|
-
mapRef
|
|
159
130
|
}) {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
const isShortLink = stakeholderType === OPERATOR || isFromStakeholder;
|
|
163
|
-
const shouldAnimate = animated;
|
|
131
|
+
const width = isFromStakeholder && isExtraSmallMarker(zoom) && !isForceOpen ? 0 : 1.2;
|
|
164
132
|
|
|
165
|
-
const
|
|
133
|
+
const coordinates = [
|
|
166
134
|
[startLatLng.lat, startLatLng.lng],
|
|
167
135
|
[endLatLng.lat, endLatLng.lng],
|
|
168
136
|
];
|
|
169
|
-
|
|
170
|
-
const polylineStyle = {
|
|
137
|
+
const style = {
|
|
171
138
|
color: "var(--base-gray-70)",
|
|
172
|
-
weight:
|
|
173
|
-
opacity:
|
|
174
|
-
smoothFactor:
|
|
139
|
+
weight: width,
|
|
140
|
+
opacity: 0.5,
|
|
141
|
+
smoothFactor: 1,
|
|
175
142
|
id,
|
|
176
|
-
dashArray:
|
|
177
|
-
renderer: L.svg()
|
|
143
|
+
dashArray: !isSelected ? "5, 5" : "0, 0",
|
|
178
144
|
};
|
|
179
145
|
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
if (existingPolyline) {
|
|
183
|
-
removeAnimationFromElement(existingPolyline.getElement());
|
|
184
|
-
|
|
185
|
-
existingPolyline.setLatLngs(lineCoordinates);
|
|
186
|
-
existingPolyline.setStyle(polylineStyle);
|
|
187
|
-
|
|
188
|
-
if (shouldAnimate && isSelected) {
|
|
189
|
-
existingPolyline.once('add', () => {
|
|
190
|
-
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return existingPolyline;
|
|
197
|
-
}
|
|
146
|
+
const newPolyline = L.polyline(coordinates, style);
|
|
198
147
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
newPolyline.once('add', () => {
|
|
206
|
-
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
148
|
+
if (listOfPolylines.find((p) => p.options.id === id)) {
|
|
149
|
+
const polylineToUpdateCoordinates = listOfPolylines.find((p) => p.options.id === id);
|
|
150
|
+
polylineToUpdateCoordinates.setLatLngs(coordinates);
|
|
151
|
+
polylineToUpdateCoordinates.setStyle(style);
|
|
152
|
+
} else {
|
|
153
|
+
listOfPolylines.push(newPolyline);
|
|
210
154
|
}
|
|
211
|
-
|
|
155
|
+
|
|
212
156
|
return newPolyline;
|
|
213
157
|
}
|
|
214
158
|
|
|
@@ -31,7 +31,7 @@ export const useMap = ({
|
|
|
31
31
|
const container = createRef();
|
|
32
32
|
const [data, setData] = useState([]);
|
|
33
33
|
const [mapRef, setMapRef] = useState(null);
|
|
34
|
-
const { TILE_LAYER_URL, MAP_TOKEN } = useMapConfig({ app, isSatellite
|
|
34
|
+
const { TILE_LAYER_URL, MAP_TOKEN } = useMapConfig({ app, isSatellite });
|
|
35
35
|
const [initialMarkerSetIsDone, setInitialMarkerSetIsDone] = useState(false);
|
|
36
36
|
const [mapCenter, setMapCenter] = useState([0, 0]);
|
|
37
37
|
const [emptyStateIsVisible, setEmptyStateIsVisible] = useState(false);
|
|
@@ -48,7 +48,6 @@ export const useMap = ({
|
|
|
48
48
|
const stakeToLoc = new Map();
|
|
49
49
|
const nodeTypes = new Map();
|
|
50
50
|
|
|
51
|
-
// Build the graph
|
|
52
51
|
for (const loc of data) {
|
|
53
52
|
const locId = loc.datastakeId;
|
|
54
53
|
nodeTypes.set(locId, loc.type);
|
|
@@ -82,45 +81,34 @@ export const useMap = ({
|
|
|
82
81
|
|
|
83
82
|
const highlightTable = {};
|
|
84
83
|
|
|
85
|
-
// Perform BFS/DFS to find all connected nodes in the entire chain
|
|
86
84
|
for (const [node] of graph) {
|
|
87
85
|
const highlighted = new Set();
|
|
88
|
-
const queue = [node];
|
|
89
|
-
const visited = new Set([node]);
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
visited.add(parentLoc);
|
|
102
|
-
queue.push(parentLoc);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
87
|
+
highlighted.add(node);
|
|
88
|
+
|
|
89
|
+
const nodeIsStakeholder = !isLocation(nodeTypes.get(node));
|
|
90
|
+
if (nodeIsStakeholder && stakeToLoc.has(node)) {
|
|
91
|
+
const parentLoc = stakeToLoc.get(node);
|
|
92
|
+
highlighted.add(parentLoc);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
for (const neighbor of graph.get(node) || []) {
|
|
96
|
+
const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
|
|
105
97
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
98
|
+
if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
|
|
99
|
+
const neighborParent = stakeToLoc.get(neighbor);
|
|
100
|
+
|
|
101
|
+
if (
|
|
102
|
+
(isLocation(nodeTypes.get(node)) && neighborParent === node) ||
|
|
103
|
+
(nodeIsStakeholder && stakeToLoc.get(node) === neighborParent)
|
|
104
|
+
) {
|
|
105
|
+
highlighted.add(neighbor);
|
|
106
|
+
} else {
|
|
111
107
|
highlighted.add(neighbor);
|
|
112
|
-
|
|
113
|
-
// If neighbor is stakeholder, add its parent location
|
|
114
|
-
const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
|
|
115
|
-
if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
|
|
116
|
-
const neighborParent = stakeToLoc.get(neighbor);
|
|
117
|
-
if (!visited.has(neighborParent)) {
|
|
118
|
-
highlighted.add(neighborParent);
|
|
119
|
-
visited.add(neighborParent);
|
|
120
|
-
queue.push(neighborParent);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
108
|
+
highlighted.add(neighborParent);
|
|
123
109
|
}
|
|
110
|
+
} else {
|
|
111
|
+
highlighted.add(neighbor);
|
|
124
112
|
}
|
|
125
113
|
}
|
|
126
114
|
|
|
@@ -203,22 +191,12 @@ export const useMap = ({
|
|
|
203
191
|
});
|
|
204
192
|
}
|
|
205
193
|
}
|
|
206
|
-
|
|
207
|
-
if (type === "chain" && selectedMarkersId.length === 0) {
|
|
208
|
-
if (polylinesRef.current.length) {
|
|
209
|
-
polylinesRef.current.forEach((polyline) => {
|
|
210
|
-
if (mapRef.hasLayer(polyline)) {
|
|
211
|
-
mapRef.removeLayer(polyline);
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
polylinesRef.current = [];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
194
|
clearMapMarkers();
|
|
219
195
|
if (data) {
|
|
196
|
+
// Filters out locations that are not connected to any stakeholders
|
|
197
|
+
const excludedType = ['village', 'town', 'area', 'territory']
|
|
220
198
|
const filteredData = data?.filter((obj) =>
|
|
221
|
-
obj
|
|
199
|
+
!excludedType.includes(obj?.type) && (obj?.stakeholders?.length > 0 ||
|
|
222
200
|
data.some((other) =>
|
|
223
201
|
other.datastakeId !== obj.datastakeId &&
|
|
224
202
|
(other.stakeholders || []).some((stk) =>
|
|
@@ -240,11 +218,9 @@ export const useMap = ({
|
|
|
240
218
|
);
|
|
241
219
|
});
|
|
242
220
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
}
|
|
221
|
+
polylinesRef.current.forEach((polyline) => {
|
|
222
|
+
mapRef.addLayer(polyline);
|
|
223
|
+
});
|
|
248
224
|
|
|
249
225
|
mapRef.invalidateSize();
|
|
250
226
|
mapRef.fire("moveend");
|
|
@@ -7,8 +7,6 @@ const Style = styled.div`
|
|
|
7
7
|
width: 100%;
|
|
8
8
|
height: 472px;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
10
|
.filter-cont {
|
|
13
11
|
position: absolute;
|
|
14
12
|
top: 24px;
|
|
@@ -111,24 +109,11 @@ const Style = styled.div`
|
|
|
111
109
|
align-items: center;
|
|
112
110
|
}
|
|
113
111
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
.animated-polyline {
|
|
121
|
-
stroke-dasharray: 10 10;
|
|
122
|
-
animation: dash-flow 1.5s linear infinite;
|
|
123
|
-
stroke-linecap: round;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@keyframes dash-flow {
|
|
127
|
-
to {
|
|
128
|
-
stroke-dashoffset: -20;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
112
|
+
.marker-chain {
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
}
|
|
132
117
|
|
|
133
118
|
}
|
|
134
119
|
|
|
@@ -87,9 +87,10 @@ export const calculateHealthAndSafetyPieData = (healthAndSafetyDistributionData,
|
|
|
87
87
|
* @param {Object} healthAndSafetyDistributionData - Distribution object
|
|
88
88
|
* @param {Function} t - Translation function
|
|
89
89
|
* @param {Function} renderTooltipJsx - Function to render tooltip JSX
|
|
90
|
+
* @param {string} tooltipTitle - Title to display in the tooltip (defaults to "Health and Safety")
|
|
90
91
|
* @returns {JSX.Element|null} Tooltip content or null
|
|
91
92
|
*/
|
|
92
|
-
export const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafetyDistributionData, t, renderTooltipJsx) => {
|
|
93
|
+
export const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafetyDistributionData, t, renderTooltipJsx, tooltipTitle = "Health and Safety") => {
|
|
93
94
|
// If empty or no data, return null to display nothing
|
|
94
95
|
if (isEmpty || !Object.keys(healthAndSafetyDistributionData).length) {
|
|
95
96
|
return null;
|
|
@@ -129,7 +130,7 @@ export const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafety
|
|
|
129
130
|
|
|
130
131
|
// Show all items with their percentages
|
|
131
132
|
return renderTooltipJsx({
|
|
132
|
-
title: t(
|
|
133
|
+
title: t(tooltipTitle),
|
|
133
134
|
items: itemsWithData,
|
|
134
135
|
});
|
|
135
136
|
};
|