datastake-daf 0.6.781 → 0.6.783
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 +383 -317
- package/dist/pages/index.js +2577 -258
- package/dist/utils/index.js +13 -0
- package/package.json +1 -1
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +9 -76
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +116 -8
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/utils.js +73 -17
- package/src/@daf/core/components/Dashboard/Map/helper.js +1 -0
- package/src/@daf/core/components/Dashboard/Map/hook.js +64 -29
- package/src/@daf/core/components/Dashboard/Map/style.js +20 -5
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/index.jsx +1 -1
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/PlantingLocations/index.jsx +2 -2
- package/src/@daf/pages/Template/components/LinkingTemplate/columns.js +95 -0
- package/src/@daf/pages/Template/components/LinkingTemplate/config.js +75 -0
- package/src/@daf/pages/Template/components/LinkingTemplate/index.jsx +119 -0
- package/src/@daf/pages/Template/index.jsx +19 -0
- package/src/@daf/pages/View/hooks/useCallToGetData.js +73 -0
- package/src/@daf/pages/View/hooks/usePrepareForm.js +86 -0
- package/src/@daf/pages/View/hooks/useSubmitSubject.js +40 -0
- package/src/@daf/pages/View/hooks/useViewActions.js +83 -0
- package/src/@daf/pages/View/hooks/useViewPermissions.js +74 -0
- package/src/@daf/pages/View/hooks/useViewUrlParams.js +93 -0
- package/src/@daf/pages/View/index.jsx +325 -0
- package/src/@daf/utils/object.js +3 -1
- package/src/pages.js +4 -1
- package/src/utils.js +1 -1
- package/dist/style/datastake/mapbox-gl.css +0 -330
- package/src/@daf/hooks/useViewFormUrlParams.js +0 -84
package/dist/components/index.js
CHANGED
|
@@ -8486,20 +8486,22 @@ const useHeader = _ref => {
|
|
|
8486
8486
|
const {
|
|
8487
8487
|
useToken: useToken$m
|
|
8488
8488
|
} = antd.theme;
|
|
8489
|
-
function BreadCrumbs({
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8489
|
+
function BreadCrumbs(_ref) {
|
|
8490
|
+
let {
|
|
8491
|
+
breadcrumbs = [],
|
|
8492
|
+
mainContWidth = 0
|
|
8493
|
+
} = _ref;
|
|
8493
8494
|
const [splitIndex, setSplitIndex] = React.useState(0);
|
|
8494
8495
|
const {
|
|
8495
8496
|
token
|
|
8496
8497
|
} = useToken$m();
|
|
8497
|
-
const _renderBreadcrumb = (b, i, isLast
|
|
8498
|
+
const _renderBreadcrumb = function (b, i, isLast) {
|
|
8499
|
+
let noOnClickLast = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
8498
8500
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
8499
8501
|
className: "flex breadcrumb-item",
|
|
8500
|
-
onClick: noOnClickLast && isLast ? undefined : b
|
|
8502
|
+
onClick: noOnClickLast && isLast ? undefined : b === null || b === void 0 ? void 0 : b.onClick,
|
|
8501
8503
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
8502
|
-
children: b
|
|
8504
|
+
children: b === null || b === void 0 ? void 0 : b.label
|
|
8503
8505
|
}), !isLast && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
8504
8506
|
className: "flex flex-column justify-content-center",
|
|
8505
8507
|
children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
|
|
@@ -8509,7 +8511,7 @@ function BreadCrumbs({
|
|
|
8509
8511
|
color: token.baseGray50
|
|
8510
8512
|
})
|
|
8511
8513
|
})]
|
|
8512
|
-
},
|
|
8514
|
+
}, "breadcrumb-item-".concat(i));
|
|
8513
8515
|
};
|
|
8514
8516
|
React.useEffect(() => {
|
|
8515
8517
|
const _placeholderCont = document.getElementById("header-breadcrumbs");
|
|
@@ -8552,7 +8554,7 @@ function BreadCrumbs({
|
|
|
8552
8554
|
placement: "bottomRight",
|
|
8553
8555
|
menu: {
|
|
8554
8556
|
items: groupedBreadCrumbs[2].map((it, i) => ({
|
|
8555
|
-
key:
|
|
8557
|
+
key: "items-".concat(i),
|
|
8556
8558
|
label: it.label,
|
|
8557
8559
|
onClick: it.onClick
|
|
8558
8560
|
}))
|
|
@@ -9544,24 +9546,29 @@ const processConditionalTableKeys = (tableKeys, item) => {
|
|
|
9544
9546
|
});
|
|
9545
9547
|
return processedKeys;
|
|
9546
9548
|
};
|
|
9547
|
-
const renderFieldData = (type, value, user, config
|
|
9549
|
+
const renderFieldData = function (type, value, user, config) {
|
|
9550
|
+
let getApiBaseUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : () => {};
|
|
9551
|
+
let getAppHeader = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : () => {};
|
|
9552
|
+
let app = arguments.length > 6 ? arguments[6] : undefined;
|
|
9553
|
+
let allValues = arguments.length > 7 ? arguments[7] : undefined;
|
|
9554
|
+
let formValues = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : {};
|
|
9548
9555
|
switch (type) {
|
|
9549
9556
|
case 'year':
|
|
9550
9557
|
return value !== '-' ? renderDateFormatted(value, 'YYYY', 'en') : '-';
|
|
9551
9558
|
case 'date':
|
|
9552
9559
|
{
|
|
9553
|
-
const language = user
|
|
9560
|
+
const language = user !== null && user !== void 0 && user.language && (user === null || user === void 0 ? void 0 : user.language) === 'sp' ? 'es' : user === null || user === void 0 ? void 0 : user.language;
|
|
9554
9561
|
return value !== '-' ? renderDateFormatted(value, 'DD MMM YYYY', language || 'en') : '-';
|
|
9555
9562
|
}
|
|
9556
9563
|
case 'select':
|
|
9557
9564
|
{
|
|
9558
|
-
const options = config
|
|
9565
|
+
const options = (config === null || config === void 0 ? void 0 : config.options) || [];
|
|
9559
9566
|
const option = findOptions(value, options);
|
|
9560
9567
|
return option;
|
|
9561
9568
|
}
|
|
9562
9569
|
case 'multiselect':
|
|
9563
9570
|
{
|
|
9564
|
-
const options = config
|
|
9571
|
+
const options = (config === null || config === void 0 ? void 0 : config.options) || [];
|
|
9565
9572
|
const _val = typeof value === 'string' ? value.split(',').map(v => v.trim()) : value;
|
|
9566
9573
|
const option = findOptions(_val, options);
|
|
9567
9574
|
return option.join(', ');
|
|
@@ -9576,7 +9583,7 @@ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, ge
|
|
|
9576
9583
|
formValues: formValues
|
|
9577
9584
|
});
|
|
9578
9585
|
case 'percentage':
|
|
9579
|
-
return value === '-' || value === null || value === undefined ? '-' :
|
|
9586
|
+
return value === '-' || value === null || value === undefined ? '-' : "".concat(value, " %");
|
|
9580
9587
|
case 'geolocation':
|
|
9581
9588
|
{
|
|
9582
9589
|
const val = JSON.parse(value) || {};
|
|
@@ -9590,7 +9597,7 @@ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, ge
|
|
|
9590
9597
|
case 'upload':
|
|
9591
9598
|
case 'videoUpload':
|
|
9592
9599
|
{
|
|
9593
|
-
const documentName = allValues
|
|
9600
|
+
const documentName = allValues === null || allValues === void 0 ? void 0 : allValues.map(item => item === null || item === void 0 ? void 0 : item.name).join(', ');
|
|
9594
9601
|
return documentName;
|
|
9595
9602
|
}
|
|
9596
9603
|
default:
|
|
@@ -9598,25 +9605,27 @@ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, ge
|
|
|
9598
9605
|
}
|
|
9599
9606
|
};
|
|
9600
9607
|
|
|
9601
|
-
const renderValue =
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9608
|
+
const renderValue = _ref => {
|
|
9609
|
+
let {
|
|
9610
|
+
value,
|
|
9611
|
+
hasChildren,
|
|
9612
|
+
config,
|
|
9613
|
+
user,
|
|
9614
|
+
getApiBaseUrl = () => {},
|
|
9615
|
+
getAppHeader = () => {},
|
|
9616
|
+
app,
|
|
9617
|
+
allData = {}
|
|
9618
|
+
} = _ref;
|
|
9619
|
+
if ((config === null || config === void 0 ? void 0 : config.type) === 'groupInputs') {
|
|
9620
|
+
if (!(config !== null && config !== void 0 && config.inputs)) return null;
|
|
9613
9621
|
const inputKeys = Object.keys(config.inputs).sort((a, b) => {
|
|
9614
|
-
|
|
9615
|
-
const
|
|
9622
|
+
var _config$inputs$a, _config$inputs$b;
|
|
9623
|
+
const positionA = ((_config$inputs$a = config.inputs[a]) === null || _config$inputs$a === void 0 ? void 0 : _config$inputs$a.position) || 0;
|
|
9624
|
+
const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
|
|
9616
9625
|
return positionA - positionB;
|
|
9617
9626
|
});
|
|
9618
9627
|
const values = inputKeys.map(inputKey => {
|
|
9619
|
-
let inputValue = value
|
|
9628
|
+
let inputValue = value === null || value === void 0 ? void 0 : value[inputKey];
|
|
9620
9629
|
if (inputValue === null || inputValue === undefined || inputValue === '') {
|
|
9621
9630
|
return '';
|
|
9622
9631
|
} else if (typeof inputValue === 'object' && inputValue !== null) {
|
|
@@ -9657,8 +9666,8 @@ const renderValue = ({
|
|
|
9657
9666
|
} else {
|
|
9658
9667
|
displayValue = String(value);
|
|
9659
9668
|
}
|
|
9660
|
-
const fieldType = config
|
|
9661
|
-
let cssClass =
|
|
9669
|
+
const fieldType = (config === null || config === void 0 ? void 0 : config.type) || 'text';
|
|
9670
|
+
let cssClass = "tree-value ".concat(fieldType, "-type");
|
|
9662
9671
|
if (displayValue === '-') {
|
|
9663
9672
|
cssClass += ' empty';
|
|
9664
9673
|
}
|
|
@@ -9668,19 +9677,21 @@ const renderValue = ({
|
|
|
9668
9677
|
children: displayValue
|
|
9669
9678
|
});
|
|
9670
9679
|
};
|
|
9671
|
-
const determineHasChildren =
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9680
|
+
const determineHasChildren = _ref2 => {
|
|
9681
|
+
var _config$meta;
|
|
9682
|
+
let {
|
|
9683
|
+
config,
|
|
9684
|
+
level
|
|
9685
|
+
} = _ref2;
|
|
9686
|
+
if ((config === null || config === void 0 ? void 0 : config.type) === 'groupInputs') {
|
|
9676
9687
|
return false;
|
|
9677
9688
|
}
|
|
9678
|
-
if (config
|
|
9689
|
+
if ((config === null || config === void 0 ? void 0 : config.type) === 'header' && config !== null && config !== void 0 && config.inputs && Object.keys(config.inputs).length > 0) {
|
|
9679
9690
|
return true;
|
|
9680
9691
|
}
|
|
9681
|
-
return config
|
|
9692
|
+
return (config === null || config === void 0 ? void 0 : config.inputs) || (config === null || config === void 0 ? void 0 : config.type) === 'group' || (config === null || config === void 0 ? void 0 : config.type) === 'dataLinkGroup' || (config === null || config === void 0 ? void 0 : config.type) === 'section' || (config === null || config === void 0 ? void 0 : config.type) === 'ajaxSubGroup' ||
|
|
9682
9693
|
// Add this line
|
|
9683
|
-
config
|
|
9694
|
+
(config === null || config === void 0 ? void 0 : config.type) === 'dataLink' && (config === null || config === void 0 || (_config$meta = config.meta) === null || _config$meta === void 0 ? void 0 : _config$meta.tableKeys) || level === 0 && config && typeof config === 'object' && Object.keys(config).some(key => key !== 'id' && key !== 'label' && key !== 'position' && key !== 'subTitle' && typeof config[key] === 'object' && config[key] !== null);
|
|
9684
9695
|
};
|
|
9685
9696
|
|
|
9686
9697
|
const sortByPosition = (items, getConfig) => {
|
|
@@ -9714,19 +9725,18 @@ const resolveDynamicLabel = (labelConfig, item, defaultLabel) => {
|
|
|
9714
9725
|
return labelConfig || defaultLabel;
|
|
9715
9726
|
};
|
|
9716
9727
|
|
|
9717
|
-
const handleSectionChildren =
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
} = _ref;
|
|
9728
|
+
const handleSectionChildren = ({
|
|
9729
|
+
config,
|
|
9730
|
+
allData,
|
|
9731
|
+
level,
|
|
9732
|
+
t,
|
|
9733
|
+
rootForm,
|
|
9734
|
+
user,
|
|
9735
|
+
getApiBaseUrl = () => {},
|
|
9736
|
+
getAppHeader = () => {},
|
|
9737
|
+
app,
|
|
9738
|
+
TreeNodeComponent
|
|
9739
|
+
}) => {
|
|
9730
9740
|
if (!(level === 0 && config && typeof config === 'object')) {
|
|
9731
9741
|
return null;
|
|
9732
9742
|
}
|
|
@@ -9740,14 +9750,14 @@ const handleSectionChildren = _ref => {
|
|
|
9740
9750
|
let fieldValue;
|
|
9741
9751
|
|
|
9742
9752
|
// Determine field value based on type
|
|
9743
|
-
if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData
|
|
9753
|
+
if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData?.[fieldKey])) {
|
|
9744
9754
|
fieldValue = allData[fieldKey];
|
|
9745
|
-
} else if (fieldConfig.type === 'dataLinkGroup' && allData
|
|
9755
|
+
} else if (fieldConfig.type === 'dataLinkGroup' && allData?.[fieldKey]) {
|
|
9746
9756
|
fieldValue = allData[fieldKey];
|
|
9747
9757
|
} else if (fieldConfig.type === 'group') {
|
|
9748
9758
|
fieldValue = {};
|
|
9749
9759
|
} else {
|
|
9750
|
-
fieldValue = allData
|
|
9760
|
+
fieldValue = allData?.[fieldKey];
|
|
9751
9761
|
}
|
|
9752
9762
|
return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
|
|
9753
9763
|
nodeKey: fieldKey,
|
|
@@ -9766,30 +9776,28 @@ const handleSectionChildren = _ref => {
|
|
|
9766
9776
|
});
|
|
9767
9777
|
};
|
|
9768
9778
|
|
|
9769
|
-
const handleArrayChildren =
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
} = _ref;
|
|
9779
|
+
const handleArrayChildren = ({
|
|
9780
|
+
value,
|
|
9781
|
+
config,
|
|
9782
|
+
label,
|
|
9783
|
+
level,
|
|
9784
|
+
t,
|
|
9785
|
+
rootForm,
|
|
9786
|
+
allData,
|
|
9787
|
+
user,
|
|
9788
|
+
getApiBaseUrl = () => {},
|
|
9789
|
+
getAppHeader = () => {},
|
|
9790
|
+
app,
|
|
9791
|
+
TreeNodeComponent
|
|
9792
|
+
}) => {
|
|
9784
9793
|
if (!Array.isArray(value)) {
|
|
9785
9794
|
return null;
|
|
9786
9795
|
}
|
|
9787
9796
|
return value.map((item, itemIndex) => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
9788
9797
|
className: "array-item",
|
|
9789
9798
|
children: Object.keys(config.inputs).sort((a, b) => {
|
|
9790
|
-
|
|
9791
|
-
const
|
|
9792
|
-
const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
|
|
9799
|
+
const positionA = config.inputs[a]?.position || 0;
|
|
9800
|
+
const positionB = config.inputs[b]?.position || 0;
|
|
9793
9801
|
return positionA - positionB;
|
|
9794
9802
|
}).map(subInputKey => {
|
|
9795
9803
|
const subInputConfig = config.inputs[subInputKey];
|
|
@@ -9807,9 +9815,9 @@ const handleArrayChildren = _ref => {
|
|
|
9807
9815
|
getApiBaseUrl: getApiBaseUrl,
|
|
9808
9816
|
getAppHeader: getAppHeader,
|
|
9809
9817
|
app: app
|
|
9810
|
-
},
|
|
9818
|
+
}, `${itemIndex}-${subInputKey}`);
|
|
9811
9819
|
})
|
|
9812
|
-
},
|
|
9820
|
+
}, `${itemIndex}`));
|
|
9813
9821
|
};
|
|
9814
9822
|
|
|
9815
9823
|
const noDafApps = ['tif', 'cukura']; //PACKAGE_CHANGE_LATER (remove sbg)
|
|
@@ -10346,21 +10354,20 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10346
10354
|
}
|
|
10347
10355
|
};
|
|
10348
10356
|
|
|
10349
|
-
const handleGroupChildren =
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
if (!(config !== null && config !== void 0 && config.inputs)) {
|
|
10357
|
+
const handleGroupChildren = ({
|
|
10358
|
+
config,
|
|
10359
|
+
value,
|
|
10360
|
+
allData,
|
|
10361
|
+
level,
|
|
10362
|
+
t,
|
|
10363
|
+
rootForm,
|
|
10364
|
+
user,
|
|
10365
|
+
getApiBaseUrl = () => {},
|
|
10366
|
+
getAppHeader = () => {},
|
|
10367
|
+
app,
|
|
10368
|
+
TreeNodeComponent
|
|
10369
|
+
}) => {
|
|
10370
|
+
if (!config?.inputs) {
|
|
10364
10371
|
return null;
|
|
10365
10372
|
}
|
|
10366
10373
|
const inputKeys = Object.keys(config.inputs);
|
|
@@ -10373,7 +10380,7 @@ const handleGroupChildren = _ref => {
|
|
|
10373
10380
|
if (value && typeof value === 'object' && value[inputKey]) {
|
|
10374
10381
|
inputValue = value[inputKey];
|
|
10375
10382
|
} else {
|
|
10376
|
-
inputValue = allData
|
|
10383
|
+
inputValue = allData?.[inputKey];
|
|
10377
10384
|
}
|
|
10378
10385
|
return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
|
|
10379
10386
|
nodeKey: inputKey,
|
|
@@ -12463,6 +12470,8 @@ const Style$M = styled__default["default"].div`
|
|
|
12463
12470
|
width: 100%;
|
|
12464
12471
|
height: 472px;
|
|
12465
12472
|
|
|
12473
|
+
|
|
12474
|
+
|
|
12466
12475
|
.filter-cont {
|
|
12467
12476
|
position: absolute;
|
|
12468
12477
|
top: 24px;
|
|
@@ -12565,11 +12574,24 @@ const Style$M = styled__default["default"].div`
|
|
|
12565
12574
|
align-items: center;
|
|
12566
12575
|
}
|
|
12567
12576
|
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12571
|
-
|
|
12572
|
-
|
|
12577
|
+
.marker-chain {
|
|
12578
|
+
display: flex;
|
|
12579
|
+
align-items: center;
|
|
12580
|
+
justify-content: center;
|
|
12581
|
+
}
|
|
12582
|
+
|
|
12583
|
+
.animated-polyline {
|
|
12584
|
+
stroke-dasharray: 10 10;
|
|
12585
|
+
animation: dash-flow 1.5s linear infinite;
|
|
12586
|
+
stroke-linecap: round;
|
|
12587
|
+
}
|
|
12588
|
+
|
|
12589
|
+
@keyframes dash-flow {
|
|
12590
|
+
to {
|
|
12591
|
+
stroke-dashoffset: -20;
|
|
12592
|
+
}
|
|
12593
|
+
}
|
|
12594
|
+
|
|
12573
12595
|
|
|
12574
12596
|
}
|
|
12575
12597
|
|
|
@@ -13015,18 +13037,15 @@ const VILLAGE = "village";
|
|
|
13015
13037
|
const EXPORTER = "exporter";
|
|
13016
13038
|
const PROCESSOR = "mineralProcessor";
|
|
13017
13039
|
const DEPOT = "depot";
|
|
13040
|
+
const OPERATOR = "miningOperator";
|
|
13018
13041
|
const MAX_EXTRA_SMALL_ZOOM_THRESHOLD = 2;
|
|
13019
13042
|
const MAX_SMALL_ZOOM_THRESHOLD = 3;
|
|
13020
13043
|
const MAX_MEDIUM_ZOOM_THRESHOLD = 6;
|
|
13021
13044
|
const LOCATION_TYPES = [MINE_SITE, VILLAGE];
|
|
13022
|
-
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT];
|
|
13045
|
+
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT, OPERATOR];
|
|
13023
13046
|
const RADIUS_SMALL = 15;
|
|
13024
13047
|
const RADIUS_MEDIUM = 35;
|
|
13025
13048
|
const RADIUS_LARGE = 60;
|
|
13026
|
-
const RADIUS_CURVE_SMALL = 10;
|
|
13027
|
-
const RADIUS_CURVE_MEDIUM = 15;
|
|
13028
|
-
const RADIUS_CURVE_LARGE = 20;
|
|
13029
|
-
const TENSION = 0.2;
|
|
13030
13049
|
function isLocation(type) {
|
|
13031
13050
|
return LOCATION_TYPES.includes(type);
|
|
13032
13051
|
}
|
|
@@ -13083,7 +13102,6 @@ function getStakeholderPosition({
|
|
|
13083
13102
|
const isLarge = isLargeMarker(zoom);
|
|
13084
13103
|
let radius;
|
|
13085
13104
|
let center = {
|
|
13086
|
-
// NOT BEING USED FOR NOW AND MAYBE NEVER
|
|
13087
13105
|
left: 0,
|
|
13088
13106
|
top: 0
|
|
13089
13107
|
};
|
|
@@ -13107,6 +13125,25 @@ function getStakeholderPosition({
|
|
|
13107
13125
|
angleDeg
|
|
13108
13126
|
};
|
|
13109
13127
|
}
|
|
13128
|
+
function applyAnimationDirect(el, isShortLink) {
|
|
13129
|
+
if (!(el instanceof SVGElement) || isShortLink) return;
|
|
13130
|
+
el.style.strokeDasharray = "10, 10";
|
|
13131
|
+
el.style.strokeDashoffset = "0";
|
|
13132
|
+
el.style.animation = "dash-flow 1.2s linear infinite";
|
|
13133
|
+
el.classList.add('animated-polyline');
|
|
13134
|
+
}
|
|
13135
|
+
function removeAnimationFromElement(element) {
|
|
13136
|
+
if (!element) return;
|
|
13137
|
+
element.classList.remove('animated-polyline');
|
|
13138
|
+
element.style.animation = '';
|
|
13139
|
+
element.style.strokeDasharray = '';
|
|
13140
|
+
}
|
|
13141
|
+
function applyAnimationToPolyline(polyline, isShortLink) {
|
|
13142
|
+
const element = polyline.getElement();
|
|
13143
|
+
if (element) {
|
|
13144
|
+
applyAnimationDirect(element, isShortLink);
|
|
13145
|
+
}
|
|
13146
|
+
}
|
|
13110
13147
|
function createPolyline({
|
|
13111
13148
|
L,
|
|
13112
13149
|
startLatLng,
|
|
@@ -13116,109 +13153,47 @@ function createPolyline({
|
|
|
13116
13153
|
zoom,
|
|
13117
13154
|
listOfPolylines = [],
|
|
13118
13155
|
isFromStakeholder = false,
|
|
13119
|
-
isForceOpen = false
|
|
13156
|
+
isForceOpen = false,
|
|
13157
|
+
stakeholderType = null,
|
|
13158
|
+
animated = false,
|
|
13159
|
+
mapRef
|
|
13120
13160
|
}) {
|
|
13121
|
-
const
|
|
13122
|
-
const
|
|
13123
|
-
const
|
|
13161
|
+
const lineWidth = isFromStakeholder && isExtraSmallMarker(zoom) && !isForceOpen ? 0 : 1.2;
|
|
13162
|
+
const isShortLink = stakeholderType === OPERATOR || isFromStakeholder;
|
|
13163
|
+
const shouldAnimate = animated;
|
|
13164
|
+
const lineCoordinates = [[startLatLng.lat, startLatLng.lng], [endLatLng.lat, endLatLng.lng]];
|
|
13165
|
+
const polylineStyle = {
|
|
13124
13166
|
color: "var(--base-gray-70)",
|
|
13125
|
-
weight:
|
|
13126
|
-
opacity: 0.5,
|
|
13127
|
-
smoothFactor:
|
|
13167
|
+
weight: lineWidth,
|
|
13168
|
+
opacity: isSelected ? 1 : 0.5,
|
|
13169
|
+
smoothFactor: 0,
|
|
13128
13170
|
id,
|
|
13129
|
-
dashArray: !isSelected ? "5, 5" : "
|
|
13171
|
+
dashArray: isShortLink ? "0, 0" : shouldAnimate ? "10, 10" : !isSelected ? "5, 5" : "10, 10",
|
|
13172
|
+
renderer: L.svg()
|
|
13130
13173
|
};
|
|
13131
|
-
const
|
|
13132
|
-
if (
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
function createCurvePath({
|
|
13142
|
-
zoom,
|
|
13143
|
-
totalMarkers,
|
|
13144
|
-
markerIndex
|
|
13145
|
-
}) {
|
|
13146
|
-
const radius = getCurvePointRadius(zoom);
|
|
13147
|
-
const {
|
|
13148
|
-
x,
|
|
13149
|
-
y,
|
|
13150
|
-
angleDeg
|
|
13151
|
-
} = getAngleDeg(totalMarkers, markerIndex, radius);
|
|
13152
|
-
return {
|
|
13153
|
-
x,
|
|
13154
|
-
y,
|
|
13155
|
-
angleDeg
|
|
13156
|
-
};
|
|
13157
|
-
}
|
|
13158
|
-
function getCurvePointRadius(zoom) {
|
|
13159
|
-
const isSmall = isSmallMarker(zoom) || isExtraSmallMarker(zoom);
|
|
13160
|
-
const isMedium = isMediumMarker(zoom);
|
|
13161
|
-
if (isSmall) {
|
|
13162
|
-
return RADIUS_SMALL + RADIUS_CURVE_SMALL;
|
|
13163
|
-
} else if (isMedium) {
|
|
13164
|
-
return RADIUS_MEDIUM + RADIUS_CURVE_MEDIUM;
|
|
13165
|
-
} else {
|
|
13166
|
-
return RADIUS_LARGE + RADIUS_CURVE_LARGE;
|
|
13167
|
-
}
|
|
13168
|
-
}
|
|
13169
|
-
function buildSmoothCurve(layerPoints, mapRef) {
|
|
13170
|
-
const path = [];
|
|
13171
|
-
for (let i = 0; i < layerPoints.length - 1; i++) {
|
|
13172
|
-
const p0 = layerPoints[i];
|
|
13173
|
-
const p1 = layerPoints[i + 1];
|
|
13174
|
-
const pPrev = layerPoints[i - 1] || p0;
|
|
13175
|
-
const pNext = layerPoints[i + 2] || p1;
|
|
13176
|
-
const cp1 = L__namespace.point(p0.x + (p1.x - pPrev.x) * TENSION, p0.y + (p1.y - pPrev.y) * TENSION);
|
|
13177
|
-
const cp2 = L__namespace.point(p1.x - (pNext.x - p0.x) * TENSION, p1.y - (pNext.y - p0.y) * TENSION);
|
|
13178
|
-
if (i === 0) {
|
|
13179
|
-
path.push("M", [mapRef.layerPointToLatLng(p0).lat, mapRef.layerPointToLatLng(p0).lng]);
|
|
13174
|
+
const existingPolyline = listOfPolylines.find(p => p.options.id === id);
|
|
13175
|
+
if (existingPolyline) {
|
|
13176
|
+
removeAnimationFromElement(existingPolyline.getElement());
|
|
13177
|
+
existingPolyline.setLatLngs(lineCoordinates);
|
|
13178
|
+
existingPolyline.setStyle(polylineStyle);
|
|
13179
|
+
if (shouldAnimate && isSelected) {
|
|
13180
|
+
existingPolyline.once('add', () => {
|
|
13181
|
+
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
13182
|
+
});
|
|
13183
|
+
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
13180
13184
|
}
|
|
13181
|
-
|
|
13185
|
+
return existingPolyline;
|
|
13182
13186
|
}
|
|
13183
|
-
|
|
13184
|
-
|
|
13185
|
-
|
|
13186
|
-
if (
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
startLatLng,
|
|
13194
|
-
endLatLng,
|
|
13195
|
-
zoom,
|
|
13196
|
-
isSelected,
|
|
13197
|
-
id
|
|
13198
|
-
}) {
|
|
13199
|
-
const fromPoint = mapRef.latLngToLayerPoint(startLatLng);
|
|
13200
|
-
const toPoint = mapRef.latLngToLayerPoint(endLatLng);
|
|
13201
|
-
const midX = (fromPoint.x + toPoint.x) / 2;
|
|
13202
|
-
const midY = (fromPoint.y + toPoint.y) / 2 + (isSmallMarker(zoom) ? RADIUS_CURVE_SMALL / 2 : 0);
|
|
13203
|
-
const dx = toPoint.x - fromPoint.x;
|
|
13204
|
-
const dy = toPoint.y - fromPoint.y;
|
|
13205
|
-
const normal = L__namespace.point(-dy, dx);
|
|
13206
|
-
const length = Math.sqrt(normal.x ** 2 + normal.y ** 2) || 1;
|
|
13207
|
-
const normalized = normal.multiplyBy(1 / length);
|
|
13208
|
-
const curveStrength = getSiblingCurveStrength(zoom);
|
|
13209
|
-
const controlPoint = L__namespace.point(midX, midY).add(normalized.multiplyBy(curveStrength));
|
|
13210
|
-
const latlngs = [startLatLng, mapRef.layerPointToLatLng(controlPoint), endLatLng];
|
|
13211
|
-
const layerPoints = latlngs.map(latlng => mapRef.latLngToLayerPoint(latlng));
|
|
13212
|
-
const path = buildSmoothCurve(layerPoints, mapRef);
|
|
13213
|
-
const curve = L__namespace.curve(path, {
|
|
13214
|
-
color: "var(--base-gray-70)",
|
|
13215
|
-
weight: isExtraSmallMarker(zoom) ? 0 : 1.2,
|
|
13216
|
-
opacity: 0.5,
|
|
13217
|
-
smoothFactor: 1,
|
|
13218
|
-
id,
|
|
13219
|
-
dashArray: !isSelected ? "5, 5" : "0, 0"
|
|
13220
|
-
});
|
|
13221
|
-
mapRef.addLayer(curve);
|
|
13187
|
+
const newPolyline = L.polyline(lineCoordinates, polylineStyle);
|
|
13188
|
+
newPolyline.addTo(mapRef);
|
|
13189
|
+
listOfPolylines.push(newPolyline);
|
|
13190
|
+
if (shouldAnimate && isSelected) {
|
|
13191
|
+
newPolyline.once('add', () => {
|
|
13192
|
+
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
13193
|
+
});
|
|
13194
|
+
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
13195
|
+
}
|
|
13196
|
+
return newPolyline;
|
|
13222
13197
|
}
|
|
13223
13198
|
|
|
13224
13199
|
const StakeholderMarker = styled__default["default"].div`
|
|
@@ -13520,6 +13495,9 @@ function StakeholderIcon$1({
|
|
|
13520
13495
|
return null;
|
|
13521
13496
|
}, [parentId, allData]);
|
|
13522
13497
|
React.useEffect(() => {
|
|
13498
|
+
if (selectedMarkersId.length === 0 || !isSelected) {
|
|
13499
|
+
return;
|
|
13500
|
+
}
|
|
13523
13501
|
linkNodesData.map(node => {
|
|
13524
13502
|
const isConnectingToStakeholder = node.isStakeholder;
|
|
13525
13503
|
const id = `${data.datastakeId}-${node.stakeholderId || node.datastakeId}`;
|
|
@@ -13531,8 +13509,6 @@ function StakeholderIcon$1({
|
|
|
13531
13509
|
const stakeholderPoint = centerPoint.add(L__namespace.point(x, y));
|
|
13532
13510
|
const stakeholderLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
|
|
13533
13511
|
let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
13534
|
-
const areNextToEachOther = targetMarkerIndex === index + 1 || targetMarkerIndex === index - 1 || index === 0 && targetMarkerIndex === node.totalStakeholders - 1 || targetMarkerIndex === 0 && index === node.totalStakeholders - 1;
|
|
13535
|
-
const areOnlyTwoSiblings = node.totalStakeholders === 2;
|
|
13536
13512
|
if (isExtraSmallMarker(zoom) && !isForceOpen) {
|
|
13537
13513
|
createPolyline({
|
|
13538
13514
|
L: L__namespace,
|
|
@@ -13542,7 +13518,8 @@ function StakeholderIcon$1({
|
|
|
13542
13518
|
zoom,
|
|
13543
13519
|
isSelected,
|
|
13544
13520
|
id,
|
|
13545
|
-
listOfPolylines: polylinesRef.current
|
|
13521
|
+
listOfPolylines: polylinesRef.current,
|
|
13522
|
+
animated: true
|
|
13546
13523
|
});
|
|
13547
13524
|
return;
|
|
13548
13525
|
}
|
|
@@ -13560,61 +13537,8 @@ function StakeholderIcon$1({
|
|
|
13560
13537
|
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
13561
13538
|
const endPoint = L__namespace.point(x + nodePoint.x + center.left, y + nodePoint.y + center.top);
|
|
13562
13539
|
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
13563
|
-
if (isSibling && (!areNextToEachOther || areOnlyTwoSiblings)) {
|
|
13564
|
-
if (areOnlyTwoSiblings) {
|
|
13565
|
-
buildCurveWIthTwoSiblings({
|
|
13566
|
-
mapRef,
|
|
13567
|
-
startLatLng: stakeholderLatLng,
|
|
13568
|
-
endLatLng,
|
|
13569
|
-
zoom,
|
|
13570
|
-
isSelected,
|
|
13571
|
-
id
|
|
13572
|
-
});
|
|
13573
|
-
return;
|
|
13574
|
-
}
|
|
13575
|
-
const total = node.totalStakeholders;
|
|
13576
|
-
let from = index;
|
|
13577
|
-
let to = targetMarkerIndex;
|
|
13578
|
-
let flip = false;
|
|
13579
|
-
const forwardDistance = (to - from + total) % total;
|
|
13580
|
-
const backwardDistance = (from - to + total) % total;
|
|
13581
|
-
if (backwardDistance < forwardDistance) {
|
|
13582
|
-
[from, to] = [to, from];
|
|
13583
|
-
flip = true;
|
|
13584
|
-
}
|
|
13585
|
-
const intermediateIndices = [];
|
|
13586
|
-
for (let i = 1; i < (to - from + total) % total; i++) {
|
|
13587
|
-
intermediateIndices.push((from + i) % total);
|
|
13588
|
-
}
|
|
13589
|
-
const indices = [from, ...intermediateIndices, to];
|
|
13590
|
-
const intermediatePoints = [];
|
|
13591
|
-
for (const i of indices) {
|
|
13592
|
-
const {
|
|
13593
|
-
x,
|
|
13594
|
-
y
|
|
13595
|
-
} = createCurvePath({
|
|
13596
|
-
zoom,
|
|
13597
|
-
totalMarkers: node.totalStakeholders,
|
|
13598
|
-
markerIndex: i
|
|
13599
|
-
});
|
|
13600
|
-
const point = centerPoint.add(L__namespace.point(x, y));
|
|
13601
|
-
const latlng = mapRef.layerPointToLatLng(point);
|
|
13602
|
-
intermediatePoints.push(latlng);
|
|
13603
|
-
}
|
|
13604
|
-
const latlngs = flip ? [endLatLng, ...intermediatePoints, stakeholderLatLng] : [stakeholderLatLng, ...intermediatePoints, endLatLng];
|
|
13605
|
-
const layerPoints = latlngs.map(latlng => mapRef.latLngToLayerPoint(latlng));
|
|
13606
|
-
const path = buildSmoothCurve(layerPoints, mapRef);
|
|
13607
|
-
const curve = L__namespace?.curve?.(path, {
|
|
13608
|
-
color: "var(--base-gray-70)",
|
|
13609
|
-
weight: isExtraSmallMarker(zoom) ? 0 : 1,
|
|
13610
|
-
opacity: isSelected ? 1 : 0.5,
|
|
13611
|
-
smoothFactor: 1,
|
|
13612
|
-
id
|
|
13613
|
-
});
|
|
13614
|
-
mapRef.addLayer(curve);
|
|
13615
|
-
return;
|
|
13616
|
-
}
|
|
13617
13540
|
}
|
|
13541
|
+
// Always use straight lines
|
|
13618
13542
|
createPolyline({
|
|
13619
13543
|
L: L__namespace,
|
|
13620
13544
|
mapRef,
|
|
@@ -13624,10 +13548,11 @@ function StakeholderIcon$1({
|
|
|
13624
13548
|
isFromStakeholder: false,
|
|
13625
13549
|
isSelected,
|
|
13626
13550
|
id,
|
|
13627
|
-
listOfPolylines: polylinesRef.current
|
|
13551
|
+
listOfPolylines: polylinesRef.current,
|
|
13552
|
+
animated: true
|
|
13628
13553
|
});
|
|
13629
13554
|
});
|
|
13630
|
-
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen]);
|
|
13555
|
+
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen, selectedMarkersId]);
|
|
13631
13556
|
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
13632
13557
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
|
|
13633
13558
|
content: renderTooltipJsx({
|
|
@@ -13639,7 +13564,8 @@ function StakeholderIcon$1({
|
|
|
13639
13564
|
link,
|
|
13640
13565
|
onClickLink: () => {
|
|
13641
13566
|
onClickLink(data);
|
|
13642
|
-
}
|
|
13567
|
+
},
|
|
13568
|
+
isNewTab: true
|
|
13643
13569
|
}),
|
|
13644
13570
|
getPopupContainer: triggerNode => {
|
|
13645
13571
|
const mapElement = document.getElementById("map");
|
|
@@ -13694,6 +13620,8 @@ function LocationIcon({
|
|
|
13694
13620
|
const linkedNodesData = React.useMemo(() => {
|
|
13695
13621
|
const nodes = [];
|
|
13696
13622
|
const links = data.links || [];
|
|
13623
|
+
|
|
13624
|
+
// Add links from the location itself
|
|
13697
13625
|
links.forEach(link => {
|
|
13698
13626
|
allData.forEach(d => {
|
|
13699
13627
|
if (d.datastakeId === link) {
|
|
@@ -13713,8 +13641,45 @@ function LocationIcon({
|
|
|
13713
13641
|
}
|
|
13714
13642
|
});
|
|
13715
13643
|
});
|
|
13644
|
+
|
|
13645
|
+
// ADD: Also include links from this location's stakeholders
|
|
13646
|
+
const stakeholders = data.stakeholders || [];
|
|
13647
|
+
stakeholders.forEach(stakeholder => {
|
|
13648
|
+
const stakeholderLinks = stakeholder.links || [];
|
|
13649
|
+
stakeholderLinks.forEach(link => {
|
|
13650
|
+
allData.forEach(d => {
|
|
13651
|
+
// Check if it's a direct location link
|
|
13652
|
+
if (d.datastakeId === link) {
|
|
13653
|
+
// Avoid duplicates
|
|
13654
|
+
if (!nodes.find(n => n.datastakeId === link && !n.isStakeholder)) {
|
|
13655
|
+
nodes.push({
|
|
13656
|
+
...d,
|
|
13657
|
+
fromStakeholderId: stakeholder.datastakeId
|
|
13658
|
+
});
|
|
13659
|
+
}
|
|
13660
|
+
}
|
|
13661
|
+
// Check if it's a stakeholder link
|
|
13662
|
+
if (d.stakeholders && d.stakeholders.length > 0) {
|
|
13663
|
+
d.stakeholders.forEach(targetStakeholder => {
|
|
13664
|
+
if (targetStakeholder.datastakeId === link) {
|
|
13665
|
+
// Avoid duplicates
|
|
13666
|
+
if (!nodes.find(n => n.isStakeholder && n.datastakeId === d.datastakeId && n.stakeholdersIndex === d.stakeholders.indexOf(targetStakeholder))) {
|
|
13667
|
+
nodes.push({
|
|
13668
|
+
...d,
|
|
13669
|
+
isStakeholder: true,
|
|
13670
|
+
totalStakeholders: d.stakeholders.length,
|
|
13671
|
+
stakeholdersIndex: d.stakeholders.indexOf(targetStakeholder),
|
|
13672
|
+
fromStakeholderId: stakeholder.datastakeId
|
|
13673
|
+
});
|
|
13674
|
+
}
|
|
13675
|
+
}
|
|
13676
|
+
});
|
|
13677
|
+
}
|
|
13678
|
+
});
|
|
13679
|
+
});
|
|
13680
|
+
});
|
|
13716
13681
|
return nodes;
|
|
13717
|
-
}, [JSON.stringify(allData), JSON.stringify(data.links), zoom]);
|
|
13682
|
+
}, [JSON.stringify(allData), JSON.stringify(data.links), JSON.stringify(data.stakeholders), zoom]);
|
|
13718
13683
|
const stakeholdersOfLocation = React.useMemo(() => {
|
|
13719
13684
|
return data?.stakeholders || [];
|
|
13720
13685
|
}, [data.stakeholders, zoom]);
|
|
@@ -13732,7 +13697,13 @@ function LocationIcon({
|
|
|
13732
13697
|
currentRoots.clear();
|
|
13733
13698
|
markersRef.current = [];
|
|
13734
13699
|
|
|
13735
|
-
//
|
|
13700
|
+
// Only create stakeholder markers if this location or any of its stakeholders are selected
|
|
13701
|
+
const shouldShowStakeholders = isSelected || stakeholdersOfLocation.some(stk => selectedMarkersId.includes(stk.datastakeId));
|
|
13702
|
+
if (!shouldShowStakeholders || selectedMarkersId.length === 0) {
|
|
13703
|
+
return;
|
|
13704
|
+
}
|
|
13705
|
+
|
|
13706
|
+
// Create new markers only when selected
|
|
13736
13707
|
stakeholdersOfLocation.forEach((stakeholder, index) => {
|
|
13737
13708
|
const markerId = `${stakeholder.datastakeId}`;
|
|
13738
13709
|
const {
|
|
@@ -13818,7 +13789,9 @@ function LocationIcon({
|
|
|
13818
13789
|
zoom,
|
|
13819
13790
|
isFromStakeholder: true,
|
|
13820
13791
|
isForceOpen,
|
|
13821
|
-
listOfPolylines: polylinesRef.current
|
|
13792
|
+
listOfPolylines: polylinesRef.current,
|
|
13793
|
+
stakeholderType: stakeholder.type,
|
|
13794
|
+
animated: true
|
|
13822
13795
|
});
|
|
13823
13796
|
});
|
|
13824
13797
|
return () => {
|
|
@@ -13833,38 +13806,88 @@ function LocationIcon({
|
|
|
13833
13806
|
rootsMapRef.current.clear();
|
|
13834
13807
|
markersRef.current = [];
|
|
13835
13808
|
};
|
|
13836
|
-
}, [stakeholdersOfLocation, selectedMarkersId, activeMarker]);
|
|
13837
|
-
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
|
|
13843
|
-
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13809
|
+
}, [stakeholdersOfLocation, selectedMarkersId, activeMarker, zoom]);
|
|
13810
|
+
|
|
13811
|
+
// Only create polylines for linked nodes when something is selected
|
|
13812
|
+
React.useEffect(() => {
|
|
13813
|
+
if (selectedMarkersId.length === 0) {
|
|
13814
|
+
return;
|
|
13815
|
+
}
|
|
13816
|
+
|
|
13817
|
+
// IMPORTANT: Only draw links if this location is actually selected
|
|
13818
|
+
// Not just highlighted as part of the chain
|
|
13819
|
+
if (!isSelected) {
|
|
13820
|
+
return;
|
|
13821
|
+
}
|
|
13822
|
+
|
|
13823
|
+
// Filter linkedNodesData to only include nodes that are in the selected chain
|
|
13824
|
+
const relevantLinks = linkedNodesData.filter(node => {
|
|
13825
|
+
// Check if the target node (location) is in the selected markers
|
|
13826
|
+
const targetLocationInSelection = selectedMarkersId.includes(node.datastakeId);
|
|
13827
|
+
|
|
13828
|
+
// If connecting to a stakeholder, check if that stakeholder is selected
|
|
13829
|
+
if (node.isStakeholder) {
|
|
13830
|
+
const stakeholderInSelection = node.stakeholdersIndex !== undefined && selectedMarkersId.includes(node.datastakeId);
|
|
13831
|
+
return stakeholderInSelection;
|
|
13832
|
+
}
|
|
13833
|
+
return targetLocationInSelection;
|
|
13834
|
+
});
|
|
13835
|
+
relevantLinks.forEach(node => {
|
|
13836
|
+
const id = node.fromStakeholderId ? `${node.fromStakeholderId}-${node.datastakeId}` : `${data.datastakeId}-${node.datastakeId}`;
|
|
13837
|
+
const isConnectingToStakeholder = node.isStakeholder;
|
|
13838
|
+
|
|
13839
|
+
// If the link is from a stakeholder, start from the stakeholder position
|
|
13840
|
+
let startLatLng;
|
|
13841
|
+
if (node.fromStakeholderId) {
|
|
13842
|
+
// Find the stakeholder index in this location's stakeholders
|
|
13843
|
+
const stakeholderIndex = stakeholdersOfLocation.findIndex(s => s.datastakeId === node.fromStakeholderId);
|
|
13844
|
+
if (stakeholderIndex !== -1) {
|
|
13845
|
+
const {
|
|
13846
|
+
x,
|
|
13847
|
+
y
|
|
13848
|
+
} = getStakeholderPosition({
|
|
13849
|
+
zoom,
|
|
13850
|
+
totalMarkers: stakeholdersOfLocation.length,
|
|
13851
|
+
markerIndex: stakeholderIndex
|
|
13852
|
+
});
|
|
13853
|
+
const centerLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
13854
|
+
const centerPoint = mapRef.latLngToLayerPoint(centerLatLng);
|
|
13855
|
+
const stakeholderPoint = centerPoint.add(L__namespace.point(x, y));
|
|
13856
|
+
startLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
|
|
13857
|
+
} else {
|
|
13858
|
+
startLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
13859
|
+
}
|
|
13860
|
+
} else {
|
|
13861
|
+
startLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
13862
|
+
}
|
|
13863
|
+
let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
13864
|
+
const isConnectingToStakeholderSelected = selectedMarkersId.includes(node.datastakeId);
|
|
13865
|
+
if (isConnectingToStakeholder && !isExtraSmallMarker(zoom)) {
|
|
13866
|
+
const {
|
|
13867
|
+
x,
|
|
13868
|
+
y
|
|
13869
|
+
} = getStakeholderPosition({
|
|
13870
|
+
zoom,
|
|
13871
|
+
totalMarkers: node.totalStakeholders,
|
|
13872
|
+
markerIndex: node.stakeholdersIndex
|
|
13873
|
+
});
|
|
13874
|
+
const nodeLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
13875
|
+
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
13876
|
+
const endPoint = L__namespace.point(x + nodePoint.x, y + nodePoint.y);
|
|
13877
|
+
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
13878
|
+
}
|
|
13879
|
+
createPolyline({
|
|
13880
|
+
L: L__namespace,
|
|
13881
|
+
mapRef,
|
|
13882
|
+
startLatLng,
|
|
13883
|
+
endLatLng,
|
|
13884
|
+
isSelected: isConnectingToStakeholderSelected,
|
|
13885
|
+
id,
|
|
13848
13886
|
zoom,
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
});
|
|
13852
|
-
const nodeLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
13853
|
-
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
13854
|
-
const endPoint = L__namespace.point(x + nodePoint.x, y + nodePoint.y);
|
|
13855
|
-
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
13856
|
-
}
|
|
13857
|
-
createPolyline({
|
|
13858
|
-
L: L__namespace,
|
|
13859
|
-
mapRef,
|
|
13860
|
-
startLatLng: centerLatLng,
|
|
13861
|
-
endLatLng,
|
|
13862
|
-
isSelected: isConnectingToStakeholderSelected,
|
|
13863
|
-
id,
|
|
13864
|
-
zoom,
|
|
13865
|
-
listOfPolylines: polylinesRef.current
|
|
13887
|
+
listOfPolylines: polylinesRef.current
|
|
13888
|
+
});
|
|
13866
13889
|
});
|
|
13867
|
-
});
|
|
13890
|
+
}, [linkedNodesData, selectedMarkersId, zoom, stakeholdersOfLocation, isSelected]);
|
|
13868
13891
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
|
|
13869
13892
|
content: renderTooltipJsx({
|
|
13870
13893
|
title: data.name,
|
|
@@ -14380,7 +14403,8 @@ function useMapHelper$1({
|
|
|
14380
14403
|
link: link,
|
|
14381
14404
|
onClickLink: onClickLink,
|
|
14382
14405
|
activeStakeholder: activeStakeholder,
|
|
14383
|
-
setActiveStakeholder: setActiveStakeholder
|
|
14406
|
+
setActiveStakeholder: setActiveStakeholder,
|
|
14407
|
+
mapRef: mapRef
|
|
14384
14408
|
}));
|
|
14385
14409
|
roots.current.push(root);
|
|
14386
14410
|
} else if (type === "location") {
|
|
@@ -14585,7 +14609,8 @@ const useMap$1 = ({
|
|
|
14585
14609
|
MAP_TOKEN
|
|
14586
14610
|
} = useMapConfig({
|
|
14587
14611
|
app,
|
|
14588
|
-
isSatellite
|
|
14612
|
+
isSatellite,
|
|
14613
|
+
mapRef: container
|
|
14589
14614
|
});
|
|
14590
14615
|
const [initialMarkerSetIsDone, setInitialMarkerSetIsDone] = React.useState(false);
|
|
14591
14616
|
const [mapCenter, setMapCenter] = React.useState([0, 0]);
|
|
@@ -14602,6 +14627,8 @@ const useMap$1 = ({
|
|
|
14602
14627
|
const graph = new Map();
|
|
14603
14628
|
const stakeToLoc = new Map();
|
|
14604
14629
|
const nodeTypes = new Map();
|
|
14630
|
+
|
|
14631
|
+
// Build the graph
|
|
14605
14632
|
for (const loc of data) {
|
|
14606
14633
|
const locId = loc.datastakeId;
|
|
14607
14634
|
nodeTypes.set(locId, loc.type);
|
|
@@ -14626,26 +14653,45 @@ const useMap$1 = ({
|
|
|
14626
14653
|
}
|
|
14627
14654
|
}
|
|
14628
14655
|
const highlightTable = {};
|
|
14656
|
+
|
|
14657
|
+
// Perform BFS/DFS to find all connected nodes in the entire chain
|
|
14629
14658
|
for (const [node] of graph) {
|
|
14630
14659
|
const highlighted = new Set();
|
|
14631
|
-
|
|
14632
|
-
const
|
|
14633
|
-
|
|
14634
|
-
const
|
|
14635
|
-
highlighted.add(
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
const
|
|
14639
|
-
if (
|
|
14640
|
-
const
|
|
14641
|
-
if (
|
|
14642
|
-
highlighted.add(
|
|
14643
|
-
|
|
14660
|
+
const queue = [node];
|
|
14661
|
+
const visited = new Set([node]);
|
|
14662
|
+
while (queue.length > 0) {
|
|
14663
|
+
const current = queue.shift();
|
|
14664
|
+
highlighted.add(current);
|
|
14665
|
+
|
|
14666
|
+
// Add parent location if current is stakeholder
|
|
14667
|
+
const currentIsStakeholder = !isLocation(nodeTypes.get(current));
|
|
14668
|
+
if (currentIsStakeholder && stakeToLoc.has(current)) {
|
|
14669
|
+
const parentLoc = stakeToLoc.get(current);
|
|
14670
|
+
if (!visited.has(parentLoc)) {
|
|
14671
|
+
highlighted.add(parentLoc);
|
|
14672
|
+
visited.add(parentLoc);
|
|
14673
|
+
queue.push(parentLoc);
|
|
14674
|
+
}
|
|
14675
|
+
}
|
|
14676
|
+
|
|
14677
|
+
// Traverse all neighbors
|
|
14678
|
+
for (const neighbor of graph.get(current) || []) {
|
|
14679
|
+
if (!visited.has(neighbor)) {
|
|
14680
|
+
visited.add(neighbor);
|
|
14681
|
+
queue.push(neighbor);
|
|
14644
14682
|
highlighted.add(neighbor);
|
|
14645
|
-
|
|
14683
|
+
|
|
14684
|
+
// If neighbor is stakeholder, add its parent location
|
|
14685
|
+
const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
|
|
14686
|
+
if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
|
|
14687
|
+
const neighborParent = stakeToLoc.get(neighbor);
|
|
14688
|
+
if (!visited.has(neighborParent)) {
|
|
14689
|
+
highlighted.add(neighborParent);
|
|
14690
|
+
visited.add(neighborParent);
|
|
14691
|
+
queue.push(neighborParent);
|
|
14692
|
+
}
|
|
14693
|
+
}
|
|
14646
14694
|
}
|
|
14647
|
-
} else {
|
|
14648
|
-
highlighted.add(neighbor);
|
|
14649
14695
|
}
|
|
14650
14696
|
}
|
|
14651
14697
|
highlightTable[node] = [...highlighted];
|
|
@@ -14683,10 +14729,20 @@ const useMap$1 = ({
|
|
|
14683
14729
|
function handleSelectMarker(clickedMarker) {
|
|
14684
14730
|
setSelectedMarkersId(prev => {
|
|
14685
14731
|
if (prev.includes(clickedMarker.datastakeId)) {
|
|
14732
|
+
// Deselecting - clear polylines
|
|
14686
14733
|
openPopupIdRef.current = null;
|
|
14687
14734
|
setMarkerWithPopup(null);
|
|
14688
14735
|
return [];
|
|
14689
14736
|
} else {
|
|
14737
|
+
// CLEAR OLD POLYLINES BEFORE SELECTING NEW MARKER
|
|
14738
|
+
if (polylinesRef.current.length > 0) {
|
|
14739
|
+
polylinesRef.current.forEach(polyline => {
|
|
14740
|
+
if (mapRef.hasLayer(polyline)) {
|
|
14741
|
+
mapRef.removeLayer(polyline);
|
|
14742
|
+
}
|
|
14743
|
+
});
|
|
14744
|
+
polylinesRef.current = [];
|
|
14745
|
+
}
|
|
14690
14746
|
setMarkerWithPopup(isStakeholder(clickedMarker.type) ? clickedMarker : null);
|
|
14691
14747
|
const newSelectedMarkersId = highlightTable[clickedMarker.datastakeId];
|
|
14692
14748
|
openPopupIdRef.current = clickedMarker.datastakeId;
|
|
@@ -14710,19 +14766,29 @@ const useMap$1 = ({
|
|
|
14710
14766
|
});
|
|
14711
14767
|
}
|
|
14712
14768
|
}
|
|
14769
|
+
if (type === "chain" && selectedMarkersId.length === 0) {
|
|
14770
|
+
if (polylinesRef.current.length) {
|
|
14771
|
+
polylinesRef.current.forEach(polyline => {
|
|
14772
|
+
if (mapRef.hasLayer(polyline)) {
|
|
14773
|
+
mapRef.removeLayer(polyline);
|
|
14774
|
+
}
|
|
14775
|
+
});
|
|
14776
|
+
polylinesRef.current = [];
|
|
14777
|
+
}
|
|
14778
|
+
}
|
|
14713
14779
|
clearMapMarkers();
|
|
14714
14780
|
if (data) {
|
|
14715
|
-
|
|
14716
|
-
const excludedType = ['village', 'town', 'area', 'territory'];
|
|
14717
|
-
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)))));
|
|
14781
|
+
const filteredData = data?.filter(obj => obj.type === 'mineSite' || obj?.stakeholders?.length > 0 || data.some(other => other.datastakeId !== obj.datastakeId && (other.stakeholders || []).some(stk => (stk.links || []).includes(obj.datastakeId))));
|
|
14718
14782
|
const maxTotal = Math.max(...(data || []).map(d => d.total));
|
|
14719
14783
|
const dataToRender = type === "chain" ? filteredData : data;
|
|
14720
14784
|
dataToRender.forEach((d, i) => {
|
|
14721
14785
|
addIconToMapInitialy([d?.marker?.lat, d?.marker?.lng], "location", d.category || "mineSite", d, maxTotal, i);
|
|
14722
14786
|
});
|
|
14723
|
-
|
|
14724
|
-
|
|
14725
|
-
|
|
14787
|
+
if (selectedMarkersId.length > 0) {
|
|
14788
|
+
polylinesRef.current.forEach(polyline => {
|
|
14789
|
+
mapRef.addLayer(polyline);
|
|
14790
|
+
});
|
|
14791
|
+
}
|
|
14726
14792
|
mapRef.invalidateSize();
|
|
14727
14793
|
mapRef.fire("moveend");
|
|
14728
14794
|
}
|