datastake-daf 0.6.780 → 0.6.781
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 +314 -369
- package/dist/pages/index.js +232 -2049
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/dist/utils/index.js +0 -13
- package/package.json +1 -1
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +76 -9
- 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 -64
- package/src/@daf/core/components/Dashboard/Map/style.js +5 -20
- package/src/@daf/hooks/useViewFormUrlParams.js +84 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/PlantingLocations/index.jsx +168 -163
- package/src/@daf/utils/object.js +1 -3
- package/src/pages.js +1 -4
- package/src/utils.js +1 -1
- package/src/@daf/pages/View/hooks/useCallToGetData.js +0 -73
- package/src/@daf/pages/View/hooks/usePrepareForm.js +0 -86
- package/src/@daf/pages/View/hooks/useSubmitSubject.js +0 -40
- package/src/@daf/pages/View/hooks/useViewActions.js +0 -83
- package/src/@daf/pages/View/hooks/useViewPermissions.js +0 -75
- package/src/@daf/pages/View/hooks/useViewUrlParams.js +0 -93
- package/src/@daf/pages/View/index.jsx +0 -286
package/dist/pages/index.js
CHANGED
|
@@ -5295,12 +5295,6 @@ const createNumberArray = i => {
|
|
|
5295
5295
|
return numbers;
|
|
5296
5296
|
};
|
|
5297
5297
|
const tooltipInputs = ["text", "phoneNumber", "textarea", "percentage", "number", "select", "ajaxSelect", "switch", "multiselect", "radioGroup", "date", "year"];
|
|
5298
|
-
const formPaths = {
|
|
5299
|
-
edit: (mod, getRedirectLink) => typeof getRedirectLink === "function" ? getRedirectLink(`/app/edit/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?`) : `/app/${mod}/edit/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?`,
|
|
5300
|
-
view: (mod, getRedirectLink) => typeof getRedirectLink === "function" ? getRedirectLink(`/app/view/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?`) : `/app/${mod}/view/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?`,
|
|
5301
|
-
viewDD: mod => `/app/${mod}/viewdd/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?`,
|
|
5302
|
-
editDD: mod => `/app/${mod}/editdd/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?`
|
|
5303
|
-
};
|
|
5304
5298
|
const CREATE_DRAWER_WIDTH = 480;
|
|
5305
5299
|
const MAX_COMMENTS_LENGTH = 1200;
|
|
5306
5300
|
const MAX_TEXT_AREA_LENGTH = 1200;
|
|
@@ -7576,8 +7570,6 @@ const Style$f = styled__default["default"].div`
|
|
|
7576
7570
|
width: 100%;
|
|
7577
7571
|
height: 472px;
|
|
7578
7572
|
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
7573
|
.filter-cont {
|
|
7582
7574
|
position: absolute;
|
|
7583
7575
|
top: 24px;
|
|
@@ -7680,24 +7672,11 @@ const Style$f = styled__default["default"].div`
|
|
|
7680
7672
|
align-items: center;
|
|
7681
7673
|
}
|
|
7682
7674
|
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
.animated-polyline {
|
|
7690
|
-
stroke-dasharray: 10 10;
|
|
7691
|
-
animation: dash-flow 1.5s linear infinite;
|
|
7692
|
-
stroke-linecap: round;
|
|
7693
|
-
}
|
|
7694
|
-
|
|
7695
|
-
@keyframes dash-flow {
|
|
7696
|
-
to {
|
|
7697
|
-
stroke-dashoffset: -20;
|
|
7698
|
-
}
|
|
7699
|
-
}
|
|
7700
|
-
|
|
7675
|
+
.marker-chain {
|
|
7676
|
+
display: flex;
|
|
7677
|
+
align-items: center;
|
|
7678
|
+
justify-content: center;
|
|
7679
|
+
}
|
|
7701
7680
|
|
|
7702
7681
|
}
|
|
7703
7682
|
|
|
@@ -8221,15 +8200,18 @@ const VILLAGE = "village";
|
|
|
8221
8200
|
const EXPORTER = "exporter";
|
|
8222
8201
|
const PROCESSOR = "mineralProcessor";
|
|
8223
8202
|
const DEPOT = "depot";
|
|
8224
|
-
const OPERATOR = "miningOperator";
|
|
8225
8203
|
const MAX_EXTRA_SMALL_ZOOM_THRESHOLD = 2;
|
|
8226
8204
|
const MAX_SMALL_ZOOM_THRESHOLD = 3;
|
|
8227
8205
|
const MAX_MEDIUM_ZOOM_THRESHOLD = 6;
|
|
8228
8206
|
const LOCATION_TYPES = [MINE_SITE, VILLAGE];
|
|
8229
|
-
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT
|
|
8207
|
+
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT];
|
|
8230
8208
|
const RADIUS_SMALL = 15;
|
|
8231
8209
|
const RADIUS_MEDIUM = 35;
|
|
8232
8210
|
const RADIUS_LARGE = 60;
|
|
8211
|
+
const RADIUS_CURVE_SMALL = 10;
|
|
8212
|
+
const RADIUS_CURVE_MEDIUM = 15;
|
|
8213
|
+
const RADIUS_CURVE_LARGE = 20;
|
|
8214
|
+
const TENSION = 0.2;
|
|
8233
8215
|
function isLocation(type) {
|
|
8234
8216
|
return LOCATION_TYPES.includes(type);
|
|
8235
8217
|
}
|
|
@@ -8286,6 +8268,7 @@ function getStakeholderPosition({
|
|
|
8286
8268
|
const isLarge = isLargeMarker(zoom);
|
|
8287
8269
|
let radius;
|
|
8288
8270
|
let center = {
|
|
8271
|
+
// NOT BEING USED FOR NOW AND MAYBE NEVER
|
|
8289
8272
|
left: 0,
|
|
8290
8273
|
top: 0
|
|
8291
8274
|
};
|
|
@@ -8309,25 +8292,6 @@ function getStakeholderPosition({
|
|
|
8309
8292
|
angleDeg
|
|
8310
8293
|
};
|
|
8311
8294
|
}
|
|
8312
|
-
function applyAnimationDirect(el, isShortLink) {
|
|
8313
|
-
if (!(el instanceof SVGElement) || isShortLink) return;
|
|
8314
|
-
el.style.strokeDasharray = "10, 10";
|
|
8315
|
-
el.style.strokeDashoffset = "0";
|
|
8316
|
-
el.style.animation = "dash-flow 1.2s linear infinite";
|
|
8317
|
-
el.classList.add('animated-polyline');
|
|
8318
|
-
}
|
|
8319
|
-
function removeAnimationFromElement(element) {
|
|
8320
|
-
if (!element) return;
|
|
8321
|
-
element.classList.remove('animated-polyline');
|
|
8322
|
-
element.style.animation = '';
|
|
8323
|
-
element.style.strokeDasharray = '';
|
|
8324
|
-
}
|
|
8325
|
-
function applyAnimationToPolyline(polyline, isShortLink) {
|
|
8326
|
-
const element = polyline.getElement();
|
|
8327
|
-
if (element) {
|
|
8328
|
-
applyAnimationDirect(element, isShortLink);
|
|
8329
|
-
}
|
|
8330
|
-
}
|
|
8331
8295
|
function createPolyline({
|
|
8332
8296
|
L,
|
|
8333
8297
|
startLatLng,
|
|
@@ -8337,48 +8301,110 @@ function createPolyline({
|
|
|
8337
8301
|
zoom,
|
|
8338
8302
|
listOfPolylines = [],
|
|
8339
8303
|
isFromStakeholder = false,
|
|
8340
|
-
isForceOpen = false
|
|
8341
|
-
stakeholderType = null,
|
|
8342
|
-
animated = false,
|
|
8343
|
-
mapRef
|
|
8304
|
+
isForceOpen = false
|
|
8344
8305
|
}) {
|
|
8345
|
-
const
|
|
8346
|
-
const
|
|
8347
|
-
const
|
|
8348
|
-
const lineCoordinates = [[startLatLng.lat, startLatLng.lng], [endLatLng.lat, endLatLng.lng]];
|
|
8349
|
-
const polylineStyle = {
|
|
8306
|
+
const width = isFromStakeholder && isExtraSmallMarker(zoom) && !isForceOpen ? 0 : 1.2;
|
|
8307
|
+
const coordinates = [[startLatLng.lat, startLatLng.lng], [endLatLng.lat, endLatLng.lng]];
|
|
8308
|
+
const style = {
|
|
8350
8309
|
color: "var(--base-gray-70)",
|
|
8351
|
-
weight:
|
|
8352
|
-
opacity:
|
|
8353
|
-
smoothFactor:
|
|
8310
|
+
weight: width,
|
|
8311
|
+
opacity: 0.5,
|
|
8312
|
+
smoothFactor: 1,
|
|
8354
8313
|
id,
|
|
8355
|
-
dashArray:
|
|
8356
|
-
renderer: L.svg()
|
|
8314
|
+
dashArray: !isSelected ? "5, 5" : "0, 0"
|
|
8357
8315
|
};
|
|
8358
|
-
const
|
|
8359
|
-
if (
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
8366
|
-
});
|
|
8367
|
-
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
8368
|
-
}
|
|
8369
|
-
return existingPolyline;
|
|
8370
|
-
}
|
|
8371
|
-
const newPolyline = L.polyline(lineCoordinates, polylineStyle);
|
|
8372
|
-
newPolyline.addTo(mapRef);
|
|
8373
|
-
listOfPolylines.push(newPolyline);
|
|
8374
|
-
if (shouldAnimate && isSelected) {
|
|
8375
|
-
newPolyline.once('add', () => {
|
|
8376
|
-
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
8377
|
-
});
|
|
8378
|
-
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
8316
|
+
const newPolyline = L.polyline(coordinates, style);
|
|
8317
|
+
if (listOfPolylines.find(p => p.options.id === id)) {
|
|
8318
|
+
const polylineToUpdateCoordinates = listOfPolylines.find(p => p.options.id === id);
|
|
8319
|
+
polylineToUpdateCoordinates.setLatLngs(coordinates);
|
|
8320
|
+
polylineToUpdateCoordinates.setStyle(style);
|
|
8321
|
+
} else {
|
|
8322
|
+
listOfPolylines.push(newPolyline);
|
|
8379
8323
|
}
|
|
8380
8324
|
return newPolyline;
|
|
8381
8325
|
}
|
|
8326
|
+
function createCurvePath({
|
|
8327
|
+
zoom,
|
|
8328
|
+
totalMarkers,
|
|
8329
|
+
markerIndex
|
|
8330
|
+
}) {
|
|
8331
|
+
const radius = getCurvePointRadius(zoom);
|
|
8332
|
+
const {
|
|
8333
|
+
x,
|
|
8334
|
+
y,
|
|
8335
|
+
angleDeg
|
|
8336
|
+
} = getAngleDeg(totalMarkers, markerIndex, radius);
|
|
8337
|
+
return {
|
|
8338
|
+
x,
|
|
8339
|
+
y,
|
|
8340
|
+
angleDeg
|
|
8341
|
+
};
|
|
8342
|
+
}
|
|
8343
|
+
function getCurvePointRadius(zoom) {
|
|
8344
|
+
const isSmall = isSmallMarker(zoom) || isExtraSmallMarker(zoom);
|
|
8345
|
+
const isMedium = isMediumMarker(zoom);
|
|
8346
|
+
if (isSmall) {
|
|
8347
|
+
return RADIUS_SMALL + RADIUS_CURVE_SMALL;
|
|
8348
|
+
} else if (isMedium) {
|
|
8349
|
+
return RADIUS_MEDIUM + RADIUS_CURVE_MEDIUM;
|
|
8350
|
+
} else {
|
|
8351
|
+
return RADIUS_LARGE + RADIUS_CURVE_LARGE;
|
|
8352
|
+
}
|
|
8353
|
+
}
|
|
8354
|
+
function buildSmoothCurve(layerPoints, mapRef) {
|
|
8355
|
+
const path = [];
|
|
8356
|
+
for (let i = 0; i < layerPoints.length - 1; i++) {
|
|
8357
|
+
const p0 = layerPoints[i];
|
|
8358
|
+
const p1 = layerPoints[i + 1];
|
|
8359
|
+
const pPrev = layerPoints[i - 1] || p0;
|
|
8360
|
+
const pNext = layerPoints[i + 2] || p1;
|
|
8361
|
+
const cp1 = L__namespace.point(p0.x + (p1.x - pPrev.x) * TENSION, p0.y + (p1.y - pPrev.y) * TENSION);
|
|
8362
|
+
const cp2 = L__namespace.point(p1.x - (pNext.x - p0.x) * TENSION, p1.y - (pNext.y - p0.y) * TENSION);
|
|
8363
|
+
if (i === 0) {
|
|
8364
|
+
path.push("M", [mapRef.layerPointToLatLng(p0).lat, mapRef.layerPointToLatLng(p0).lng]);
|
|
8365
|
+
}
|
|
8366
|
+
path.push("C", [mapRef.layerPointToLatLng(cp1).lat, mapRef.layerPointToLatLng(cp1).lng], [mapRef.layerPointToLatLng(cp2).lat, mapRef.layerPointToLatLng(cp2).lng], [mapRef.layerPointToLatLng(p1).lat, mapRef.layerPointToLatLng(p1).lng]);
|
|
8367
|
+
}
|
|
8368
|
+
return path;
|
|
8369
|
+
}
|
|
8370
|
+
function getSiblingCurveStrength(zoom) {
|
|
8371
|
+
if (isExtraSmallMarker(zoom)) return RADIUS_CURVE_SMALL / 2;
|
|
8372
|
+
if (isSmallMarker(zoom)) return RADIUS_CURVE_MEDIUM;
|
|
8373
|
+
if (isMediumMarker(zoom)) return RADIUS_CURVE_LARGE;
|
|
8374
|
+
return RADIUS_CURVE_LARGE;
|
|
8375
|
+
}
|
|
8376
|
+
function buildCurveWIthTwoSiblings({
|
|
8377
|
+
mapRef,
|
|
8378
|
+
startLatLng,
|
|
8379
|
+
endLatLng,
|
|
8380
|
+
zoom,
|
|
8381
|
+
isSelected,
|
|
8382
|
+
id
|
|
8383
|
+
}) {
|
|
8384
|
+
const fromPoint = mapRef.latLngToLayerPoint(startLatLng);
|
|
8385
|
+
const toPoint = mapRef.latLngToLayerPoint(endLatLng);
|
|
8386
|
+
const midX = (fromPoint.x + toPoint.x) / 2;
|
|
8387
|
+
const midY = (fromPoint.y + toPoint.y) / 2 + (isSmallMarker(zoom) ? RADIUS_CURVE_SMALL / 2 : 0);
|
|
8388
|
+
const dx = toPoint.x - fromPoint.x;
|
|
8389
|
+
const dy = toPoint.y - fromPoint.y;
|
|
8390
|
+
const normal = L__namespace.point(-dy, dx);
|
|
8391
|
+
const length = Math.sqrt(normal.x ** 2 + normal.y ** 2) || 1;
|
|
8392
|
+
const normalized = normal.multiplyBy(1 / length);
|
|
8393
|
+
const curveStrength = getSiblingCurveStrength(zoom);
|
|
8394
|
+
const controlPoint = L__namespace.point(midX, midY).add(normalized.multiplyBy(curveStrength));
|
|
8395
|
+
const latlngs = [startLatLng, mapRef.layerPointToLatLng(controlPoint), endLatLng];
|
|
8396
|
+
const layerPoints = latlngs.map(latlng => mapRef.latLngToLayerPoint(latlng));
|
|
8397
|
+
const path = buildSmoothCurve(layerPoints, mapRef);
|
|
8398
|
+
const curve = L__namespace.curve(path, {
|
|
8399
|
+
color: "var(--base-gray-70)",
|
|
8400
|
+
weight: isExtraSmallMarker(zoom) ? 0 : 1.2,
|
|
8401
|
+
opacity: 0.5,
|
|
8402
|
+
smoothFactor: 1,
|
|
8403
|
+
id,
|
|
8404
|
+
dashArray: !isSelected ? "5, 5" : "0, 0"
|
|
8405
|
+
});
|
|
8406
|
+
mapRef.addLayer(curve);
|
|
8407
|
+
}
|
|
8382
8408
|
|
|
8383
8409
|
const StakeholderMarker = styled__default["default"].div`
|
|
8384
8410
|
background-color: var(--blue-50);
|
|
@@ -8679,9 +8705,6 @@ function StakeholderIcon$1({
|
|
|
8679
8705
|
return null;
|
|
8680
8706
|
}, [parentId, allData]);
|
|
8681
8707
|
React.useEffect(() => {
|
|
8682
|
-
if (selectedMarkersId.length === 0 || !isSelected) {
|
|
8683
|
-
return;
|
|
8684
|
-
}
|
|
8685
8708
|
linkNodesData.map(node => {
|
|
8686
8709
|
const isConnectingToStakeholder = node.isStakeholder;
|
|
8687
8710
|
const id = `${data.datastakeId}-${node.stakeholderId || node.datastakeId}`;
|
|
@@ -8693,6 +8716,8 @@ function StakeholderIcon$1({
|
|
|
8693
8716
|
const stakeholderPoint = centerPoint.add(L__namespace.point(x, y));
|
|
8694
8717
|
const stakeholderLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
|
|
8695
8718
|
let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
8719
|
+
const areNextToEachOther = targetMarkerIndex === index + 1 || targetMarkerIndex === index - 1 || index === 0 && targetMarkerIndex === node.totalStakeholders - 1 || targetMarkerIndex === 0 && index === node.totalStakeholders - 1;
|
|
8720
|
+
const areOnlyTwoSiblings = node.totalStakeholders === 2;
|
|
8696
8721
|
if (isExtraSmallMarker(zoom) && !isForceOpen) {
|
|
8697
8722
|
createPolyline({
|
|
8698
8723
|
L: L__namespace,
|
|
@@ -8702,8 +8727,7 @@ function StakeholderIcon$1({
|
|
|
8702
8727
|
zoom,
|
|
8703
8728
|
isSelected,
|
|
8704
8729
|
id,
|
|
8705
|
-
listOfPolylines: polylinesRef.current
|
|
8706
|
-
animated: true
|
|
8730
|
+
listOfPolylines: polylinesRef.current
|
|
8707
8731
|
});
|
|
8708
8732
|
return;
|
|
8709
8733
|
}
|
|
@@ -8721,8 +8745,61 @@ function StakeholderIcon$1({
|
|
|
8721
8745
|
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
8722
8746
|
const endPoint = L__namespace.point(x + nodePoint.x + center.left, y + nodePoint.y + center.top);
|
|
8723
8747
|
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
8748
|
+
if (isSibling && (!areNextToEachOther || areOnlyTwoSiblings)) {
|
|
8749
|
+
if (areOnlyTwoSiblings) {
|
|
8750
|
+
buildCurveWIthTwoSiblings({
|
|
8751
|
+
mapRef,
|
|
8752
|
+
startLatLng: stakeholderLatLng,
|
|
8753
|
+
endLatLng,
|
|
8754
|
+
zoom,
|
|
8755
|
+
isSelected,
|
|
8756
|
+
id
|
|
8757
|
+
});
|
|
8758
|
+
return;
|
|
8759
|
+
}
|
|
8760
|
+
const total = node.totalStakeholders;
|
|
8761
|
+
let from = index;
|
|
8762
|
+
let to = targetMarkerIndex;
|
|
8763
|
+
let flip = false;
|
|
8764
|
+
const forwardDistance = (to - from + total) % total;
|
|
8765
|
+
const backwardDistance = (from - to + total) % total;
|
|
8766
|
+
if (backwardDistance < forwardDistance) {
|
|
8767
|
+
[from, to] = [to, from];
|
|
8768
|
+
flip = true;
|
|
8769
|
+
}
|
|
8770
|
+
const intermediateIndices = [];
|
|
8771
|
+
for (let i = 1; i < (to - from + total) % total; i++) {
|
|
8772
|
+
intermediateIndices.push((from + i) % total);
|
|
8773
|
+
}
|
|
8774
|
+
const indices = [from, ...intermediateIndices, to];
|
|
8775
|
+
const intermediatePoints = [];
|
|
8776
|
+
for (const i of indices) {
|
|
8777
|
+
const {
|
|
8778
|
+
x,
|
|
8779
|
+
y
|
|
8780
|
+
} = createCurvePath({
|
|
8781
|
+
zoom,
|
|
8782
|
+
totalMarkers: node.totalStakeholders,
|
|
8783
|
+
markerIndex: i
|
|
8784
|
+
});
|
|
8785
|
+
const point = centerPoint.add(L__namespace.point(x, y));
|
|
8786
|
+
const latlng = mapRef.layerPointToLatLng(point);
|
|
8787
|
+
intermediatePoints.push(latlng);
|
|
8788
|
+
}
|
|
8789
|
+
const latlngs = flip ? [endLatLng, ...intermediatePoints, stakeholderLatLng] : [stakeholderLatLng, ...intermediatePoints, endLatLng];
|
|
8790
|
+
const layerPoints = latlngs.map(latlng => mapRef.latLngToLayerPoint(latlng));
|
|
8791
|
+
const path = buildSmoothCurve(layerPoints, mapRef);
|
|
8792
|
+
const curve = L__namespace?.curve?.(path, {
|
|
8793
|
+
color: "var(--base-gray-70)",
|
|
8794
|
+
weight: isExtraSmallMarker(zoom) ? 0 : 1,
|
|
8795
|
+
opacity: isSelected ? 1 : 0.5,
|
|
8796
|
+
smoothFactor: 1,
|
|
8797
|
+
id
|
|
8798
|
+
});
|
|
8799
|
+
mapRef.addLayer(curve);
|
|
8800
|
+
return;
|
|
8801
|
+
}
|
|
8724
8802
|
}
|
|
8725
|
-
// Always use straight lines
|
|
8726
8803
|
createPolyline({
|
|
8727
8804
|
L: L__namespace,
|
|
8728
8805
|
mapRef,
|
|
@@ -8732,11 +8809,10 @@ function StakeholderIcon$1({
|
|
|
8732
8809
|
isFromStakeholder: false,
|
|
8733
8810
|
isSelected,
|
|
8734
8811
|
id,
|
|
8735
|
-
listOfPolylines: polylinesRef.current
|
|
8736
|
-
animated: true
|
|
8812
|
+
listOfPolylines: polylinesRef.current
|
|
8737
8813
|
});
|
|
8738
8814
|
});
|
|
8739
|
-
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen
|
|
8815
|
+
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen]);
|
|
8740
8816
|
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
8741
8817
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
|
|
8742
8818
|
content: renderTooltipJsx({
|
|
@@ -8748,8 +8824,7 @@ function StakeholderIcon$1({
|
|
|
8748
8824
|
link,
|
|
8749
8825
|
onClickLink: () => {
|
|
8750
8826
|
onClickLink(data);
|
|
8751
|
-
}
|
|
8752
|
-
isNewTab: true
|
|
8827
|
+
}
|
|
8753
8828
|
}),
|
|
8754
8829
|
getPopupContainer: triggerNode => {
|
|
8755
8830
|
const mapElement = document.getElementById("map");
|
|
@@ -8804,8 +8879,6 @@ function LocationIcon({
|
|
|
8804
8879
|
const linkedNodesData = React.useMemo(() => {
|
|
8805
8880
|
const nodes = [];
|
|
8806
8881
|
const links = data.links || [];
|
|
8807
|
-
|
|
8808
|
-
// Add links from the location itself
|
|
8809
8882
|
links.forEach(link => {
|
|
8810
8883
|
allData.forEach(d => {
|
|
8811
8884
|
if (d.datastakeId === link) {
|
|
@@ -8825,45 +8898,8 @@ function LocationIcon({
|
|
|
8825
8898
|
}
|
|
8826
8899
|
});
|
|
8827
8900
|
});
|
|
8828
|
-
|
|
8829
|
-
// ADD: Also include links from this location's stakeholders
|
|
8830
|
-
const stakeholders = data.stakeholders || [];
|
|
8831
|
-
stakeholders.forEach(stakeholder => {
|
|
8832
|
-
const stakeholderLinks = stakeholder.links || [];
|
|
8833
|
-
stakeholderLinks.forEach(link => {
|
|
8834
|
-
allData.forEach(d => {
|
|
8835
|
-
// Check if it's a direct location link
|
|
8836
|
-
if (d.datastakeId === link) {
|
|
8837
|
-
// Avoid duplicates
|
|
8838
|
-
if (!nodes.find(n => n.datastakeId === link && !n.isStakeholder)) {
|
|
8839
|
-
nodes.push({
|
|
8840
|
-
...d,
|
|
8841
|
-
fromStakeholderId: stakeholder.datastakeId
|
|
8842
|
-
});
|
|
8843
|
-
}
|
|
8844
|
-
}
|
|
8845
|
-
// Check if it's a stakeholder link
|
|
8846
|
-
if (d.stakeholders && d.stakeholders.length > 0) {
|
|
8847
|
-
d.stakeholders.forEach(targetStakeholder => {
|
|
8848
|
-
if (targetStakeholder.datastakeId === link) {
|
|
8849
|
-
// Avoid duplicates
|
|
8850
|
-
if (!nodes.find(n => n.isStakeholder && n.datastakeId === d.datastakeId && n.stakeholdersIndex === d.stakeholders.indexOf(targetStakeholder))) {
|
|
8851
|
-
nodes.push({
|
|
8852
|
-
...d,
|
|
8853
|
-
isStakeholder: true,
|
|
8854
|
-
totalStakeholders: d.stakeholders.length,
|
|
8855
|
-
stakeholdersIndex: d.stakeholders.indexOf(targetStakeholder),
|
|
8856
|
-
fromStakeholderId: stakeholder.datastakeId
|
|
8857
|
-
});
|
|
8858
|
-
}
|
|
8859
|
-
}
|
|
8860
|
-
});
|
|
8861
|
-
}
|
|
8862
|
-
});
|
|
8863
|
-
});
|
|
8864
|
-
});
|
|
8865
8901
|
return nodes;
|
|
8866
|
-
}, [JSON.stringify(allData), JSON.stringify(data.links),
|
|
8902
|
+
}, [JSON.stringify(allData), JSON.stringify(data.links), zoom]);
|
|
8867
8903
|
const stakeholdersOfLocation = React.useMemo(() => {
|
|
8868
8904
|
return data?.stakeholders || [];
|
|
8869
8905
|
}, [data.stakeholders, zoom]);
|
|
@@ -8881,13 +8917,7 @@ function LocationIcon({
|
|
|
8881
8917
|
currentRoots.clear();
|
|
8882
8918
|
markersRef.current = [];
|
|
8883
8919
|
|
|
8884
|
-
//
|
|
8885
|
-
const shouldShowStakeholders = isSelected || stakeholdersOfLocation.some(stk => selectedMarkersId.includes(stk.datastakeId));
|
|
8886
|
-
if (!shouldShowStakeholders || selectedMarkersId.length === 0) {
|
|
8887
|
-
return;
|
|
8888
|
-
}
|
|
8889
|
-
|
|
8890
|
-
// Create new markers only when selected
|
|
8920
|
+
// Create new markers
|
|
8891
8921
|
stakeholdersOfLocation.forEach((stakeholder, index) => {
|
|
8892
8922
|
const markerId = `${stakeholder.datastakeId}`;
|
|
8893
8923
|
const {
|
|
@@ -8973,9 +9003,7 @@ function LocationIcon({
|
|
|
8973
9003
|
zoom,
|
|
8974
9004
|
isFromStakeholder: true,
|
|
8975
9005
|
isForceOpen,
|
|
8976
|
-
listOfPolylines: polylinesRef.current
|
|
8977
|
-
stakeholderType: stakeholder.type,
|
|
8978
|
-
animated: true
|
|
9006
|
+
listOfPolylines: polylinesRef.current
|
|
8979
9007
|
});
|
|
8980
9008
|
});
|
|
8981
9009
|
return () => {
|
|
@@ -8990,88 +9018,38 @@ function LocationIcon({
|
|
|
8990
9018
|
rootsMapRef.current.clear();
|
|
8991
9019
|
markersRef.current = [];
|
|
8992
9020
|
};
|
|
8993
|
-
}, [stakeholdersOfLocation, selectedMarkersId, activeMarker
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
}
|
|
9006
|
-
|
|
9007
|
-
// Filter linkedNodesData to only include nodes that are in the selected chain
|
|
9008
|
-
const relevantLinks = linkedNodesData.filter(node => {
|
|
9009
|
-
// Check if the target node (location) is in the selected markers
|
|
9010
|
-
const targetLocationInSelection = selectedMarkersId.includes(node.datastakeId);
|
|
9011
|
-
|
|
9012
|
-
// If connecting to a stakeholder, check if that stakeholder is selected
|
|
9013
|
-
if (node.isStakeholder) {
|
|
9014
|
-
const stakeholderInSelection = node.stakeholdersIndex !== undefined && selectedMarkersId.includes(node.datastakeId);
|
|
9015
|
-
return stakeholderInSelection;
|
|
9016
|
-
}
|
|
9017
|
-
return targetLocationInSelection;
|
|
9018
|
-
});
|
|
9019
|
-
relevantLinks.forEach(node => {
|
|
9020
|
-
const id = node.fromStakeholderId ? `${node.fromStakeholderId}-${node.datastakeId}` : `${data.datastakeId}-${node.datastakeId}`;
|
|
9021
|
-
const isConnectingToStakeholder = node.isStakeholder;
|
|
9022
|
-
|
|
9023
|
-
// If the link is from a stakeholder, start from the stakeholder position
|
|
9024
|
-
let startLatLng;
|
|
9025
|
-
if (node.fromStakeholderId) {
|
|
9026
|
-
// Find the stakeholder index in this location's stakeholders
|
|
9027
|
-
const stakeholderIndex = stakeholdersOfLocation.findIndex(s => s.datastakeId === node.fromStakeholderId);
|
|
9028
|
-
if (stakeholderIndex !== -1) {
|
|
9029
|
-
const {
|
|
9030
|
-
x,
|
|
9031
|
-
y
|
|
9032
|
-
} = getStakeholderPosition({
|
|
9033
|
-
zoom,
|
|
9034
|
-
totalMarkers: stakeholdersOfLocation.length,
|
|
9035
|
-
markerIndex: stakeholderIndex
|
|
9036
|
-
});
|
|
9037
|
-
const centerLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
9038
|
-
const centerPoint = mapRef.latLngToLayerPoint(centerLatLng);
|
|
9039
|
-
const stakeholderPoint = centerPoint.add(L__namespace.point(x, y));
|
|
9040
|
-
startLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
|
|
9041
|
-
} else {
|
|
9042
|
-
startLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
9043
|
-
}
|
|
9044
|
-
} else {
|
|
9045
|
-
startLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
9046
|
-
}
|
|
9047
|
-
let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
9048
|
-
const isConnectingToStakeholderSelected = selectedMarkersId.includes(node.datastakeId);
|
|
9049
|
-
if (isConnectingToStakeholder && !isExtraSmallMarker(zoom)) {
|
|
9050
|
-
const {
|
|
9051
|
-
x,
|
|
9052
|
-
y
|
|
9053
|
-
} = getStakeholderPosition({
|
|
9054
|
-
zoom,
|
|
9055
|
-
totalMarkers: node.totalStakeholders,
|
|
9056
|
-
markerIndex: node.stakeholdersIndex
|
|
9057
|
-
});
|
|
9058
|
-
const nodeLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
9059
|
-
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
9060
|
-
const endPoint = L__namespace.point(x + nodePoint.x, y + nodePoint.y);
|
|
9061
|
-
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
9062
|
-
}
|
|
9063
|
-
createPolyline({
|
|
9064
|
-
L: L__namespace,
|
|
9065
|
-
mapRef,
|
|
9066
|
-
startLatLng,
|
|
9067
|
-
endLatLng,
|
|
9068
|
-
isSelected: isConnectingToStakeholderSelected,
|
|
9069
|
-
id,
|
|
9021
|
+
}, [stakeholdersOfLocation, selectedMarkersId, activeMarker]);
|
|
9022
|
+
linkedNodesData.map(node => {
|
|
9023
|
+
const id = `${data.datastakeId}-${node.datastakeId}`;
|
|
9024
|
+
const isConnectingToStakeholder = node.isStakeholder;
|
|
9025
|
+
const centerLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
9026
|
+
let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
9027
|
+
const isConnectingToStakeholderSelected = selectedMarkersId.includes(node.datastakeId);
|
|
9028
|
+
if (isConnectingToStakeholder && !isExtraSmallMarker(zoom)) {
|
|
9029
|
+
const {
|
|
9030
|
+
x,
|
|
9031
|
+
y
|
|
9032
|
+
} = getStakeholderPosition({
|
|
9070
9033
|
zoom,
|
|
9071
|
-
|
|
9072
|
-
|
|
9034
|
+
totalMarkers: node.totalStakeholders,
|
|
9035
|
+
markerIndex: node.stakeholdersIndex
|
|
9036
|
+
});
|
|
9037
|
+
const nodeLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
9038
|
+
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
9039
|
+
const endPoint = L__namespace.point(x + nodePoint.x, y + nodePoint.y);
|
|
9040
|
+
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
9041
|
+
}
|
|
9042
|
+
createPolyline({
|
|
9043
|
+
L: L__namespace,
|
|
9044
|
+
mapRef,
|
|
9045
|
+
startLatLng: centerLatLng,
|
|
9046
|
+
endLatLng,
|
|
9047
|
+
isSelected: isConnectingToStakeholderSelected,
|
|
9048
|
+
id,
|
|
9049
|
+
zoom,
|
|
9050
|
+
listOfPolylines: polylinesRef.current
|
|
9073
9051
|
});
|
|
9074
|
-
}
|
|
9052
|
+
});
|
|
9075
9053
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
|
|
9076
9054
|
content: renderTooltipJsx({
|
|
9077
9055
|
title: data.name,
|
|
@@ -9587,8 +9565,7 @@ function useMapHelper$1({
|
|
|
9587
9565
|
link: link,
|
|
9588
9566
|
onClickLink: onClickLink,
|
|
9589
9567
|
activeStakeholder: activeStakeholder,
|
|
9590
|
-
setActiveStakeholder: setActiveStakeholder
|
|
9591
|
-
mapRef: mapRef
|
|
9568
|
+
setActiveStakeholder: setActiveStakeholder
|
|
9592
9569
|
}));
|
|
9593
9570
|
roots.current.push(root);
|
|
9594
9571
|
} else if (type === "location") {
|
|
@@ -9793,8 +9770,7 @@ const useMap = ({
|
|
|
9793
9770
|
MAP_TOKEN
|
|
9794
9771
|
} = useMapConfig({
|
|
9795
9772
|
app,
|
|
9796
|
-
isSatellite
|
|
9797
|
-
mapRef: container
|
|
9773
|
+
isSatellite
|
|
9798
9774
|
});
|
|
9799
9775
|
const [initialMarkerSetIsDone, setInitialMarkerSetIsDone] = React.useState(false);
|
|
9800
9776
|
const [mapCenter, setMapCenter] = React.useState([0, 0]);
|
|
@@ -9811,8 +9787,6 @@ const useMap = ({
|
|
|
9811
9787
|
const graph = new Map();
|
|
9812
9788
|
const stakeToLoc = new Map();
|
|
9813
9789
|
const nodeTypes = new Map();
|
|
9814
|
-
|
|
9815
|
-
// Build the graph
|
|
9816
9790
|
for (const loc of data) {
|
|
9817
9791
|
const locId = loc.datastakeId;
|
|
9818
9792
|
nodeTypes.set(locId, loc.type);
|
|
@@ -9837,45 +9811,26 @@ const useMap = ({
|
|
|
9837
9811
|
}
|
|
9838
9812
|
}
|
|
9839
9813
|
const highlightTable = {};
|
|
9840
|
-
|
|
9841
|
-
// Perform BFS/DFS to find all connected nodes in the entire chain
|
|
9842
9814
|
for (const [node] of graph) {
|
|
9843
9815
|
const highlighted = new Set();
|
|
9844
|
-
|
|
9845
|
-
const
|
|
9846
|
-
|
|
9847
|
-
const
|
|
9848
|
-
highlighted.add(
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
const
|
|
9852
|
-
if (
|
|
9853
|
-
const
|
|
9854
|
-
if (
|
|
9855
|
-
highlighted.add(parentLoc);
|
|
9856
|
-
visited.add(parentLoc);
|
|
9857
|
-
queue.push(parentLoc);
|
|
9858
|
-
}
|
|
9859
|
-
}
|
|
9860
|
-
|
|
9861
|
-
// Traverse all neighbors
|
|
9862
|
-
for (const neighbor of graph.get(current) || []) {
|
|
9863
|
-
if (!visited.has(neighbor)) {
|
|
9864
|
-
visited.add(neighbor);
|
|
9865
|
-
queue.push(neighbor);
|
|
9816
|
+
highlighted.add(node);
|
|
9817
|
+
const nodeIsStakeholder = !isLocation(nodeTypes.get(node));
|
|
9818
|
+
if (nodeIsStakeholder && stakeToLoc.has(node)) {
|
|
9819
|
+
const parentLoc = stakeToLoc.get(node);
|
|
9820
|
+
highlighted.add(parentLoc);
|
|
9821
|
+
}
|
|
9822
|
+
for (const neighbor of graph.get(node) || []) {
|
|
9823
|
+
const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
|
|
9824
|
+
if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
|
|
9825
|
+
const neighborParent = stakeToLoc.get(neighbor);
|
|
9826
|
+
if (isLocation(nodeTypes.get(node)) && neighborParent === node || nodeIsStakeholder && stakeToLoc.get(node) === neighborParent) {
|
|
9866
9827
|
highlighted.add(neighbor);
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
|
|
9871
|
-
const neighborParent = stakeToLoc.get(neighbor);
|
|
9872
|
-
if (!visited.has(neighborParent)) {
|
|
9873
|
-
highlighted.add(neighborParent);
|
|
9874
|
-
visited.add(neighborParent);
|
|
9875
|
-
queue.push(neighborParent);
|
|
9876
|
-
}
|
|
9877
|
-
}
|
|
9828
|
+
} else {
|
|
9829
|
+
highlighted.add(neighbor);
|
|
9830
|
+
highlighted.add(neighborParent);
|
|
9878
9831
|
}
|
|
9832
|
+
} else {
|
|
9833
|
+
highlighted.add(neighbor);
|
|
9879
9834
|
}
|
|
9880
9835
|
}
|
|
9881
9836
|
highlightTable[node] = [...highlighted];
|
|
@@ -9913,20 +9868,10 @@ const useMap = ({
|
|
|
9913
9868
|
function handleSelectMarker(clickedMarker) {
|
|
9914
9869
|
setSelectedMarkersId(prev => {
|
|
9915
9870
|
if (prev.includes(clickedMarker.datastakeId)) {
|
|
9916
|
-
// Deselecting - clear polylines
|
|
9917
9871
|
openPopupIdRef.current = null;
|
|
9918
9872
|
setMarkerWithPopup(null);
|
|
9919
9873
|
return [];
|
|
9920
9874
|
} else {
|
|
9921
|
-
// CLEAR OLD POLYLINES BEFORE SELECTING NEW MARKER
|
|
9922
|
-
if (polylinesRef.current.length > 0) {
|
|
9923
|
-
polylinesRef.current.forEach(polyline => {
|
|
9924
|
-
if (mapRef.hasLayer(polyline)) {
|
|
9925
|
-
mapRef.removeLayer(polyline);
|
|
9926
|
-
}
|
|
9927
|
-
});
|
|
9928
|
-
polylinesRef.current = [];
|
|
9929
|
-
}
|
|
9930
9875
|
setMarkerWithPopup(isStakeholder(clickedMarker.type) ? clickedMarker : null);
|
|
9931
9876
|
const newSelectedMarkersId = highlightTable[clickedMarker.datastakeId];
|
|
9932
9877
|
openPopupIdRef.current = clickedMarker.datastakeId;
|
|
@@ -9950,29 +9895,19 @@ const useMap = ({
|
|
|
9950
9895
|
});
|
|
9951
9896
|
}
|
|
9952
9897
|
}
|
|
9953
|
-
if (type === "chain" && selectedMarkersId.length === 0) {
|
|
9954
|
-
if (polylinesRef.current.length) {
|
|
9955
|
-
polylinesRef.current.forEach(polyline => {
|
|
9956
|
-
if (mapRef.hasLayer(polyline)) {
|
|
9957
|
-
mapRef.removeLayer(polyline);
|
|
9958
|
-
}
|
|
9959
|
-
});
|
|
9960
|
-
polylinesRef.current = [];
|
|
9961
|
-
}
|
|
9962
|
-
}
|
|
9963
9898
|
clearMapMarkers();
|
|
9964
9899
|
if (data) {
|
|
9965
|
-
|
|
9900
|
+
// Filters out locations that are not connected to any stakeholders
|
|
9901
|
+
const excludedType = ['village', 'town', 'area', 'territory'];
|
|
9902
|
+
const filteredData = data?.filter(obj => !excludedType.includes(obj?.type) && (obj?.stakeholders?.length > 0 || data.some(other => other.datastakeId !== obj.datastakeId && (other.stakeholders || []).some(stk => (stk.links || []).includes(obj.datastakeId)))));
|
|
9966
9903
|
const maxTotal = Math.max(...(data || []).map(d => d.total));
|
|
9967
9904
|
const dataToRender = type === "chain" ? filteredData : data;
|
|
9968
9905
|
dataToRender.forEach((d, i) => {
|
|
9969
9906
|
addIconToMapInitialy([d?.marker?.lat, d?.marker?.lng], "location", d.category || "mineSite", d, maxTotal, i);
|
|
9970
9907
|
});
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
});
|
|
9975
|
-
}
|
|
9908
|
+
polylinesRef.current.forEach(polyline => {
|
|
9909
|
+
mapRef.addLayer(polyline);
|
|
9910
|
+
});
|
|
9976
9911
|
mapRef.invalidateSize();
|
|
9977
9912
|
mapRef.fire("moveend");
|
|
9978
9913
|
}
|
|
@@ -17152,9 +17087,6 @@ function showHideForm(form, formsValue) {
|
|
|
17152
17087
|
}
|
|
17153
17088
|
return true;
|
|
17154
17089
|
}
|
|
17155
|
-
const filterForm = (f, d) => {
|
|
17156
|
-
return f && (f.showFormIf ? showHideForm(f, d) : true);
|
|
17157
|
-
};
|
|
17158
17090
|
const getSgbEvaluationIcons = (width, height) => ({
|
|
17159
17091
|
0: /*#__PURE__*/jsxRuntime.jsxs("svg", {
|
|
17160
17092
|
width: width,
|
|
@@ -17492,28 +17424,8 @@ function AjaxModal$1({
|
|
|
17492
17424
|
const types = {
|
|
17493
17425
|
MODAL: 'modal'
|
|
17494
17426
|
};
|
|
17495
|
-
const isGroupInput = (group, repeatable = false, data) => {
|
|
17496
|
-
let resp = group.inputs && Object.keys(group.inputs).length && group.repeatable === repeatable && group.type !== 'groupInputs' && group.type !== 'group' && group.type !== 'dataLinkGroup' && group.display !== 'group' && !group.viewGroup && !group.component;
|
|
17497
|
-
if (group.showIf || group?.meta?.excludeFromView) {
|
|
17498
|
-
resp = resp && showHideInput$3(group, data);
|
|
17499
|
-
}
|
|
17500
|
-
return resp;
|
|
17501
|
-
};
|
|
17502
17427
|
const repeatObjects = (obj, fn = () => {}, filter = null, sort = null) => filter ? Object.keys(obj).filter(key => filter(obj[key])).map(fn) : sort ? Object.keys(obj).sort(sort).map(fn) : Object.keys(obj).map(fn);
|
|
17503
17428
|
const conditions = new RegExp(/( is | and | not | notEmpty | includes )/gm);
|
|
17504
|
-
const getLastRow = (arr, cols) => {
|
|
17505
|
-
let currentInd = -1;
|
|
17506
|
-
const newArr = [];
|
|
17507
|
-
arr.forEach(nr => {
|
|
17508
|
-
if (nr % cols === 0) {
|
|
17509
|
-
newArr[currentInd + 1] = [nr];
|
|
17510
|
-
currentInd++;
|
|
17511
|
-
} else {
|
|
17512
|
-
newArr[currentInd].push(nr);
|
|
17513
|
-
}
|
|
17514
|
-
});
|
|
17515
|
-
return newArr[newArr.length - 1];
|
|
17516
|
-
};
|
|
17517
17429
|
const _verifyCondition = (condition, data, allData) => {
|
|
17518
17430
|
let [path, match, needed] = condition.split(conditions);
|
|
17519
17431
|
const isRepeatable = path.split('./').length > 1;
|
|
@@ -17586,49 +17498,6 @@ const showHideInput$3 = (input, formsValue, repeatValues) => {
|
|
|
17586
17498
|
}
|
|
17587
17499
|
return true;
|
|
17588
17500
|
};
|
|
17589
|
-
const getNkey = namespace => {
|
|
17590
|
-
if (['location', 'scl', 'village', 'event', 'incidents', 'corrective-actions', 'testimonials', 'initiatives', 'victims', 'pictures', 'documents', 'lir', 'sp', 'im', 'sci', 'bpe', 'gm'].includes(namespace)) {
|
|
17591
|
-
return 'scoping';
|
|
17592
|
-
}
|
|
17593
|
-
return namespace;
|
|
17594
|
-
};
|
|
17595
|
-
const groupSubsections = (form, onlyConf = false) => {
|
|
17596
|
-
return Object.keys(form).reduce((f, fKey) => {
|
|
17597
|
-
if (form[fKey].subSection) {
|
|
17598
|
-
let subName = form[fKey].subSection;
|
|
17599
|
-
if (typeof form[fKey].subSection === "object") {
|
|
17600
|
-
subName = form[fKey].subSection.name;
|
|
17601
|
-
}
|
|
17602
|
-
if (!f[subName]) {
|
|
17603
|
-
f[subName] = {
|
|
17604
|
-
label: '',
|
|
17605
|
-
icon: '',
|
|
17606
|
-
position: 0
|
|
17607
|
-
};
|
|
17608
|
-
if (typeof form[fKey].subSection === "object") {
|
|
17609
|
-
const {
|
|
17610
|
-
label = '',
|
|
17611
|
-
icon = '',
|
|
17612
|
-
position = 0,
|
|
17613
|
-
showFormIf = ''
|
|
17614
|
-
} = form[fKey].subSection;
|
|
17615
|
-
f[subName] = {
|
|
17616
|
-
label,
|
|
17617
|
-
icon,
|
|
17618
|
-
position,
|
|
17619
|
-
showFormIf
|
|
17620
|
-
};
|
|
17621
|
-
}
|
|
17622
|
-
}
|
|
17623
|
-
if (!onlyConf) {
|
|
17624
|
-
Object.assign(f[subName], {
|
|
17625
|
-
[fKey]: form[fKey]
|
|
17626
|
-
});
|
|
17627
|
-
}
|
|
17628
|
-
}
|
|
17629
|
-
return f;
|
|
17630
|
-
}, {});
|
|
17631
|
-
};
|
|
17632
17501
|
const renderPlaceholder = ({
|
|
17633
17502
|
data,
|
|
17634
17503
|
config,
|
|
@@ -24610,19 +24479,6 @@ const Input = ({
|
|
|
24610
24479
|
return getComponent();
|
|
24611
24480
|
};
|
|
24612
24481
|
|
|
24613
|
-
const getDisabled = ({
|
|
24614
|
-
disabled,
|
|
24615
|
-
groupCheckboxDisableKey,
|
|
24616
|
-
data
|
|
24617
|
-
}) => {
|
|
24618
|
-
if (disabled) {
|
|
24619
|
-
return true;
|
|
24620
|
-
}
|
|
24621
|
-
if (typeof groupCheckboxDisableKey === 'string') {
|
|
24622
|
-
return !Object.values(data?.[groupCheckboxDisableKey] || {}).find(c => typeof c === 'number');
|
|
24623
|
-
}
|
|
24624
|
-
return false;
|
|
24625
|
-
};
|
|
24626
24482
|
({
|
|
24627
24483
|
t: PropTypes__default["default"].func,
|
|
24628
24484
|
data: PropTypes__default["default"].any,
|
|
@@ -24685,7 +24541,6 @@ function convertUndefinedToNull(obj) {
|
|
|
24685
24541
|
}
|
|
24686
24542
|
return obj;
|
|
24687
24543
|
}
|
|
24688
|
-
const hasKeyInObject = (obj, key) => Object.keys(obj || {}).includes(key);
|
|
24689
24544
|
|
|
24690
24545
|
const packageApps = ["kota", "sbg", "nashiriki", "straatos", "wazi", "hatua"]; //PACKAGE_CHANGE_LATER (add sbg)
|
|
24691
24546
|
|
|
@@ -40045,710 +39900,6 @@ const StatCard = ({
|
|
|
40045
39900
|
});
|
|
40046
39901
|
};
|
|
40047
39902
|
|
|
40048
|
-
const RepeatableGroup = ({
|
|
40049
|
-
name = null,
|
|
40050
|
-
config = {},
|
|
40051
|
-
allData = {},
|
|
40052
|
-
linkingData = {},
|
|
40053
|
-
ajaxOptions,
|
|
40054
|
-
t,
|
|
40055
|
-
ajaxForms,
|
|
40056
|
-
changeAjaxForms,
|
|
40057
|
-
getApiBaseUrl,
|
|
40058
|
-
getAppHeader,
|
|
40059
|
-
user,
|
|
40060
|
-
getToken,
|
|
40061
|
-
app
|
|
40062
|
-
}) => {
|
|
40063
|
-
const {
|
|
40064
|
-
automaticallyLink,
|
|
40065
|
-
dataLink,
|
|
40066
|
-
call
|
|
40067
|
-
} = React.useMemo(() => config, [config]);
|
|
40068
|
-
const entity = React.useMemo(() => automaticallyLink?.entity || config?.meta?.dataLinkEntity, [automaticallyLink, config]);
|
|
40069
|
-
const isAjaxModal = React.useMemo(() => automaticallyLink && dataLink && call, [automaticallyLink, dataLink, call]);
|
|
40070
|
-
const [modalRow, setModalRow] = React.useState(null);
|
|
40071
|
-
const dataSource = React.useMemo(() => allData[name] || [], [allData, name]);
|
|
40072
|
-
const notAvailable = (allData?.meta?.inputs || {})[name]?.notAvailable;
|
|
40073
|
-
const notApplicable = (allData?.meta?.inputs || {})[name]?.notApplicable;
|
|
40074
|
-
const noBody = notApplicable || notAvailable;
|
|
40075
|
-
const _data = React.useMemo(() => dataSource.length ? dataSource.map((f, i) => {
|
|
40076
|
-
if (isAjaxModal && typeof f === 'string' && linkingData && linkingData[entity] && linkingData[entity][f]) {
|
|
40077
|
-
const value = linkingData[entity][f];
|
|
40078
|
-
return {
|
|
40079
|
-
...value,
|
|
40080
|
-
key: i
|
|
40081
|
-
};
|
|
40082
|
-
}
|
|
40083
|
-
if (config?.meta?.ajaxOptionsKey) {
|
|
40084
|
-
if (linkingData && linkingData[entity] && linkingData[entity][f[config?.meta?.ajaxOptionsKey]]) {
|
|
40085
|
-
const value = linkingData[entity][f[config?.meta?.ajaxOptionsKey]];
|
|
40086
|
-
return {
|
|
40087
|
-
...value,
|
|
40088
|
-
key: i
|
|
40089
|
-
};
|
|
40090
|
-
}
|
|
40091
|
-
const options = ajaxOptions[config?.meta?.ajaxOptionsKey];
|
|
40092
|
-
if (Array.isArray(options)) {
|
|
40093
|
-
const value = options.find(v => v.value === f[config?.meta?.ajaxOptionsKey]);
|
|
40094
|
-
if (value) {
|
|
40095
|
-
return {
|
|
40096
|
-
...f,
|
|
40097
|
-
...value,
|
|
40098
|
-
key: i
|
|
40099
|
-
};
|
|
40100
|
-
}
|
|
40101
|
-
}
|
|
40102
|
-
}
|
|
40103
|
-
return {
|
|
40104
|
-
...f,
|
|
40105
|
-
key: i
|
|
40106
|
-
};
|
|
40107
|
-
}) : [{
|
|
40108
|
-
key: 1,
|
|
40109
|
-
isEmpty: true
|
|
40110
|
-
}, {
|
|
40111
|
-
key: 2,
|
|
40112
|
-
isEmpty: true
|
|
40113
|
-
}], [isAjaxModal, dataSource, entity, config, ajaxOptions, linkingData]);
|
|
40114
|
-
const mapKey = key => ({
|
|
40115
|
-
title: config?.inputs[key]?.label,
|
|
40116
|
-
key: key,
|
|
40117
|
-
dataIndex: key,
|
|
40118
|
-
ellipsis: true,
|
|
40119
|
-
render: (v, all) => {
|
|
40120
|
-
if (all.isEmpty) {
|
|
40121
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40122
|
-
className: "daf-default-cell md"
|
|
40123
|
-
});
|
|
40124
|
-
}
|
|
40125
|
-
if (v) {
|
|
40126
|
-
return /*#__PURE__*/jsxRuntime.jsx(BasicInput, {
|
|
40127
|
-
t: t,
|
|
40128
|
-
app: app,
|
|
40129
|
-
ajaxForms: ajaxForms,
|
|
40130
|
-
changeAjaxForms: changeAjaxForms,
|
|
40131
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
40132
|
-
getAppHeader: getAppHeader,
|
|
40133
|
-
user: user,
|
|
40134
|
-
getToken: getToken,
|
|
40135
|
-
name: key,
|
|
40136
|
-
config: config.inputs[key],
|
|
40137
|
-
valueOnlyString: true,
|
|
40138
|
-
data: all
|
|
40139
|
-
}, key);
|
|
40140
|
-
}
|
|
40141
|
-
return '--';
|
|
40142
|
-
}
|
|
40143
|
-
});
|
|
40144
|
-
const columns = [...(Array.isArray(config?.meta?.tableKeys) ? config.meta.tableKeys.map(mapKey) : Object.keys(config?.inputs).map(mapKey)), {
|
|
40145
|
-
key: 'actions',
|
|
40146
|
-
dataIndex: 'actions',
|
|
40147
|
-
label: '',
|
|
40148
|
-
width: 50,
|
|
40149
|
-
render: (_, all) => {
|
|
40150
|
-
if (all.isEmpty) {
|
|
40151
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40152
|
-
className: "daf-default-cell md"
|
|
40153
|
-
});
|
|
40154
|
-
}
|
|
40155
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40156
|
-
onClick: () => setModalRow(all),
|
|
40157
|
-
className: "cursor-pointer flex justify-content-center",
|
|
40158
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Icons.EyeOutlined, {})
|
|
40159
|
-
});
|
|
40160
|
-
}
|
|
40161
|
-
}];
|
|
40162
|
-
const _subTitle = config.viewSubTitle || config.subTitle;
|
|
40163
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40164
|
-
className: formatClassname(["group repeatable", noBody && 'no-body']),
|
|
40165
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40166
|
-
className: "daf-title with-subtitle",
|
|
40167
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("h1", {
|
|
40168
|
-
children: ReactHtmlParser__default["default"](config?.label)
|
|
40169
|
-
}), _subTitle && typeof _subTitle === 'string' ? /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
40170
|
-
children: ReactHtmlParser__default["default"](_subTitle)
|
|
40171
|
-
}) : null]
|
|
40172
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40173
|
-
className: "flex",
|
|
40174
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40175
|
-
className: "daf-table-wrapper no-padding repeatable-form-table input no-pagination",
|
|
40176
|
-
children: /*#__PURE__*/jsxRuntime.jsx(antd.ConfigProvider, {
|
|
40177
|
-
renderEmpty: () => notApplicable ? t('Not applicable') : t('No information available'),
|
|
40178
|
-
children: /*#__PURE__*/jsxRuntime.jsx(antd.Table, {
|
|
40179
|
-
locale: getLocales(t),
|
|
40180
|
-
pagination: false,
|
|
40181
|
-
columns: columns,
|
|
40182
|
-
rowKey: "key",
|
|
40183
|
-
dataSource: noBody ? [] : _data
|
|
40184
|
-
})
|
|
40185
|
-
})
|
|
40186
|
-
}), !noActionsInputs.includes(config?.type) ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40187
|
-
className: "ml-4 input-actions flex",
|
|
40188
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Review, {
|
|
40189
|
-
t: t,
|
|
40190
|
-
config: config,
|
|
40191
|
-
inputMeta: (allData?.meta?.inputs || {})[name] || {},
|
|
40192
|
-
name: name
|
|
40193
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Versions, {
|
|
40194
|
-
t: t,
|
|
40195
|
-
versionsDatapoints: [],
|
|
40196
|
-
config: config,
|
|
40197
|
-
allData: allData,
|
|
40198
|
-
name: name,
|
|
40199
|
-
getValue: () => null
|
|
40200
|
-
}), /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
40201
|
-
title: t("Sources"),
|
|
40202
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40203
|
-
children: /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
40204
|
-
className: "default p-0 flex flex-column justify-content-center",
|
|
40205
|
-
type: "link",
|
|
40206
|
-
disabled: true,
|
|
40207
|
-
children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
|
|
40208
|
-
name: "Sources",
|
|
40209
|
-
width: 16,
|
|
40210
|
-
height: 16
|
|
40211
|
-
})
|
|
40212
|
-
})
|
|
40213
|
-
})
|
|
40214
|
-
}), /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
40215
|
-
title: t("Comments"),
|
|
40216
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40217
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Comments, {
|
|
40218
|
-
t: t,
|
|
40219
|
-
config: config,
|
|
40220
|
-
allData: allData,
|
|
40221
|
-
name: name
|
|
40222
|
-
})
|
|
40223
|
-
})
|
|
40224
|
-
})]
|
|
40225
|
-
}) : null]
|
|
40226
|
-
}), /*#__PURE__*/jsxRuntime.jsx(antd.Modal, {
|
|
40227
|
-
open: !!modalRow,
|
|
40228
|
-
title: /*#__PURE__*/jsxRuntime.jsx(ModalHeader, {
|
|
40229
|
-
title: config?.label
|
|
40230
|
-
}),
|
|
40231
|
-
footer: null,
|
|
40232
|
-
width: 650,
|
|
40233
|
-
className: "max-h-50",
|
|
40234
|
-
onCancel: () => setModalRow(null),
|
|
40235
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40236
|
-
className: "daf-view-form",
|
|
40237
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40238
|
-
className: "view-content",
|
|
40239
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40240
|
-
className: "content no-padding",
|
|
40241
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40242
|
-
className: "wrapper",
|
|
40243
|
-
style: {
|
|
40244
|
-
maxWidth: 600 // FUTURE ILVI
|
|
40245
|
-
},
|
|
40246
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40247
|
-
className: "group",
|
|
40248
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
40249
|
-
app: app,
|
|
40250
|
-
t: t,
|
|
40251
|
-
ajaxForms: ajaxForms,
|
|
40252
|
-
changeAjaxForms: changeAjaxForms,
|
|
40253
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
40254
|
-
getAppHeader: getAppHeader,
|
|
40255
|
-
user: user,
|
|
40256
|
-
getToken: getToken,
|
|
40257
|
-
config: Object.keys(config.inputs || {}).filter(k => {
|
|
40258
|
-
return !(config?.meta?.excludedKeysView || []).includes(k);
|
|
40259
|
-
}).reduce((all, key) => {
|
|
40260
|
-
all[key] = config.inputs[key];
|
|
40261
|
-
return all;
|
|
40262
|
-
}, {}),
|
|
40263
|
-
data: {
|
|
40264
|
-
...modalRow
|
|
40265
|
-
}
|
|
40266
|
-
})
|
|
40267
|
-
})
|
|
40268
|
-
})
|
|
40269
|
-
})
|
|
40270
|
-
})
|
|
40271
|
-
})
|
|
40272
|
-
})]
|
|
40273
|
-
});
|
|
40274
|
-
};
|
|
40275
|
-
|
|
40276
|
-
/* eslint-disable no-case-declarations */
|
|
40277
|
-
const RepeatableModals = ({
|
|
40278
|
-
name = null,
|
|
40279
|
-
config = {},
|
|
40280
|
-
data = {},
|
|
40281
|
-
linkingData = {},
|
|
40282
|
-
linkingForms = {},
|
|
40283
|
-
ajaxOptions = [],
|
|
40284
|
-
t,
|
|
40285
|
-
ajaxForms,
|
|
40286
|
-
changeAjaxForms,
|
|
40287
|
-
getApiBaseUrl,
|
|
40288
|
-
getAppHeader,
|
|
40289
|
-
user,
|
|
40290
|
-
getToken,
|
|
40291
|
-
app
|
|
40292
|
-
}) => {
|
|
40293
|
-
const label = (prop = null) => {
|
|
40294
|
-
function getLabel(label) {
|
|
40295
|
-
switch (typeof label) {
|
|
40296
|
-
case 'string':
|
|
40297
|
-
return label;
|
|
40298
|
-
case 'object':
|
|
40299
|
-
const labelKey = Object.keys(label).find(cond => verifyConditional(cond, data));
|
|
40300
|
-
return label[labelKey];
|
|
40301
|
-
default:
|
|
40302
|
-
return label;
|
|
40303
|
-
}
|
|
40304
|
-
}
|
|
40305
|
-
if (config[prop]) {
|
|
40306
|
-
return getLabel(config[prop]);
|
|
40307
|
-
}
|
|
40308
|
-
if (config.sectionLabel) {
|
|
40309
|
-
return getLabel(config.sectionLabel);
|
|
40310
|
-
}
|
|
40311
|
-
if (config.outputLabel) {
|
|
40312
|
-
return getLabel(config.outputLabel);
|
|
40313
|
-
}
|
|
40314
|
-
return getLabel(config.label);
|
|
40315
|
-
};
|
|
40316
|
-
return verifyConditional(config.showIf ? config.showIf : null, data) ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40317
|
-
className: "group",
|
|
40318
|
-
children: [label('outputLabel') ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40319
|
-
className: "title",
|
|
40320
|
-
children: /*#__PURE__*/jsxRuntime.jsx("h1", {
|
|
40321
|
-
children: label('outputLabel')
|
|
40322
|
-
})
|
|
40323
|
-
}) : null, data[name] && data[name].length ? data[name].map((item, index) => /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40324
|
-
className: "group display",
|
|
40325
|
-
style: {
|
|
40326
|
-
border: '1px dotted var(--mmt-primary-70)'
|
|
40327
|
-
},
|
|
40328
|
-
children: [label() ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40329
|
-
className: "title",
|
|
40330
|
-
children: /*#__PURE__*/jsxRuntime.jsxs("h1", {
|
|
40331
|
-
children: [label(), " #", index + 1]
|
|
40332
|
-
})
|
|
40333
|
-
}) : null, repeatObjects(config.inputs, key => {
|
|
40334
|
-
const modalData = {
|
|
40335
|
-
[name]: {
|
|
40336
|
-
[key]: data[name][index][key] || null
|
|
40337
|
-
}
|
|
40338
|
-
};
|
|
40339
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40340
|
-
className: "group",
|
|
40341
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40342
|
-
className: "title",
|
|
40343
|
-
children: /*#__PURE__*/jsxRuntime.jsx("h1", {
|
|
40344
|
-
children: config.inputs[key].outputLabel || getInputLabel$2(config.inputs[key], item)
|
|
40345
|
-
})
|
|
40346
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
40347
|
-
app: app,
|
|
40348
|
-
ajaxForms: ajaxForms,
|
|
40349
|
-
changeAjaxForms: changeAjaxForms,
|
|
40350
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
40351
|
-
getAppHeader: getAppHeader,
|
|
40352
|
-
user: user,
|
|
40353
|
-
getToken: getToken,
|
|
40354
|
-
t: t,
|
|
40355
|
-
parent: name,
|
|
40356
|
-
name: config.inputs[key].dataId || key,
|
|
40357
|
-
config: config.inputs[key],
|
|
40358
|
-
data: modalData,
|
|
40359
|
-
linkingData: linkingData,
|
|
40360
|
-
linkingForms: linkingForms,
|
|
40361
|
-
ajaxOptions: ajaxOptions,
|
|
40362
|
-
cols: 2
|
|
40363
|
-
}, key)]
|
|
40364
|
-
}, key);
|
|
40365
|
-
})]
|
|
40366
|
-
}, index)) : /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
40367
|
-
className: "text-muted",
|
|
40368
|
-
children: t('Not answered')
|
|
40369
|
-
})]
|
|
40370
|
-
}) : null;
|
|
40371
|
-
};
|
|
40372
|
-
|
|
40373
|
-
/* eslint-disable no-unused-vars */
|
|
40374
|
-
const Content = ({
|
|
40375
|
-
style = {},
|
|
40376
|
-
form = {},
|
|
40377
|
-
data = {},
|
|
40378
|
-
groupConfig = {},
|
|
40379
|
-
versionsDatapoints,
|
|
40380
|
-
linkingData = {},
|
|
40381
|
-
linkingForms = {},
|
|
40382
|
-
ajaxOptions = [],
|
|
40383
|
-
// ADDED
|
|
40384
|
-
t,
|
|
40385
|
-
app,
|
|
40386
|
-
ajaxForms,
|
|
40387
|
-
language,
|
|
40388
|
-
changeAjaxForms,
|
|
40389
|
-
getApiBaseUrl,
|
|
40390
|
-
getAppHeader,
|
|
40391
|
-
user,
|
|
40392
|
-
evaluationConfig = [],
|
|
40393
|
-
fullWidth = false
|
|
40394
|
-
}) => {
|
|
40395
|
-
const groupSingle = grps => {
|
|
40396
|
-
const form = Object.keys(grps).reduce((f, gKey) => {
|
|
40397
|
-
if (grps[gKey].type !== "modal" && !isGroupInput(grps[gKey], false, data) && !isGroupInput(grps[gKey], true, data) && grps[gKey].display !== "group" && !grps[gKey].viewGroup && !grps[gKey].component) {
|
|
40398
|
-
if (grps[gKey].group && !f[grps[gKey].group]) {
|
|
40399
|
-
f[grps[gKey].group] = {};
|
|
40400
|
-
Object.assign(f[grps[gKey].group], {
|
|
40401
|
-
[gKey]: grps[gKey]
|
|
40402
|
-
});
|
|
40403
|
-
} else if (grps[gKey].group && f[grps[gKey].group]) {
|
|
40404
|
-
Object.assign(f[grps[gKey].group], {
|
|
40405
|
-
[gKey]: grps[gKey]
|
|
40406
|
-
});
|
|
40407
|
-
}
|
|
40408
|
-
if (grps[gKey]?.meta?.group && !f[grps[gKey]?.meta?.group]) {
|
|
40409
|
-
f[grps[gKey]?.meta?.group] = {};
|
|
40410
|
-
Object.assign(f[grps[gKey].meta.group], {
|
|
40411
|
-
[gKey]: grps[gKey]
|
|
40412
|
-
});
|
|
40413
|
-
} else if (grps[gKey]?.meta?.group && f[grps[gKey]?.meta?.group]) {
|
|
40414
|
-
Object.assign(f[grps[gKey].meta.group], {
|
|
40415
|
-
[gKey]: grps[gKey]
|
|
40416
|
-
});
|
|
40417
|
-
}
|
|
40418
|
-
if (grps[gKey].section && !f[grps[gKey].section]) {
|
|
40419
|
-
f[grps[gKey].section] = {};
|
|
40420
|
-
Object.assign(f[grps[gKey].section], {
|
|
40421
|
-
[gKey]: grps[gKey]
|
|
40422
|
-
});
|
|
40423
|
-
} else if (grps[gKey].section && f[grps[gKey].section]) {
|
|
40424
|
-
Object.assign(f[grps[gKey].section], {
|
|
40425
|
-
[gKey]: grps[gKey]
|
|
40426
|
-
});
|
|
40427
|
-
}
|
|
40428
|
-
}
|
|
40429
|
-
return f;
|
|
40430
|
-
}, {});
|
|
40431
|
-
return form;
|
|
40432
|
-
};
|
|
40433
|
-
const getDisplayGroupConfig = (groups, key) => {
|
|
40434
|
-
return Object.keys(groups).reduce((items, gKey) => {
|
|
40435
|
-
if (groups[gKey].viewGroup === key) {
|
|
40436
|
-
// eslint-disable-next-line no-unused-vars
|
|
40437
|
-
const {
|
|
40438
|
-
viewGroup,
|
|
40439
|
-
...gCfg
|
|
40440
|
-
} = groups[gKey];
|
|
40441
|
-
items[gKey] = gCfg;
|
|
40442
|
-
}
|
|
40443
|
-
return items;
|
|
40444
|
-
}, {});
|
|
40445
|
-
};
|
|
40446
|
-
const getComponent = (component, key, config) => {
|
|
40447
|
-
switch (component) {
|
|
40448
|
-
case "repeatableModals":
|
|
40449
|
-
return /*#__PURE__*/jsxRuntime.jsx(RepeatableModals, {
|
|
40450
|
-
app: app,
|
|
40451
|
-
t: t,
|
|
40452
|
-
ajaxForms: ajaxForms,
|
|
40453
|
-
changeAjaxForms: changeAjaxForms,
|
|
40454
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
40455
|
-
getAppHeader: getAppHeader,
|
|
40456
|
-
user: user,
|
|
40457
|
-
getToken: getToken,
|
|
40458
|
-
name: key,
|
|
40459
|
-
data: data,
|
|
40460
|
-
config: config,
|
|
40461
|
-
linkingData: linkingData,
|
|
40462
|
-
linkingForms: linkingForms,
|
|
40463
|
-
ajaxOptions: ajaxOptions
|
|
40464
|
-
}, key);
|
|
40465
|
-
default:
|
|
40466
|
-
return /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
40467
|
-
children: "Component"
|
|
40468
|
-
});
|
|
40469
|
-
}
|
|
40470
|
-
};
|
|
40471
|
-
const isDisplayGroup = input => input.display && input.display === "group";
|
|
40472
|
-
const isSingleModal = input => input.type && input.type === "modal";
|
|
40473
|
-
const hasComponent = input => input.component && typeof input.component === "string";
|
|
40474
|
-
const typeRender = (groups, singleGroupsKeys, addedContent) => {
|
|
40475
|
-
const _length = Object.keys(groups || {}).length;
|
|
40476
|
-
const isEven = _length % 2 === 0;
|
|
40477
|
-
const groupped = Object.keys(groups).reduce((all, key) => {
|
|
40478
|
-
const _val = groups[key];
|
|
40479
|
-
const group = _val.group || _val?.meta?.group || _val.section;
|
|
40480
|
-
if (all[group]) {
|
|
40481
|
-
all[group][key] = _val;
|
|
40482
|
-
} else {
|
|
40483
|
-
all[group] = {
|
|
40484
|
-
[key]: _val
|
|
40485
|
-
};
|
|
40486
|
-
}
|
|
40487
|
-
return all;
|
|
40488
|
-
}, {});
|
|
40489
|
-
return Object.keys(groupped).map(key => {
|
|
40490
|
-
const groups = groupped[key];
|
|
40491
|
-
return /*#__PURE__*/jsxRuntime.jsx(React__default["default"].Fragment, {
|
|
40492
|
-
children: repeatObjects(groups, (key, ind) => {
|
|
40493
|
-
// normal group
|
|
40494
|
-
return hasComponent(groups[key]) ? getComponent(groups[key].component, key, groups[key]) : isGroupInput(groups[key], false, data) ? /*#__PURE__*/jsxRuntime.jsx(Group, {
|
|
40495
|
-
t: t,
|
|
40496
|
-
name: key,
|
|
40497
|
-
linkingData: linkingData,
|
|
40498
|
-
config: groups[key],
|
|
40499
|
-
data: data,
|
|
40500
|
-
allData: data,
|
|
40501
|
-
linkingForms: linkingForms,
|
|
40502
|
-
cols: 2,
|
|
40503
|
-
ajaxForms: ajaxForms,
|
|
40504
|
-
changeAjaxForms: changeAjaxForms,
|
|
40505
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
40506
|
-
getAppHeader: getAppHeader,
|
|
40507
|
-
user: user,
|
|
40508
|
-
getToken: getToken,
|
|
40509
|
-
evaluationConfig: evaluationConfig,
|
|
40510
|
-
ajaxOptions: ajaxOptions
|
|
40511
|
-
}, key) :
|
|
40512
|
-
// repeatable group
|
|
40513
|
-
isGroupInput(groups[key], true, data) ? /*#__PURE__*/jsxRuntime.jsx(RepeatableGroup, {
|
|
40514
|
-
app: app,
|
|
40515
|
-
t: t,
|
|
40516
|
-
ajaxForms: ajaxForms,
|
|
40517
|
-
changeAjaxForms: changeAjaxForms,
|
|
40518
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
40519
|
-
getAppHeader: getAppHeader,
|
|
40520
|
-
user: user,
|
|
40521
|
-
getToken: getToken,
|
|
40522
|
-
name: key,
|
|
40523
|
-
config: groups[key],
|
|
40524
|
-
data: data,
|
|
40525
|
-
allData: data,
|
|
40526
|
-
linkingData: linkingData,
|
|
40527
|
-
linkingForms: linkingForms,
|
|
40528
|
-
ajaxOptions: ajaxOptions
|
|
40529
|
-
}, key) :
|
|
40530
|
-
// single inputs grouped
|
|
40531
|
-
singleGroupsKeys.includes(key) ? (() => {
|
|
40532
|
-
if (!addedContent.includes(key)) {
|
|
40533
|
-
const currentGroup = Object.keys(groupSingle(groups)).find(k => Object.keys(groupSingle(groups)[k]).includes(key));
|
|
40534
|
-
addedContent.push(...Object.keys(groupSingle(groups)[currentGroup]));
|
|
40535
|
-
const config = groupSingle(groups)[currentGroup];
|
|
40536
|
-
if (groups[key].viewShowIf || groups[key]?.meta?.excludeFromView) {
|
|
40537
|
-
if (!showHideInput$3(groups[key], data)) {
|
|
40538
|
-
return null;
|
|
40539
|
-
}
|
|
40540
|
-
}
|
|
40541
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40542
|
-
className: "group",
|
|
40543
|
-
id: currentGroup,
|
|
40544
|
-
children: [groupConfig[currentGroup] ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40545
|
-
className: "title",
|
|
40546
|
-
children: /*#__PURE__*/jsxRuntime.jsx("h1", {
|
|
40547
|
-
children: groupConfig[currentGroup][language]
|
|
40548
|
-
})
|
|
40549
|
-
}) : null, /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
40550
|
-
app: app,
|
|
40551
|
-
t: t,
|
|
40552
|
-
ajaxForms: ajaxForms,
|
|
40553
|
-
changeAjaxForms: changeAjaxForms,
|
|
40554
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
40555
|
-
getAppHeader: getAppHeader,
|
|
40556
|
-
user: user,
|
|
40557
|
-
getToken: getToken,
|
|
40558
|
-
versionsDatapoints: versionsDatapoints,
|
|
40559
|
-
name: config.dataId || key,
|
|
40560
|
-
config: config,
|
|
40561
|
-
data: data,
|
|
40562
|
-
allData: data,
|
|
40563
|
-
linkingData: linkingData,
|
|
40564
|
-
className: isEven ? ind === _length - 1 || ind === _length - 2 ? "last" : undefined : ind === _length - 1 ? "last" : undefined,
|
|
40565
|
-
linkingForms: linkingForms,
|
|
40566
|
-
ajaxOptions: ajaxOptions,
|
|
40567
|
-
evaluationConfig: evaluationConfig,
|
|
40568
|
-
cols: 2
|
|
40569
|
-
}, key)]
|
|
40570
|
-
}, `${currentGroup}-${Date.now()}`);
|
|
40571
|
-
}
|
|
40572
|
-
})() :
|
|
40573
|
-
// display group
|
|
40574
|
-
isDisplayGroup(groups[key]) ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40575
|
-
className: "group display",
|
|
40576
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40577
|
-
className: "title",
|
|
40578
|
-
children: /*#__PURE__*/jsxRuntime.jsx("h1", {
|
|
40579
|
-
children: groups[key].label
|
|
40580
|
-
})
|
|
40581
|
-
}), typeRender(getDisplayGroupConfig(groups, key), singleGroupsKeys, addedContent)]
|
|
40582
|
-
}, key) :
|
|
40583
|
-
// single modal
|
|
40584
|
-
isSingleModal(groups[key]) ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40585
|
-
className: "group",
|
|
40586
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40587
|
-
className: "title",
|
|
40588
|
-
children: /*#__PURE__*/jsxRuntime.jsx("h1", {
|
|
40589
|
-
children: groups[key].outputLabel || getInputLabel$2(groups[key], data)
|
|
40590
|
-
})
|
|
40591
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
40592
|
-
app: app,
|
|
40593
|
-
t: t,
|
|
40594
|
-
ajaxForms: ajaxForms,
|
|
40595
|
-
changeAjaxForms: changeAjaxForms,
|
|
40596
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
40597
|
-
getAppHeader: getAppHeader,
|
|
40598
|
-
user: user,
|
|
40599
|
-
getToken: getToken,
|
|
40600
|
-
versionsDatapoints: versionsDatapoints,
|
|
40601
|
-
parent: key,
|
|
40602
|
-
name: groups[key].dataId || key,
|
|
40603
|
-
config: groups[key],
|
|
40604
|
-
className: "last",
|
|
40605
|
-
data: data,
|
|
40606
|
-
allData: data,
|
|
40607
|
-
linkingData: linkingData,
|
|
40608
|
-
linkingForms: linkingForms,
|
|
40609
|
-
ajaxOptions: ajaxOptions,
|
|
40610
|
-
evaluationConfig: evaluationConfig,
|
|
40611
|
-
cols: 2
|
|
40612
|
-
}, key)]
|
|
40613
|
-
}, key) : null;
|
|
40614
|
-
})
|
|
40615
|
-
}, key);
|
|
40616
|
-
});
|
|
40617
|
-
};
|
|
40618
|
-
React.useEffect(() => {
|
|
40619
|
-
setTimeout(() => {
|
|
40620
|
-
const groups = Array.from(document.getElementsByClassName("group"));
|
|
40621
|
-
const rows = Array.from(document.querySelectorAll(".repetable-row-extra"));
|
|
40622
|
-
rows.forEach(row => {
|
|
40623
|
-
const inputs = Array.from(row.querySelectorAll(".input"));
|
|
40624
|
-
const lasts = getLastRow(inputs.map((i, ind) => ind), 4);
|
|
40625
|
-
if (lasts) {
|
|
40626
|
-
lasts.forEach(index => inputs[index].classList.add("last"));
|
|
40627
|
-
}
|
|
40628
|
-
});
|
|
40629
|
-
groups.forEach(group => {
|
|
40630
|
-
// const isRepeatable = Array.from(group.classList).includes('repeatable');
|
|
40631
|
-
const inputs = Array.from(group.querySelectorAll(".input"));
|
|
40632
|
-
// if (inputs.length && !isRepeatable) {
|
|
40633
|
-
// if (inputs.length % 2 === 0) {
|
|
40634
|
-
// inputs[inputs.length - 1].classList.add('last');
|
|
40635
|
-
// inputs[inputs.length - 2].classList.add('last');
|
|
40636
|
-
// } else {
|
|
40637
|
-
// inputs[inputs.length - 1].classList.add('last');
|
|
40638
|
-
// }
|
|
40639
|
-
// }
|
|
40640
|
-
// remove groups without inputs
|
|
40641
|
-
if (!inputs.length) {
|
|
40642
|
-
group.remove();
|
|
40643
|
-
}
|
|
40644
|
-
});
|
|
40645
|
-
}, 200);
|
|
40646
|
-
}, [form, data]);
|
|
40647
|
-
React.useState({});
|
|
40648
|
-
React.useState({});
|
|
40649
|
-
React.useState({});
|
|
40650
|
-
const renderContent = (f, showTitle = true) => {
|
|
40651
|
-
if (f) {
|
|
40652
|
-
const alertType = ["error", "warning", "info", "success"];
|
|
40653
|
-
if (f.alertConf && f.alertConf.type === "warning") {
|
|
40654
|
-
return /*#__PURE__*/jsxRuntime.jsx(antd.Alert, {
|
|
40655
|
-
message: f.alertConf.text,
|
|
40656
|
-
type: f.alertConf.type,
|
|
40657
|
-
showIcon: true
|
|
40658
|
-
});
|
|
40659
|
-
}
|
|
40660
|
-
let {
|
|
40661
|
-
label,
|
|
40662
|
-
icon,
|
|
40663
|
-
position,
|
|
40664
|
-
...groups
|
|
40665
|
-
} = f;
|
|
40666
|
-
groups = Object.keys(groups).reduce((items, key) => {
|
|
40667
|
-
if (!groups[key]?.meta?.excludeFromView) {
|
|
40668
|
-
items[key] = groups[key];
|
|
40669
|
-
}
|
|
40670
|
-
return items;
|
|
40671
|
-
}, {});
|
|
40672
|
-
const addedContent = [];
|
|
40673
|
-
const singleGroupsKeys = [].concat(...Object.keys(groupSingle(groups)).map(key => Object.keys(groupSingle(groups)[key])));
|
|
40674
|
-
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
40675
|
-
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40676
|
-
className: "wrapper",
|
|
40677
|
-
style: {
|
|
40678
|
-
width: fullWidth ? "100%" : 700
|
|
40679
|
-
},
|
|
40680
|
-
children: [f.alertConf ? /*#__PURE__*/jsxRuntime.jsx(antd.Alert, {
|
|
40681
|
-
className: "w-100",
|
|
40682
|
-
style: {
|
|
40683
|
-
marginBottom: "20px"
|
|
40684
|
-
},
|
|
40685
|
-
message: f.alertConf.text,
|
|
40686
|
-
type: alertType.includes(f.alertConf.type) ? f.alertConf.type : "info",
|
|
40687
|
-
showIcon: true
|
|
40688
|
-
}) : null, typeRender(groups, singleGroupsKeys, addedContent)]
|
|
40689
|
-
}, Date.now())
|
|
40690
|
-
});
|
|
40691
|
-
}
|
|
40692
|
-
};
|
|
40693
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40694
|
-
className: "content",
|
|
40695
|
-
style: style,
|
|
40696
|
-
children: renderContent(form)
|
|
40697
|
-
});
|
|
40698
|
-
};
|
|
40699
|
-
|
|
40700
|
-
function Modal({
|
|
40701
|
-
t = text => text,
|
|
40702
|
-
open,
|
|
40703
|
-
title,
|
|
40704
|
-
children,
|
|
40705
|
-
onClose,
|
|
40706
|
-
onSuccess,
|
|
40707
|
-
cancelBtnText = "Cancel",
|
|
40708
|
-
saveBtnText = "Save",
|
|
40709
|
-
className,
|
|
40710
|
-
loading = false,
|
|
40711
|
-
disabled = false,
|
|
40712
|
-
withModalFormWrapper = true,
|
|
40713
|
-
...props
|
|
40714
|
-
}) {
|
|
40715
|
-
return /*#__PURE__*/jsxRuntime.jsxs(antd.Modal, {
|
|
40716
|
-
width: 650,
|
|
40717
|
-
footer: null,
|
|
40718
|
-
open: open,
|
|
40719
|
-
onCancel: onClose,
|
|
40720
|
-
title: /*#__PURE__*/jsxRuntime.jsx(ModalHeader, {
|
|
40721
|
-
title: t(title)
|
|
40722
|
-
}),
|
|
40723
|
-
className: `${className}`,
|
|
40724
|
-
...props,
|
|
40725
|
-
children: [withModalFormWrapper ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40726
|
-
className: "repeatable-modal-form",
|
|
40727
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40728
|
-
className: "daf-dynamic-form-form",
|
|
40729
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40730
|
-
className: "form",
|
|
40731
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40732
|
-
className: "daf-dynamic-form dynamic-form",
|
|
40733
|
-
children: children
|
|
40734
|
-
})
|
|
40735
|
-
})
|
|
40736
|
-
})
|
|
40737
|
-
}) : children, onSuccess && onClose ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
40738
|
-
className: "daf-form-bottom",
|
|
40739
|
-
children: [onClose && /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
40740
|
-
onClick: onClose,
|
|
40741
|
-
children: t(cancelBtnText)
|
|
40742
|
-
}), onSuccess && /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
40743
|
-
type: "primary",
|
|
40744
|
-
onClick: onSuccess,
|
|
40745
|
-
disabled: loading || disabled,
|
|
40746
|
-
children: t(saveBtnText)
|
|
40747
|
-
})]
|
|
40748
|
-
}) : null]
|
|
40749
|
-
});
|
|
40750
|
-
}
|
|
40751
|
-
|
|
40752
39903
|
class SourceService extends BaseService {
|
|
40753
39904
|
get(tab, filters) {
|
|
40754
39905
|
const {
|
|
@@ -40786,7 +39937,7 @@ class SourceService extends BaseService {
|
|
|
40786
39937
|
});
|
|
40787
39938
|
}
|
|
40788
39939
|
}
|
|
40789
|
-
|
|
39940
|
+
createLazyService(SourceService);
|
|
40790
39941
|
|
|
40791
39942
|
class VersionService extends BaseService {
|
|
40792
39943
|
getSources({
|
|
@@ -40800,344 +39951,7 @@ class VersionService extends BaseService {
|
|
|
40800
39951
|
});
|
|
40801
39952
|
}
|
|
40802
39953
|
}
|
|
40803
|
-
|
|
40804
|
-
|
|
40805
|
-
const getSourcesType = subject => {
|
|
40806
|
-
const typeMapping = {
|
|
40807
|
-
locations: "location",
|
|
40808
|
-
location: "location",
|
|
40809
|
-
"production-sites": "location",
|
|
40810
|
-
stakeholders: "stakeholder",
|
|
40811
|
-
stakeholder: "stakeholder",
|
|
40812
|
-
workers: "stakeholder",
|
|
40813
|
-
operators: "stakeholder",
|
|
40814
|
-
documents: "document",
|
|
40815
|
-
document: "document",
|
|
40816
|
-
events: "event",
|
|
40817
|
-
event: "event",
|
|
40818
|
-
activities: "event",
|
|
40819
|
-
incidents: "event"
|
|
40820
|
-
};
|
|
40821
|
-
return typeMapping[subject] ?? null;
|
|
40822
|
-
};
|
|
40823
|
-
|
|
40824
|
-
const Records = ({
|
|
40825
|
-
onSubmit,
|
|
40826
|
-
modalTitle = "Records",
|
|
40827
|
-
t = () => {},
|
|
40828
|
-
onClose = () => {},
|
|
40829
|
-
open = false,
|
|
40830
|
-
subject = "",
|
|
40831
|
-
id = ""
|
|
40832
|
-
}) => {
|
|
40833
|
-
const [form] = antd.Form.useForm();
|
|
40834
|
-
const [sources, setSources] = React.useState([]);
|
|
40835
|
-
const [versions, setVersions] = React.useState([]);
|
|
40836
|
-
const [selectedSource, setSelectedSource] = React.useState(null);
|
|
40837
|
-
const handleCancel = () => {
|
|
40838
|
-
onClose();
|
|
40839
|
-
form.resetFields();
|
|
40840
|
-
};
|
|
40841
|
-
const type = React.useMemo(() => getSourcesType(subject), [subject]);
|
|
40842
|
-
const getSources = async () => {
|
|
40843
|
-
try {
|
|
40844
|
-
const {
|
|
40845
|
-
data
|
|
40846
|
-
} = await SourceService$1.getSources({
|
|
40847
|
-
type,
|
|
40848
|
-
id
|
|
40849
|
-
});
|
|
40850
|
-
setSources(data);
|
|
40851
|
-
} catch (error) {
|
|
40852
|
-
console.error('Error fetching sources:', error);
|
|
40853
|
-
}
|
|
40854
|
-
};
|
|
40855
|
-
const getVersions = async () => {
|
|
40856
|
-
try {
|
|
40857
|
-
const {
|
|
40858
|
-
data
|
|
40859
|
-
} = await VersionService$1.getSources({
|
|
40860
|
-
type,
|
|
40861
|
-
id,
|
|
40862
|
-
params: {
|
|
40863
|
-
source: selectedSource
|
|
40864
|
-
}
|
|
40865
|
-
});
|
|
40866
|
-
console.log({
|
|
40867
|
-
data
|
|
40868
|
-
});
|
|
40869
|
-
setVersions(data);
|
|
40870
|
-
} catch (error) {
|
|
40871
|
-
console.error('Error fetching versions:', error);
|
|
40872
|
-
}
|
|
40873
|
-
};
|
|
40874
|
-
const sourceOptions = React.useMemo(() => {
|
|
40875
|
-
return sources.map(source => ({
|
|
40876
|
-
label: source?.name,
|
|
40877
|
-
value: source?.id
|
|
40878
|
-
}));
|
|
40879
|
-
}, [sources]);
|
|
40880
|
-
React.useEffect(() => {
|
|
40881
|
-
if (type && id) {
|
|
40882
|
-
getSources();
|
|
40883
|
-
}
|
|
40884
|
-
}, [type, id]);
|
|
40885
|
-
React.useEffect(() => {
|
|
40886
|
-
if (selectedSource) {
|
|
40887
|
-
getVersions();
|
|
40888
|
-
}
|
|
40889
|
-
}, [selectedSource]);
|
|
40890
|
-
const versionOptions = React.useMemo(() => {
|
|
40891
|
-
if (!versions?.numberOfVersions) return [];
|
|
40892
|
-
return Array.from({
|
|
40893
|
-
length: versions.numberOfVersions
|
|
40894
|
-
}, (_, index) => ({
|
|
40895
|
-
label: `Version ${index + 1}`,
|
|
40896
|
-
value: index + 1
|
|
40897
|
-
}));
|
|
40898
|
-
}, [versions]);
|
|
40899
|
-
const handleOk = async () => {
|
|
40900
|
-
try {
|
|
40901
|
-
const values = await form.validateFields();
|
|
40902
|
-
if (onSubmit) {
|
|
40903
|
-
onSubmit(values);
|
|
40904
|
-
}
|
|
40905
|
-
onClose();
|
|
40906
|
-
form.resetFields();
|
|
40907
|
-
} catch (error) {
|
|
40908
|
-
console.error('Validation failed:', error);
|
|
40909
|
-
}
|
|
40910
|
-
};
|
|
40911
|
-
return /*#__PURE__*/jsxRuntime.jsxs(Modal, {
|
|
40912
|
-
open: open,
|
|
40913
|
-
t: t,
|
|
40914
|
-
title: t(modalTitle),
|
|
40915
|
-
onSuccess: handleOk,
|
|
40916
|
-
onClose: handleCancel,
|
|
40917
|
-
withModalFormWrapper: false,
|
|
40918
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Form, {
|
|
40919
|
-
form: form,
|
|
40920
|
-
layout: "vertical",
|
|
40921
|
-
name: "recordsForm",
|
|
40922
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
|
|
40923
|
-
name: "source",
|
|
40924
|
-
label: t("Source"),
|
|
40925
|
-
rules: [{
|
|
40926
|
-
required: true,
|
|
40927
|
-
message: t('Please select an option')
|
|
40928
|
-
}],
|
|
40929
|
-
children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
|
|
40930
|
-
placeholder: t("Select"),
|
|
40931
|
-
showSearch: true,
|
|
40932
|
-
optionFilterProp: "children",
|
|
40933
|
-
onChange: value => {
|
|
40934
|
-
console.log('Selected source ID:', value);
|
|
40935
|
-
setSelectedSource(value);
|
|
40936
|
-
},
|
|
40937
|
-
children: sourceOptions.map(option => /*#__PURE__*/jsxRuntime.jsx(antd.Select.Option, {
|
|
40938
|
-
value: option.value,
|
|
40939
|
-
children: option.label
|
|
40940
|
-
}, option.value))
|
|
40941
|
-
})
|
|
40942
|
-
}), /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
|
|
40943
|
-
name: "version",
|
|
40944
|
-
label: t("Version"),
|
|
40945
|
-
rules: [{
|
|
40946
|
-
required: true,
|
|
40947
|
-
message: t('Please select an option')
|
|
40948
|
-
}],
|
|
40949
|
-
children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
|
|
40950
|
-
placeholder: t("Select"),
|
|
40951
|
-
showSearch: true,
|
|
40952
|
-
optionFilterProp: "children",
|
|
40953
|
-
children: versionOptions.map(option => /*#__PURE__*/jsxRuntime.jsx(antd.Select.Option, {
|
|
40954
|
-
value: option.value,
|
|
40955
|
-
children: option.label
|
|
40956
|
-
}, option.value))
|
|
40957
|
-
})
|
|
40958
|
-
})]
|
|
40959
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
40960
|
-
style: {
|
|
40961
|
-
height: 60
|
|
40962
|
-
}
|
|
40963
|
-
})]
|
|
40964
|
-
});
|
|
40965
|
-
};
|
|
40966
|
-
|
|
40967
|
-
const Navigation = ({
|
|
40968
|
-
form = {},
|
|
40969
|
-
data = {},
|
|
40970
|
-
group = null,
|
|
40971
|
-
subsection = null,
|
|
40972
|
-
search = null,
|
|
40973
|
-
onGroupChange = () => {},
|
|
40974
|
-
mod,
|
|
40975
|
-
// TODO: ADD this
|
|
40976
|
-
goTo,
|
|
40977
|
-
params,
|
|
40978
|
-
generatePath,
|
|
40979
|
-
getRedirectLink
|
|
40980
|
-
}) => {
|
|
40981
|
-
const [selectedGroup, setSelectedGroup] = React.useState(null);
|
|
40982
|
-
const [formGroups, setFormGroups] = React.useState([]);
|
|
40983
|
-
const [openKeys, setOpenKeys] = React.useState([]);
|
|
40984
|
-
const hasSubSections = f => Object.keys(f).map(key => propHasValue$1(f[key].subSection)).includes(true);
|
|
40985
|
-
const mapFormGroup = f => Object.keys(f).map(key => {
|
|
40986
|
-
const {
|
|
40987
|
-
label,
|
|
40988
|
-
showFormIf,
|
|
40989
|
-
position
|
|
40990
|
-
} = f[key];
|
|
40991
|
-
const disabled = getDisabled({
|
|
40992
|
-
disabled: f[key]?.title?.meta?.disabled || false,
|
|
40993
|
-
groupCheckboxDisableKey: f[key]?.title?.meta?.groupCheckboxDisableKey,
|
|
40994
|
-
data
|
|
40995
|
-
});
|
|
40996
|
-
const fConf = {
|
|
40997
|
-
key,
|
|
40998
|
-
label,
|
|
40999
|
-
showFormIf,
|
|
41000
|
-
show: filterForm(f[key], data),
|
|
41001
|
-
items: [],
|
|
41002
|
-
disabled: disabled || false,
|
|
41003
|
-
position
|
|
41004
|
-
};
|
|
41005
|
-
if (hasSubSections(f[key])) {
|
|
41006
|
-
fConf.items = {};
|
|
41007
|
-
const items = groupSubsections(f[key], true);
|
|
41008
|
-
Object.keys(items).forEach(i => {
|
|
41009
|
-
items[i].show = filterForm(items[i], data);
|
|
41010
|
-
fConf.items[i] = items[i];
|
|
41011
|
-
});
|
|
41012
|
-
}
|
|
41013
|
-
return fConf;
|
|
41014
|
-
});
|
|
41015
|
-
React.useEffect(() => {
|
|
41016
|
-
const formG = mapFormGroup(form).sort((a, b) => (a.position || 0) - (b.position || 0));
|
|
41017
|
-
const keys = [];
|
|
41018
|
-
formG.forEach(f => {
|
|
41019
|
-
if (!keys.includes(f.key)) {
|
|
41020
|
-
keys.push(f.key);
|
|
41021
|
-
}
|
|
41022
|
-
if (f.items) {
|
|
41023
|
-
Object.keys(f.items).forEach(item => {
|
|
41024
|
-
if (!keys.includes(`${f.key}/${item}`)) {
|
|
41025
|
-
keys.push(`${f.key}/${item}`);
|
|
41026
|
-
}
|
|
41027
|
-
});
|
|
41028
|
-
}
|
|
41029
|
-
});
|
|
41030
|
-
let sGroup = group;
|
|
41031
|
-
if (!group && formG.length) {
|
|
41032
|
-
sGroup = formG[0].key;
|
|
41033
|
-
}
|
|
41034
|
-
if (subsection && keys.includes(`${sGroup}/${subsection}`)) {
|
|
41035
|
-
sGroup = `${sGroup}/${subsection}`;
|
|
41036
|
-
}
|
|
41037
|
-
if (sGroup === selectedGroup) {
|
|
41038
|
-
groupChanged();
|
|
41039
|
-
}
|
|
41040
|
-
setFormGroups(formG);
|
|
41041
|
-
if (!keys.includes(sGroup)) {
|
|
41042
|
-
sGroup = keys[0];
|
|
41043
|
-
}
|
|
41044
|
-
setSelectedGroup(sGroup);
|
|
41045
|
-
}, [form, group, subsection]);
|
|
41046
|
-
React.useEffect(() => {
|
|
41047
|
-
groupChanged();
|
|
41048
|
-
}, [selectedGroup]);
|
|
41049
|
-
|
|
41050
|
-
// useEffect(() => {
|
|
41051
|
-
// if (!selectedGroup && !formGroups.map(f => f.key).includes(selectedGroup)) {
|
|
41052
|
-
// setSelectedGroup(formGroups.map(f => f.key)[0]);
|
|
41053
|
-
// }
|
|
41054
|
-
// }, [formGroups])
|
|
41055
|
-
|
|
41056
|
-
const groupChanged = () => {
|
|
41057
|
-
if (selectedGroup) {
|
|
41058
|
-
onGroupChange(selectedGroup);
|
|
41059
|
-
if (selectedGroup !== group) {
|
|
41060
|
-
// const path = formPaths.view(mod, getRedirectLink);
|
|
41061
|
-
const [section, subSection, subgroup] = selectedGroup.split('/');
|
|
41062
|
-
let url;
|
|
41063
|
-
if (params.formId) {
|
|
41064
|
-
// Dynamic context (within a project : monitoring, restoration, engagement, etc.)
|
|
41065
|
-
url = `/app/${params.namespace}/${params.id}/${params.subsection}/view/general/${params.formId}/${section}`;
|
|
41066
|
-
} else {
|
|
41067
|
-
// Default: organisation context
|
|
41068
|
-
const path = formPaths.view(mod, getRedirectLink);
|
|
41069
|
-
url = `${generatePath(path, {
|
|
41070
|
-
...params,
|
|
41071
|
-
group: section,
|
|
41072
|
-
subsection: subSection,
|
|
41073
|
-
subgroup: subgroup || undefined
|
|
41074
|
-
})}${search || ''}`;
|
|
41075
|
-
}
|
|
41076
|
-
goTo(url);
|
|
41077
|
-
}
|
|
41078
|
-
}
|
|
41079
|
-
setTimeout(() => {
|
|
41080
|
-
const groups = Array.from(document.getElementsByClassName('group'));
|
|
41081
|
-
const rows = Array.from(document.querySelectorAll('.repetable-row-extra'));
|
|
41082
|
-
rows.forEach(row => {
|
|
41083
|
-
const inputs = Array.from(row.querySelectorAll('.input'));
|
|
41084
|
-
const lasts = getLastRow(inputs.map((i, ind) => ind), 4);
|
|
41085
|
-
if (lasts) {
|
|
41086
|
-
lasts.forEach(index => inputs[index].classList.add('last'));
|
|
41087
|
-
}
|
|
41088
|
-
});
|
|
41089
|
-
groups.forEach(group => {
|
|
41090
|
-
// const isRepeatable = Array.from(group.classList).includes('repeatable');
|
|
41091
|
-
const inputs = Array.from(group.querySelectorAll('.input'));
|
|
41092
|
-
// if (inputs.length && !isRepeatable) {
|
|
41093
|
-
// if (inputs.length % 2 === 0) {
|
|
41094
|
-
// inputs[inputs.length - 1].classList.add('last');
|
|
41095
|
-
// inputs[inputs.length - 2].classList.add('last');
|
|
41096
|
-
// } else {
|
|
41097
|
-
// inputs[inputs.length - 1].classList.add('last');
|
|
41098
|
-
// }
|
|
41099
|
-
// }
|
|
41100
|
-
// remove groups without inputs
|
|
41101
|
-
if (!inputs.length) {
|
|
41102
|
-
group.remove();
|
|
41103
|
-
}
|
|
41104
|
-
});
|
|
41105
|
-
}, 200);
|
|
41106
|
-
};
|
|
41107
|
-
return selectedGroup ? /*#__PURE__*/jsxRuntime.jsx(antd.Menu, {
|
|
41108
|
-
mode: "inline",
|
|
41109
|
-
defaultSelectedKeys: [selectedGroup],
|
|
41110
|
-
selectedKeys: [selectedGroup],
|
|
41111
|
-
defaultOpenKeys: selectedGroup ? [selectedGroup.split('/')[0]] : [],
|
|
41112
|
-
openKeys: openKeys,
|
|
41113
|
-
onOpenChange: oKeys => {
|
|
41114
|
-
setOpenKeys(oKeys);
|
|
41115
|
-
},
|
|
41116
|
-
style: {
|
|
41117
|
-
overflowY: 'auto',
|
|
41118
|
-
overflowX: 'hidden'
|
|
41119
|
-
},
|
|
41120
|
-
onSelect: g => {
|
|
41121
|
-
setSelectedGroup(g.key);
|
|
41122
|
-
},
|
|
41123
|
-
children: formGroups.filter(key => key.show).map(key => key.items && typeof key.items === 'object' && Object.keys(key.items).length > 0 ? /*#__PURE__*/jsxRuntime.jsx(antd.Menu.SubMenu, {
|
|
41124
|
-
title: getInputLabel$2(key, data),
|
|
41125
|
-
children: Object.keys(key.items).filter(item => key.items[item].show).map(item => /*#__PURE__*/jsxRuntime.jsx(antd.Menu.Item, {
|
|
41126
|
-
level: 2,
|
|
41127
|
-
children: getInputLabel$2(key.items[item], data)
|
|
41128
|
-
}, `${key.key}/${item}`))
|
|
41129
|
-
}, key.key) : /*#__PURE__*/jsxRuntime.jsx(antd.Menu.Item, {
|
|
41130
|
-
disabled: key.disabled,
|
|
41131
|
-
onClick: props => {
|
|
41132
|
-
if (params.subgroup && params.group === props.key) {
|
|
41133
|
-
const path = formPaths.view(mod, getRedirectLink);
|
|
41134
|
-
goTo(`${generatePath(path, params)}${search || ''}`);
|
|
41135
|
-
}
|
|
41136
|
-
},
|
|
41137
|
-
children: getInputLabel$2(key, data)
|
|
41138
|
-
}, key.key))
|
|
41139
|
-
}) : null;
|
|
41140
|
-
};
|
|
39954
|
+
createLazyService(VersionService);
|
|
41141
39955
|
|
|
41142
39956
|
styled__default["default"](antd.Select)`
|
|
41143
39957
|
width: 100%;
|
|
@@ -43950,7 +42764,10 @@ const PlantingLocations = ({
|
|
|
43950
42764
|
return eventsWithGPS.map((event, index) => {
|
|
43951
42765
|
const locationCheckArrival = event.locationCheckArrival;
|
|
43952
42766
|
const matchingLocation = locations.find(location => locationCheckArrival.name === location.name || locationCheckArrival._id === location.id || location.id === locationCheckArrival._id) || locations[0];
|
|
43953
|
-
const area = matchingLocation?.perimeter ? matchingLocation.perimeter.map(coord => Array.isArray(coord) && coord.length >= 2 ? [coord[1], coord[0]] : coord) :
|
|
42767
|
+
const area = matchingLocation?.perimeter ? matchingLocation.perimeter.map(coord => Array.isArray(coord) && coord.length >= 2 ? [coord[1], coord[0]] : coord) : null;
|
|
42768
|
+
|
|
42769
|
+
// Only include area if it has at least 3 valid coordinates
|
|
42770
|
+
const validArea = area && Array.isArray(area) && area.length >= 3 ? area : null;
|
|
43954
42771
|
const gps = {
|
|
43955
42772
|
latitude: locationCheckArrival.latitude,
|
|
43956
42773
|
longitude: locationCheckArrival.longitude
|
|
@@ -43959,7 +42776,7 @@ const PlantingLocations = ({
|
|
|
43959
42776
|
const locationName = matchingLocation?.name || locationCheckArrival.name || 'Planting Location';
|
|
43960
42777
|
return {
|
|
43961
42778
|
_id: locationCheckArrival._id || event._id || {},
|
|
43962
|
-
area:
|
|
42779
|
+
area: validArea,
|
|
43963
42780
|
color: color,
|
|
43964
42781
|
datastakeId: `LOC-${String(index + 1).padStart(9, '0')}`,
|
|
43965
42782
|
gps: gps,
|
|
@@ -47098,639 +45915,6 @@ const MineSummary = ({
|
|
|
47098
45915
|
});
|
|
47099
45916
|
};
|
|
47100
45917
|
|
|
47101
|
-
const useViewUrlParams = ({
|
|
47102
|
-
params,
|
|
47103
|
-
push,
|
|
47104
|
-
pathname,
|
|
47105
|
-
search,
|
|
47106
|
-
searchParams,
|
|
47107
|
-
setSearchParams
|
|
47108
|
-
}) => {
|
|
47109
|
-
const [namespace, setNamespace] = React.useState(params?.namespace);
|
|
47110
|
-
const [id, setId] = React.useState(params?.id);
|
|
47111
|
-
const [group, setGroup] = React.useState(params?.group);
|
|
47112
|
-
const [subsection, setSubSection] = React.useState(params?.subsection);
|
|
47113
|
-
const sourceUrl = searchParams.get("source");
|
|
47114
|
-
const versionUrl = searchParams.get("version");
|
|
47115
|
-
const [source, setSource] = React.useState(sourceUrl || null);
|
|
47116
|
-
const [version, setVersion] = React.useState(versionUrl || null);
|
|
47117
|
-
React.useEffect(() => {
|
|
47118
|
-
if (id && params.id !== id || namespace && namespace !== params.namespace) {
|
|
47119
|
-
setGroup(undefined);
|
|
47120
|
-
setSubSection(undefined);
|
|
47121
|
-
// setSubGroup(undefined);
|
|
47122
|
-
} else {
|
|
47123
|
-
setGroup(params.group);
|
|
47124
|
-
setSubSection(params.subsection);
|
|
47125
|
-
// setSubGroup(params.subgroup);
|
|
47126
|
-
}
|
|
47127
|
-
setNamespace(params.namespace);
|
|
47128
|
-
setId(params.id);
|
|
47129
|
-
}, [params]);
|
|
47130
|
-
React.useEffect(() => {
|
|
47131
|
-
if (source && version) {
|
|
47132
|
-
const newParams = new URLSearchParams(searchParams);
|
|
47133
|
-
newParams.set("source", source);
|
|
47134
|
-
newParams.set("version", version);
|
|
47135
|
-
setSearchParams(newParams);
|
|
47136
|
-
}
|
|
47137
|
-
}, [source, version]);
|
|
47138
|
-
const goBackFromSource = React.useCallback(() => {
|
|
47139
|
-
const params = new URLSearchParams(searchParams);
|
|
47140
|
-
params.delete("source");
|
|
47141
|
-
params.delete("version");
|
|
47142
|
-
setSearchParams(params);
|
|
47143
|
-
setVersion(null);
|
|
47144
|
-
setSource(null);
|
|
47145
|
-
}, [searchParams, setSearchParams]);
|
|
47146
|
-
const getEditLink = React.useCallback(srcId => {
|
|
47147
|
-
const r = new RegExp(`\/view\/`);
|
|
47148
|
-
const [previous, extra] = pathname.split(r);
|
|
47149
|
-
if (srcId) {
|
|
47150
|
-
push(`${previous}/edit/${extra}?sourceId=${srcId}`);
|
|
47151
|
-
return;
|
|
47152
|
-
}
|
|
47153
|
-
if (search) {
|
|
47154
|
-
push(`${previous}/edit/${extra}${search}`);
|
|
47155
|
-
} else {
|
|
47156
|
-
push(`${previous}/edit/${extra}`);
|
|
47157
|
-
}
|
|
47158
|
-
}, [pathname, search, push]);
|
|
47159
|
-
const match = React.useMemo(() => ({
|
|
47160
|
-
params,
|
|
47161
|
-
path: pathname
|
|
47162
|
-
}), [params, pathname]);
|
|
47163
|
-
return {
|
|
47164
|
-
namespace,
|
|
47165
|
-
id,
|
|
47166
|
-
group,
|
|
47167
|
-
subsection,
|
|
47168
|
-
params,
|
|
47169
|
-
source,
|
|
47170
|
-
setSource,
|
|
47171
|
-
sourceUrl,
|
|
47172
|
-
version,
|
|
47173
|
-
setVersion,
|
|
47174
|
-
versionUrl,
|
|
47175
|
-
goBackFromSource,
|
|
47176
|
-
getEditLink,
|
|
47177
|
-
match,
|
|
47178
|
-
search
|
|
47179
|
-
};
|
|
47180
|
-
};
|
|
47181
|
-
|
|
47182
|
-
const usePrepareForm = ({
|
|
47183
|
-
namespaceConfig,
|
|
47184
|
-
allData,
|
|
47185
|
-
id,
|
|
47186
|
-
namespace,
|
|
47187
|
-
t,
|
|
47188
|
-
mode,
|
|
47189
|
-
APP,
|
|
47190
|
-
viewConfig
|
|
47191
|
-
}) => {
|
|
47192
|
-
const [form, setForm] = React.useState({});
|
|
47193
|
-
const [data, setData] = React.useState({});
|
|
47194
|
-
const [groups, setGroups] = React.useState({});
|
|
47195
|
-
const [linkingForms, setLinkingForms] = React.useState({});
|
|
47196
|
-
const [loading, setLoading] = React.useState(true);
|
|
47197
|
-
const [notFound, setNotFound] = React.useState(false);
|
|
47198
|
-
const prepareForm = currentView => {
|
|
47199
|
-
const dKey = namespaceConfig.dataKey;
|
|
47200
|
-
const nKey = `${APP}-${currentView}`;
|
|
47201
|
-
if (hasKeyInObject(allData, dKey) && hasKeyInObject(allData[dKey], nKey)) {
|
|
47202
|
-
const {
|
|
47203
|
-
form = {},
|
|
47204
|
-
data = {},
|
|
47205
|
-
config = {},
|
|
47206
|
-
linkingForms = {}
|
|
47207
|
-
} = JSON.parse(JSON.stringify(allData[dKey][nKey] || {}));
|
|
47208
|
-
if (data.datastakeId === id || id === "user") {
|
|
47209
|
-
if (viewConfig.linkingSubjects.includes(namespace)) {
|
|
47210
|
-
setForm({
|
|
47211
|
-
...form,
|
|
47212
|
-
linking: {
|
|
47213
|
-
position: 100,
|
|
47214
|
-
excludeFromEdit: true,
|
|
47215
|
-
label: t("Linked Subjects"),
|
|
47216
|
-
template: "linkingSubjects"
|
|
47217
|
-
}
|
|
47218
|
-
});
|
|
47219
|
-
} else {
|
|
47220
|
-
setForm(form);
|
|
47221
|
-
}
|
|
47222
|
-
setData(data);
|
|
47223
|
-
setGroups(config.groups || {});
|
|
47224
|
-
setLinkingForms(linkingForms);
|
|
47225
|
-
setLoading(false);
|
|
47226
|
-
setNotFound(false);
|
|
47227
|
-
} else if (!data.id) {
|
|
47228
|
-
if (mode === "proxy") {
|
|
47229
|
-
window.location.reload();
|
|
47230
|
-
} else {
|
|
47231
|
-
setLoading(false);
|
|
47232
|
-
setNotFound(true);
|
|
47233
|
-
}
|
|
47234
|
-
}
|
|
47235
|
-
}
|
|
47236
|
-
};
|
|
47237
|
-
const getCertainData = allData[namespaceConfig.dataKey];
|
|
47238
|
-
React.useEffect(() => {
|
|
47239
|
-
if (namespace && namespaceConfig) {
|
|
47240
|
-
prepareForm(namespaceConfig.view);
|
|
47241
|
-
}
|
|
47242
|
-
}, [getCertainData, namespaceConfig]);
|
|
47243
|
-
return {
|
|
47244
|
-
form,
|
|
47245
|
-
setForm,
|
|
47246
|
-
data,
|
|
47247
|
-
setData,
|
|
47248
|
-
groups,
|
|
47249
|
-
setGroups,
|
|
47250
|
-
linkingForms,
|
|
47251
|
-
setLinkingForms,
|
|
47252
|
-
loading,
|
|
47253
|
-
setLoading,
|
|
47254
|
-
notFound,
|
|
47255
|
-
setNotFound,
|
|
47256
|
-
prepareForm
|
|
47257
|
-
};
|
|
47258
|
-
};
|
|
47259
|
-
|
|
47260
|
-
const useViewPermissions = ({
|
|
47261
|
-
data,
|
|
47262
|
-
id,
|
|
47263
|
-
namespaceOverrides = {
|
|
47264
|
-
supportedNamespaces: {},
|
|
47265
|
-
canEdit: {}
|
|
47266
|
-
},
|
|
47267
|
-
namespace,
|
|
47268
|
-
user,
|
|
47269
|
-
push,
|
|
47270
|
-
getRedirectLink,
|
|
47271
|
-
namespaceConfig,
|
|
47272
|
-
APP,
|
|
47273
|
-
viewConfig
|
|
47274
|
-
}) => {
|
|
47275
|
-
const baseNamespaceKeys = Object.keys(namespaceConfig);
|
|
47276
|
-
const baseSupportedNamespaces = baseNamespaceKeys.reduce((acc, key) => {
|
|
47277
|
-
acc[key] = () => true;
|
|
47278
|
-
return acc;
|
|
47279
|
-
}, {});
|
|
47280
|
-
const isSupportedNamespaces = React.useMemo(() => ({
|
|
47281
|
-
...baseSupportedNamespaces,
|
|
47282
|
-
...namespaceOverrides.supportedNamespaces
|
|
47283
|
-
}), [data, id]);
|
|
47284
|
-
const isSupported = typeof isSupportedNamespaces[namespace] === "function" ? isSupportedNamespaces[namespace]() && viewConfig.supportedNamespaces[APP] && namespaceConfig.supportedNamespaces[APP].includes(namespace) : namespaceConfig.supportedNamespaces[APP] && namespaceConfig.supportedNamespaces[APP].includes(namespace);
|
|
47285
|
-
const isUserData = () => {
|
|
47286
|
-
return data && data.authorId && user?.company?.id === data.authorId;
|
|
47287
|
-
};
|
|
47288
|
-
const canEdit = React.useMemo(() => {
|
|
47289
|
-
const baseCanEditAction = baseNamespaceKeys.reduce((acc, key) => {
|
|
47290
|
-
acc[key] = () => isUserData();
|
|
47291
|
-
return acc;
|
|
47292
|
-
}, {});
|
|
47293
|
-
const canEditAction = {
|
|
47294
|
-
...baseCanEditAction,
|
|
47295
|
-
...namespaceOverrides.canEdit
|
|
47296
|
-
};
|
|
47297
|
-
return canEditAction[namespace] ? canEditAction[namespace]() : false;
|
|
47298
|
-
}, [namespace, data, user]);
|
|
47299
|
-
React.useEffect(() => {
|
|
47300
|
-
if (data) {
|
|
47301
|
-
if (typeof isSupportedNamespaces[namespace] === "function") {
|
|
47302
|
-
if (!isSupportedNamespaces[namespace]()) {
|
|
47303
|
-
push(getRedirectLink(`/app`));
|
|
47304
|
-
}
|
|
47305
|
-
}
|
|
47306
|
-
}
|
|
47307
|
-
}, [data, namespace]);
|
|
47308
|
-
return {
|
|
47309
|
-
isSupportedNamespaces,
|
|
47310
|
-
canEdit,
|
|
47311
|
-
isSupported
|
|
47312
|
-
};
|
|
47313
|
-
};
|
|
47314
|
-
|
|
47315
|
-
const submitSubjectData = async (namespace, data, serviceMap) => {
|
|
47316
|
-
const service = serviceMap[namespace];
|
|
47317
|
-
if (!service) {
|
|
47318
|
-
throw new Error(`No service found for namespace: ${namespace}`);
|
|
47319
|
-
}
|
|
47320
|
-
const response = await service.submitStep(data, data.datastakeId || data.id);
|
|
47321
|
-
return response.data;
|
|
47322
|
-
};
|
|
47323
|
-
const useSubmitSubject = ({
|
|
47324
|
-
namespace,
|
|
47325
|
-
data,
|
|
47326
|
-
serviceMap
|
|
47327
|
-
}) => {
|
|
47328
|
-
const [isDisabled, setIsDisabled] = React.useState(false);
|
|
47329
|
-
const [loading, setLoading] = React.useState(false);
|
|
47330
|
-
const [isPublished, setIsPublished] = React.useState(false);
|
|
47331
|
-
const submitSubject = React.useCallback(async () => {
|
|
47332
|
-
try {
|
|
47333
|
-
setLoading(true);
|
|
47334
|
-
const response = await submitSubjectData(namespace, data, serviceMap);
|
|
47335
|
-
setIsDisabled(response.published);
|
|
47336
|
-
setIsPublished(response.published);
|
|
47337
|
-
} catch (error) {
|
|
47338
|
-
console.error("Submit error:", error);
|
|
47339
|
-
} finally {
|
|
47340
|
-
setLoading(false);
|
|
47341
|
-
}
|
|
47342
|
-
}, [namespace, data]);
|
|
47343
|
-
return {
|
|
47344
|
-
submitSubject,
|
|
47345
|
-
isDisabled,
|
|
47346
|
-
submitLoading: loading,
|
|
47347
|
-
isPublished
|
|
47348
|
-
};
|
|
47349
|
-
};
|
|
47350
|
-
|
|
47351
|
-
const useCallToGetData = ({
|
|
47352
|
-
namespaceConfig,
|
|
47353
|
-
namespace,
|
|
47354
|
-
allData,
|
|
47355
|
-
id,
|
|
47356
|
-
isSupported,
|
|
47357
|
-
namespaceGet,
|
|
47358
|
-
source,
|
|
47359
|
-
version,
|
|
47360
|
-
user,
|
|
47361
|
-
setLoading,
|
|
47362
|
-
APP
|
|
47363
|
-
}) => {
|
|
47364
|
-
const isFirstRender = React.useRef(true);
|
|
47365
|
-
const callToGetData = (_doCall = false) => {
|
|
47366
|
-
const dKey = namespaceConfig.dataKey;
|
|
47367
|
-
const nKey = `${APP}-${getNkey(namespace)}`;
|
|
47368
|
-
const doCall = _doCall ? true : hasKeyInObject(allData, dKey) && hasKeyInObject(allData[dKey], nKey) ? allData[dKey][nKey]?.data?.datastakeId !== id : true;
|
|
47369
|
-
if (doCall) {
|
|
47370
|
-
if (isSupported) {
|
|
47371
|
-
namespaceGet[namespace]();
|
|
47372
|
-
}
|
|
47373
|
-
}
|
|
47374
|
-
};
|
|
47375
|
-
React.useEffect(() => {
|
|
47376
|
-
if (isFirstRender.current) {
|
|
47377
|
-
isFirstRender.current = false;
|
|
47378
|
-
return;
|
|
47379
|
-
}
|
|
47380
|
-
callToGetData(true);
|
|
47381
|
-
}, [source, version]);
|
|
47382
|
-
React.useEffect(() => {
|
|
47383
|
-
callToGetData(true);
|
|
47384
|
-
}, [id, namespace, user.language]);
|
|
47385
|
-
const onStorageUpdate = e => {
|
|
47386
|
-
const {
|
|
47387
|
-
key,
|
|
47388
|
-
newValue
|
|
47389
|
-
} = e;
|
|
47390
|
-
if (key === `${id}-loading` && newValue) {
|
|
47391
|
-
setLoading(newValue);
|
|
47392
|
-
}
|
|
47393
|
-
if (key === `${id}-updated` && newValue) {
|
|
47394
|
-
setLoading(true);
|
|
47395
|
-
callToGetData();
|
|
47396
|
-
}
|
|
47397
|
-
};
|
|
47398
|
-
React.useEffect(() => {
|
|
47399
|
-
window.addEventListener("storage", onStorageUpdate);
|
|
47400
|
-
return () => {
|
|
47401
|
-
window.removeEventListener("storage", onStorageUpdate);
|
|
47402
|
-
};
|
|
47403
|
-
}, []);
|
|
47404
|
-
React.useEffect(() => {
|
|
47405
|
-
setLoading(true);
|
|
47406
|
-
}, [namespace]);
|
|
47407
|
-
return {
|
|
47408
|
-
callToGetData
|
|
47409
|
-
};
|
|
47410
|
-
};
|
|
47411
|
-
|
|
47412
|
-
const useViewActions = ({
|
|
47413
|
-
namespace,
|
|
47414
|
-
data,
|
|
47415
|
-
isSupported,
|
|
47416
|
-
canEdit,
|
|
47417
|
-
versionUrl,
|
|
47418
|
-
sourceUrl,
|
|
47419
|
-
getEditLink,
|
|
47420
|
-
submitSubject,
|
|
47421
|
-
isDisabled,
|
|
47422
|
-
setOpenRecordsModal,
|
|
47423
|
-
goBackFromSource,
|
|
47424
|
-
push,
|
|
47425
|
-
getRedirectLink,
|
|
47426
|
-
t,
|
|
47427
|
-
viewConfig,
|
|
47428
|
-
buttonActions
|
|
47429
|
-
}) => {
|
|
47430
|
-
const [pageActions, setPageActions] = React.useState([]);
|
|
47431
|
-
const [extraPageActions, setExtraPageActions] = React.useState([]);
|
|
47432
|
-
React.useEffect(() => {
|
|
47433
|
-
const actions = [];
|
|
47434
|
-
const extraActions = [];
|
|
47435
|
-
if (!isSupported) {
|
|
47436
|
-
setPageActions([]);
|
|
47437
|
-
setExtraPageActions([]);
|
|
47438
|
-
return;
|
|
47439
|
-
}
|
|
47440
|
-
if (canEdit) {
|
|
47441
|
-
if (viewConfig.namespacesWithoutActionButtons.includes(namespace)) {
|
|
47442
|
-
if (viewConfig.editOnlyButton.includes(namespace)) {
|
|
47443
|
-
if (versionUrl && sourceUrl) {
|
|
47444
|
-
actions.push(buttonActions.createBackButton(t, goBackFromSource));
|
|
47445
|
-
} else {
|
|
47446
|
-
actions.push(buttonActions.createEditButton(t, getEditLink));
|
|
47447
|
-
}
|
|
47448
|
-
}
|
|
47449
|
-
} else {
|
|
47450
|
-
if (versionUrl && sourceUrl) {
|
|
47451
|
-
actions.push(buttonActions.createBackButton(t, goBackFromSource));
|
|
47452
|
-
} else {
|
|
47453
|
-
actions.push(buttonActions.createSubmitButton(t, submitSubject, isDisabled, data));
|
|
47454
|
-
actions.push(buttonActions.createEditButton(t, getEditLink));
|
|
47455
|
-
// actions.push(createRecordsButton(t, setOpenRecordsModal));
|
|
47456
|
-
}
|
|
47457
|
-
}
|
|
47458
|
-
}
|
|
47459
|
-
if (viewConfig.summaryNamespaces.includes(namespace)) {
|
|
47460
|
-
extraActions.push(buttonActions.createSummaryButton(t, namespace, data, push, getRedirectLink));
|
|
47461
|
-
extraActions.push(buttonActions.createRecordsButton(t, setOpenRecordsModal));
|
|
47462
|
-
}
|
|
47463
|
-
setPageActions(actions);
|
|
47464
|
-
setExtraPageActions(extraActions);
|
|
47465
|
-
}, [namespace, data, isSupported, canEdit, versionUrl, sourceUrl, isDisabled, t, getEditLink, submitSubject, goBackFromSource, setOpenRecordsModal, push, getRedirectLink]);
|
|
47466
|
-
return {
|
|
47467
|
-
pageActions,
|
|
47468
|
-
extraPageActions
|
|
47469
|
-
};
|
|
47470
|
-
};
|
|
47471
|
-
|
|
47472
|
-
const View = ({
|
|
47473
|
-
push,
|
|
47474
|
-
getRedirectLink,
|
|
47475
|
-
allData,
|
|
47476
|
-
ajaxForms,
|
|
47477
|
-
changeAjaxForms,
|
|
47478
|
-
t,
|
|
47479
|
-
namespaceConfiguaration,
|
|
47480
|
-
params,
|
|
47481
|
-
pathname,
|
|
47482
|
-
search,
|
|
47483
|
-
searchParams,
|
|
47484
|
-
setSearchParams,
|
|
47485
|
-
mode = "app",
|
|
47486
|
-
APP,
|
|
47487
|
-
viewConfig,
|
|
47488
|
-
partners,
|
|
47489
|
-
setSelectedPartners,
|
|
47490
|
-
user,
|
|
47491
|
-
serviceMap,
|
|
47492
|
-
actionMap,
|
|
47493
|
-
goBack,
|
|
47494
|
-
breadcrumbs,
|
|
47495
|
-
theme,
|
|
47496
|
-
buttonActions,
|
|
47497
|
-
generatePath,
|
|
47498
|
-
getApiBaseUrl,
|
|
47499
|
-
getAppHeader
|
|
47500
|
-
// ADD CALLBACK TO GET THE CURRENT NAMESPACE CONFIG
|
|
47501
|
-
}) => {
|
|
47502
|
-
const getNamespaceConfig = namespace => namespaceConfiguaration[namespace];
|
|
47503
|
-
const [openRecordsModal, setOpenRecordsModal] = React.useState(false);
|
|
47504
|
-
|
|
47505
|
-
// HANDLES THE URL PARAMS FOR THE VIEW PAGE
|
|
47506
|
-
const {
|
|
47507
|
-
namespace,
|
|
47508
|
-
id,
|
|
47509
|
-
group,
|
|
47510
|
-
subsection,
|
|
47511
|
-
source,
|
|
47512
|
-
setSource,
|
|
47513
|
-
sourceUrl,
|
|
47514
|
-
version,
|
|
47515
|
-
setVersion,
|
|
47516
|
-
versionUrl,
|
|
47517
|
-
goBackFromSource,
|
|
47518
|
-
getEditLink,
|
|
47519
|
-
match
|
|
47520
|
-
} = useViewUrlParams({
|
|
47521
|
-
params,
|
|
47522
|
-
push,
|
|
47523
|
-
pathname,
|
|
47524
|
-
search,
|
|
47525
|
-
searchParams,
|
|
47526
|
-
setSearchParams
|
|
47527
|
-
});
|
|
47528
|
-
const namespaceConfig = React.useMemo(() => getNamespaceConfig(namespace), [namespace]);
|
|
47529
|
-
|
|
47530
|
-
// PREPARES THE FORM FOR THE VIEW PAGE
|
|
47531
|
-
const {
|
|
47532
|
-
form,
|
|
47533
|
-
data,
|
|
47534
|
-
groups,
|
|
47535
|
-
linkingForms,
|
|
47536
|
-
loading,
|
|
47537
|
-
setLoading,
|
|
47538
|
-
notFound
|
|
47539
|
-
} = usePrepareForm({
|
|
47540
|
-
namespaceConfig,
|
|
47541
|
-
allData,
|
|
47542
|
-
id,
|
|
47543
|
-
namespace,
|
|
47544
|
-
t,
|
|
47545
|
-
mode,
|
|
47546
|
-
APP,
|
|
47547
|
-
viewConfig
|
|
47548
|
-
});
|
|
47549
|
-
const {
|
|
47550
|
-
canEdit,
|
|
47551
|
-
isSupported
|
|
47552
|
-
} = useViewPermissions({
|
|
47553
|
-
data,
|
|
47554
|
-
id,
|
|
47555
|
-
namespace,
|
|
47556
|
-
user,
|
|
47557
|
-
push,
|
|
47558
|
-
getRedirectLink,
|
|
47559
|
-
namespaceConfig: namespaceConfiguaration,
|
|
47560
|
-
APP,
|
|
47561
|
-
viewConfig
|
|
47562
|
-
});
|
|
47563
|
-
const groupForm = React.useMemo(() => {
|
|
47564
|
-
const gF = form[group] || {};
|
|
47565
|
-
if (subsection) {
|
|
47566
|
-
const sectionForms = groupSubsections(gF);
|
|
47567
|
-
if (sectionForms[subsection]) {
|
|
47568
|
-
return sectionForms[subsection];
|
|
47569
|
-
}
|
|
47570
|
-
}
|
|
47571
|
-
return gF;
|
|
47572
|
-
}, [form, group, subsection]);
|
|
47573
|
-
const {
|
|
47574
|
-
submitSubject,
|
|
47575
|
-
isDisabled,
|
|
47576
|
-
submitLoading,
|
|
47577
|
-
isPublished
|
|
47578
|
-
} = useSubmitSubject({
|
|
47579
|
-
namespace,
|
|
47580
|
-
data,
|
|
47581
|
-
serviceMap
|
|
47582
|
-
});
|
|
47583
|
-
const {
|
|
47584
|
-
pageActions,
|
|
47585
|
-
extraPageActions
|
|
47586
|
-
} = useViewActions({
|
|
47587
|
-
namespace,
|
|
47588
|
-
data,
|
|
47589
|
-
isSupported,
|
|
47590
|
-
canEdit,
|
|
47591
|
-
versionUrl,
|
|
47592
|
-
sourceUrl,
|
|
47593
|
-
getEditLink,
|
|
47594
|
-
submitSubject,
|
|
47595
|
-
isDisabled,
|
|
47596
|
-
setOpenRecordsModal,
|
|
47597
|
-
goBackFromSource,
|
|
47598
|
-
push,
|
|
47599
|
-
getRedirectLink,
|
|
47600
|
-
t,
|
|
47601
|
-
viewConfig,
|
|
47602
|
-
buttonActions
|
|
47603
|
-
});
|
|
47604
|
-
const action = React.useMemo(() => actionMap[namespaceConfig?.action], [namespaceConfig?.action]);
|
|
47605
|
-
const namespaceGet = {
|
|
47606
|
-
[namespace]: () => {
|
|
47607
|
-
return action({
|
|
47608
|
-
namespace: namespaceConfig.namespace,
|
|
47609
|
-
module: APP,
|
|
47610
|
-
view: namespaceConfig.view,
|
|
47611
|
-
...(namespaceConfig.scope && {
|
|
47612
|
-
scope: namespaceConfig.scope
|
|
47613
|
-
}),
|
|
47614
|
-
datastakeId: id,
|
|
47615
|
-
version,
|
|
47616
|
-
source
|
|
47617
|
-
});
|
|
47618
|
-
}
|
|
47619
|
-
};
|
|
47620
|
-
useCallToGetData({
|
|
47621
|
-
namespaceConfig,
|
|
47622
|
-
namespace,
|
|
47623
|
-
allData,
|
|
47624
|
-
id,
|
|
47625
|
-
isSupported,
|
|
47626
|
-
namespaceGet,
|
|
47627
|
-
source,
|
|
47628
|
-
version,
|
|
47629
|
-
user,
|
|
47630
|
-
setLoading
|
|
47631
|
-
});
|
|
47632
|
-
const extraLinking = React.useMemo(() => {
|
|
47633
|
-
return null;
|
|
47634
|
-
}, [namespace, match, data]);
|
|
47635
|
-
const sourceOptions = React.useMemo(() => {
|
|
47636
|
-
return partners.map(partner => {
|
|
47637
|
-
const isOwnData = partner.id === user?.company?.id;
|
|
47638
|
-
return {
|
|
47639
|
-
label: partner.nickName,
|
|
47640
|
-
value: partner.id,
|
|
47641
|
-
avatar: isOwnData ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
47642
|
-
children: "OWN"
|
|
47643
|
-
}) : undefined,
|
|
47644
|
-
background: isOwnData ? theme.colorPrimary7 : undefined,
|
|
47645
|
-
color: isOwnData ? "white" : undefined
|
|
47646
|
-
};
|
|
47647
|
-
});
|
|
47648
|
-
}, [partners, user]);
|
|
47649
|
-
const actionButtons = React.useMemo(() => {
|
|
47650
|
-
return groupForm?.template === "linkingSubjects" ? pageActions.filter(v => v.key !== "edit") : pageActions;
|
|
47651
|
-
}, [groupForm, pageActions]);
|
|
47652
|
-
if (!isSupported || notFound || loading) {
|
|
47653
|
-
return /*#__PURE__*/jsxRuntime.jsx(Loading, {});
|
|
47654
|
-
}
|
|
47655
|
-
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
47656
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
47657
|
-
className: "daf-view-form",
|
|
47658
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(DAFHeader, {
|
|
47659
|
-
title: data?.name || "",
|
|
47660
|
-
breadcrumbs: breadcrumbs,
|
|
47661
|
-
goBackTo: goBack,
|
|
47662
|
-
actionButtons: actionButtons,
|
|
47663
|
-
extraButtons: extraPageActions,
|
|
47664
|
-
addedHeaderFirst: true,
|
|
47665
|
-
addedHeader: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
47666
|
-
className: "flex flex-row gap-4",
|
|
47667
|
-
style: {
|
|
47668
|
-
marginRight: 8
|
|
47669
|
-
},
|
|
47670
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
|
|
47671
|
-
options: [...sourceOptions],
|
|
47672
|
-
isAvatarGroup: true,
|
|
47673
|
-
selectionType: "checkbox",
|
|
47674
|
-
canUnselectLast: false,
|
|
47675
|
-
onChange: selected => {
|
|
47676
|
-
setSelectedPartners(prev => ({
|
|
47677
|
-
...prev,
|
|
47678
|
-
partners: selected,
|
|
47679
|
-
loading: false
|
|
47680
|
-
}));
|
|
47681
|
-
},
|
|
47682
|
-
dropDownWidth: 200,
|
|
47683
|
-
defaultSelected: (partners || []).map(p => p.id) || []
|
|
47684
|
-
}, partners?.length)
|
|
47685
|
-
})
|
|
47686
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
47687
|
-
className: "view-content",
|
|
47688
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Navigation, {
|
|
47689
|
-
mod: APP,
|
|
47690
|
-
data: data,
|
|
47691
|
-
match: match,
|
|
47692
|
-
form: form,
|
|
47693
|
-
group: group,
|
|
47694
|
-
subsection: subsection,
|
|
47695
|
-
search: search,
|
|
47696
|
-
goTo: push,
|
|
47697
|
-
getRedirectLink: getRedirectLink,
|
|
47698
|
-
generatePath: generatePath,
|
|
47699
|
-
params: params
|
|
47700
|
-
}), groupForm.template ? /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {}) : /*#__PURE__*/jsxRuntime.jsx(Content, {
|
|
47701
|
-
form: groupForm,
|
|
47702
|
-
data: data || {},
|
|
47703
|
-
groupConfig: groups || {},
|
|
47704
|
-
linkingData: (data || {}).linking || {},
|
|
47705
|
-
linkingForms: linkingForms || {},
|
|
47706
|
-
ajaxOptions: [],
|
|
47707
|
-
extraLinking: extraLinking,
|
|
47708
|
-
t: t,
|
|
47709
|
-
app: APP,
|
|
47710
|
-
ajaxForms: ajaxForms,
|
|
47711
|
-
language: user?.language,
|
|
47712
|
-
changeAjaxForms: changeAjaxForms,
|
|
47713
|
-
getApiBaseUrl: getApiBaseUrl,
|
|
47714
|
-
getAppHeader: getAppHeader,
|
|
47715
|
-
user: user
|
|
47716
|
-
})]
|
|
47717
|
-
})]
|
|
47718
|
-
}), openRecordsModal && /*#__PURE__*/jsxRuntime.jsx(Records, {
|
|
47719
|
-
open: openRecordsModal,
|
|
47720
|
-
onClose: () => setOpenRecordsModal(false),
|
|
47721
|
-
t: t,
|
|
47722
|
-
sourceOptions: [],
|
|
47723
|
-
versionOptions: [],
|
|
47724
|
-
id: params?.id,
|
|
47725
|
-
subject: namespace,
|
|
47726
|
-
onSubmit: values => {
|
|
47727
|
-
setSource(values?.source);
|
|
47728
|
-
setVersion(values?.version);
|
|
47729
|
-
}
|
|
47730
|
-
})]
|
|
47731
|
-
});
|
|
47732
|
-
};
|
|
47733
|
-
|
|
47734
45918
|
exports.ActivitiesTable = ActivitiesTable;
|
|
47735
45919
|
exports.DocumentsTable = DocumentsTable;
|
|
47736
45920
|
exports.EventsTable = EventsTable;
|
|
@@ -47748,5 +45932,4 @@ exports.SupplyChainDashboard = SupplyChain;
|
|
|
47748
45932
|
exports.TablePage = TablePage;
|
|
47749
45933
|
exports.UserDashboard = UserDashboard;
|
|
47750
45934
|
exports.UsersTable = UsersTable;
|
|
47751
|
-
exports.View = View;
|
|
47752
45935
|
exports.WorkersTable = WorkersTable;
|