datastake-daf 0.6.782 → 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 +348 -284
- package/dist/pages/index.js +2574 -255
- 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/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
|
@@ -9962,44 +9962,44 @@ function useAjaxModal$2({
|
|
|
9962
9962
|
}
|
|
9963
9963
|
|
|
9964
9964
|
const mergeObject = obj => {
|
|
9965
|
-
return Object.entries(obj || {}).reduce((acc,
|
|
9965
|
+
return Object.entries(obj || {}).reduce((acc, _ref) => {
|
|
9966
|
+
let [key, value] = _ref;
|
|
9966
9967
|
if (typeof value === "object" && !Array.isArray(value) && value !== null) {
|
|
9967
|
-
return {
|
|
9968
|
-
...acc,
|
|
9969
|
-
...value
|
|
9970
|
-
};
|
|
9968
|
+
return _objectSpread2(_objectSpread2({}, acc), value);
|
|
9971
9969
|
}
|
|
9972
|
-
return {
|
|
9973
|
-
...acc,
|
|
9970
|
+
return _objectSpread2(_objectSpread2({}, acc), {}, {
|
|
9974
9971
|
[key]: value
|
|
9975
|
-
};
|
|
9972
|
+
});
|
|
9976
9973
|
}, {});
|
|
9977
9974
|
};
|
|
9978
|
-
const handleDataLinkGroupWithTableKeys =
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9975
|
+
const handleDataLinkGroupWithTableKeys = _ref2 => {
|
|
9976
|
+
var _inputConfig$meta, _config$meta2, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
|
|
9977
|
+
let {
|
|
9978
|
+
config,
|
|
9979
|
+
inputConfig,
|
|
9980
|
+
inputKey,
|
|
9981
|
+
value,
|
|
9982
|
+
level,
|
|
9983
|
+
t,
|
|
9984
|
+
rootForm,
|
|
9985
|
+
allData,
|
|
9986
|
+
user,
|
|
9987
|
+
getApiBaseUrl = () => {},
|
|
9988
|
+
getAppHeader = () => {},
|
|
9989
|
+
app,
|
|
9990
|
+
TreeNodeComponent
|
|
9991
|
+
} = _ref2;
|
|
9993
9992
|
if (!(config.type === 'dataLinkGroup' || config.type === 'dataLink')) {
|
|
9994
9993
|
return null;
|
|
9995
9994
|
}
|
|
9996
|
-
if (inputConfig
|
|
9995
|
+
if ((inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type) !== 'dataLink' || !(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta = inputConfig.meta) !== null && _inputConfig$meta !== void 0 && _inputConfig$meta.tableKeys)) {
|
|
9997
9996
|
const parentInputKeys = Object.keys(config.inputs || {});
|
|
9998
9997
|
const isHandledBySiblingDataLink = parentInputKeys.some(otherInputKey => {
|
|
9999
9998
|
const otherConfig = config.inputs[otherInputKey];
|
|
10000
|
-
if (otherConfig
|
|
10001
|
-
|
|
10002
|
-
const
|
|
9999
|
+
if ((otherConfig === null || otherConfig === void 0 ? void 0 : otherConfig.type) === 'dataLink') {
|
|
10000
|
+
var _otherConfig$meta, _config$meta;
|
|
10001
|
+
const siblingTableKeys = (otherConfig === null || otherConfig === void 0 || (_otherConfig$meta = otherConfig.meta) === null || _otherConfig$meta === void 0 ? void 0 : _otherConfig$meta.tableKeys) || [];
|
|
10002
|
+
const additionalTableKeys = ((_config$meta = config.meta) === null || _config$meta === void 0 ? void 0 : _config$meta.additionalTableKeys) || [];
|
|
10003
10003
|
const allSiblingKeys = [...siblingTableKeys, ...additionalTableKeys];
|
|
10004
10004
|
return allSiblingKeys.includes(inputKey) && otherInputKey !== inputKey;
|
|
10005
10005
|
}
|
|
@@ -10013,23 +10013,26 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10013
10013
|
return null;
|
|
10014
10014
|
}
|
|
10015
10015
|
const tableKeys = inputConfig.meta.tableKeys;
|
|
10016
|
-
const additionalTableKeys = config.meta
|
|
10016
|
+
const additionalTableKeys = ((_config$meta2 = config.meta) === null || _config$meta2 === void 0 ? void 0 : _config$meta2.additionalTableKeys) || [];
|
|
10017
10017
|
const parentInputKeys = Object.keys(config.inputs || {});
|
|
10018
10018
|
const siblingInputsMatchingTableKeys = parentInputKeys.filter(siblingKey => siblingKey !== inputKey).filter(siblingKey => tableKeys.includes(siblingKey) || additionalTableKeys.includes(siblingKey));
|
|
10019
10019
|
[...new Set([...tableKeys, ...siblingInputsMatchingTableKeys])];
|
|
10020
|
-
const isAjaxModal = React.useMemo(() =>
|
|
10020
|
+
const isAjaxModal = React.useMemo(() => {
|
|
10021
|
+
var _inputConfig$meta2;
|
|
10022
|
+
return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
|
|
10023
|
+
}, [inputConfig]);
|
|
10021
10024
|
const ajaxModalValues = useAjaxModal$2({
|
|
10022
10025
|
name: inputKey,
|
|
10023
10026
|
user,
|
|
10024
|
-
namespace: inputConfig
|
|
10025
|
-
skipFetch: inputConfig
|
|
10027
|
+
namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
|
|
10028
|
+
skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
|
|
10026
10029
|
isAjaxModal,
|
|
10027
|
-
formScope: inputConfig
|
|
10030
|
+
formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
|
|
10028
10031
|
APP: app,
|
|
10029
10032
|
apiBaseUrl: getApiBaseUrl(),
|
|
10030
10033
|
_getAppHeader: getAppHeader
|
|
10031
10034
|
});
|
|
10032
|
-
const dataLinkForm = ajaxModalValues
|
|
10035
|
+
const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
|
|
10033
10036
|
const createInputsAndValues = item => {
|
|
10034
10037
|
const inputs = {};
|
|
10035
10038
|
const values = {};
|
|
@@ -10041,12 +10044,12 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10041
10044
|
'videos': 'Video'
|
|
10042
10045
|
};
|
|
10043
10046
|
tableKeys.filter(tableKey => tableKey !== 'datastakeId').forEach(tableKey => {
|
|
10044
|
-
|
|
10047
|
+
var _dataLinkForm$identif;
|
|
10048
|
+
const formInputConfig = (dataLinkForm === null || dataLinkForm === void 0 ? void 0 : dataLinkForm[tableKey]) || (dataLinkForm === null || dataLinkForm === void 0 || (_dataLinkForm$identif = dataLinkForm['identification']) === null || _dataLinkForm$identif === void 0 ? void 0 : _dataLinkForm$identif[tableKey]);
|
|
10045
10049
|
if (formInputConfig) {
|
|
10046
|
-
inputs[tableKey] = {
|
|
10047
|
-
...formInputConfig,
|
|
10050
|
+
inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
|
|
10048
10051
|
label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
|
|
10049
|
-
};
|
|
10052
|
+
});
|
|
10050
10053
|
if (formInputConfig.label && typeof formInputConfig.label === 'object') {
|
|
10051
10054
|
const dynamicLabelKeys = Object.keys(formInputConfig.label);
|
|
10052
10055
|
let resolvedLabel = null;
|
|
@@ -10054,7 +10057,7 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10054
10057
|
const parts = labelKey.split(' is ');
|
|
10055
10058
|
if (parts.length === 2) {
|
|
10056
10059
|
const [conditionKey, conditionValue] = parts;
|
|
10057
|
-
if (item
|
|
10060
|
+
if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
|
|
10058
10061
|
resolvedLabel = formInputConfig.label[labelKey];
|
|
10059
10062
|
break;
|
|
10060
10063
|
}
|
|
@@ -10062,37 +10065,37 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10062
10065
|
}
|
|
10063
10066
|
inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
|
|
10064
10067
|
}
|
|
10065
|
-
values[tableKey] = item
|
|
10068
|
+
values[tableKey] = item === null || item === void 0 ? void 0 : item[tableKey];
|
|
10066
10069
|
} else {
|
|
10070
|
+
var _item$linking;
|
|
10067
10071
|
inputs[tableKey] = {
|
|
10068
10072
|
label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
|
|
10069
|
-
type: inputConfig
|
|
10073
|
+
type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
|
|
10070
10074
|
};
|
|
10071
|
-
values[tableKey] = item
|
|
10075
|
+
values[tableKey] = (item === null || item === void 0 || (_item$linking = item.linking) === null || _item$linking === void 0 || (_item$linking = _item$linking.SCL) === null || _item$linking === void 0 || (_item$linking = _item$linking[item === null || item === void 0 ? void 0 : item[tableKey]]) === null || _item$linking === void 0 ? void 0 : _item$linking.name) || (item === null || item === void 0 ? void 0 : item[tableKey]);
|
|
10072
10076
|
}
|
|
10073
10077
|
});
|
|
10074
10078
|
siblingInputsMatchingTableKeys.forEach(siblingKey => {
|
|
10075
10079
|
const siblingConfig = config.inputs[siblingKey];
|
|
10076
10080
|
if (siblingConfig) {
|
|
10077
|
-
inputs[siblingKey] = {
|
|
10078
|
-
...siblingConfig,
|
|
10081
|
+
inputs[siblingKey] = _objectSpread2(_objectSpread2({}, siblingConfig), {}, {
|
|
10079
10082
|
label: siblingConfig.label || siblingKey
|
|
10080
|
-
};
|
|
10081
|
-
values[siblingKey] = item
|
|
10083
|
+
});
|
|
10084
|
+
values[siblingKey] = item === null || item === void 0 ? void 0 : item[siblingKey];
|
|
10082
10085
|
}
|
|
10083
10086
|
});
|
|
10084
|
-
if (dataLinkForm
|
|
10087
|
+
if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
|
|
10085
10088
|
Object.keys(dataLinkForm.identification).filter(fieldKey => fieldKey !== 'datastakeId' && !tableKeys.includes(fieldKey)).filter(fieldKey => {
|
|
10086
10089
|
const formInputConfig = dataLinkForm.identification[fieldKey];
|
|
10087
10090
|
return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
|
|
10088
10091
|
}).forEach(fieldKey => {
|
|
10092
|
+
var _item$linking2;
|
|
10089
10093
|
const formInputConfig = dataLinkForm.identification[fieldKey];
|
|
10090
|
-
inputs[fieldKey] = {
|
|
10091
|
-
...formInputConfig,
|
|
10094
|
+
inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
|
|
10092
10095
|
label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
|
|
10093
|
-
};
|
|
10094
|
-
if (formInputConfig
|
|
10095
|
-
const dynamicLabelKeys = Object.keys(formInputConfig
|
|
10096
|
+
});
|
|
10097
|
+
if (formInputConfig !== null && formInputConfig !== void 0 && formInputConfig.label && typeof (formInputConfig === null || formInputConfig === void 0 ? void 0 : formInputConfig.label) === 'object') {
|
|
10098
|
+
const dynamicLabelKeys = Object.keys(formInputConfig === null || formInputConfig === void 0 ? void 0 : formInputConfig.label);
|
|
10096
10099
|
let resolvedLabel = null;
|
|
10097
10100
|
for (const labelKey of dynamicLabelKeys) {
|
|
10098
10101
|
const parts = labelKey.split(' is ');
|
|
@@ -10101,7 +10104,7 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10101
10104
|
const flattenedItem = Object.assign({}, item.location, {
|
|
10102
10105
|
address: item.address
|
|
10103
10106
|
});
|
|
10104
|
-
if (flattenedItem
|
|
10107
|
+
if ((flattenedItem === null || flattenedItem === void 0 ? void 0 : flattenedItem[conditionKey]) === conditionValue) {
|
|
10105
10108
|
resolvedLabel = formInputConfig.label[labelKey];
|
|
10106
10109
|
break;
|
|
10107
10110
|
}
|
|
@@ -10109,7 +10112,7 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10109
10112
|
}
|
|
10110
10113
|
inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
|
|
10111
10114
|
}
|
|
10112
|
-
values[fieldKey] = item
|
|
10115
|
+
values[fieldKey] = (item === null || item === void 0 || (_item$linking2 = item.linking) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2.SCL) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2[item === null || item === void 0 ? void 0 : item[fieldKey]]) === null || _item$linking2 === void 0 ? void 0 : _item$linking2.name) || (item === null || item === void 0 ? void 0 : item[fieldKey]);
|
|
10113
10116
|
});
|
|
10114
10117
|
}
|
|
10115
10118
|
return {
|
|
@@ -10119,16 +10122,17 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10119
10122
|
};
|
|
10120
10123
|
if (Array.isArray(value)) {
|
|
10121
10124
|
return value.map((item, itemIndex) => {
|
|
10125
|
+
var _merged$inputKey;
|
|
10122
10126
|
const merged = mergeObject(item);
|
|
10123
|
-
const datastakeIdValue = merged
|
|
10127
|
+
const datastakeIdValue = (merged === null || merged === void 0 || (_merged$inputKey = merged[inputKey]) === null || _merged$inputKey === void 0 ? void 0 : _merged$inputKey.datastakeId) || (merged === null || merged === void 0 ? void 0 : merged.datastakeId);
|
|
10124
10128
|
const {
|
|
10125
10129
|
inputs,
|
|
10126
10130
|
values
|
|
10127
10131
|
} = createInputsAndValues(merged);
|
|
10128
10132
|
return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
|
|
10129
|
-
nodeKey: datastakeIdValue || t(
|
|
10133
|
+
nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
|
|
10130
10134
|
config: {
|
|
10131
|
-
label: datastakeIdValue || t(
|
|
10135
|
+
label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
|
|
10132
10136
|
type: 'custom-datalink-group',
|
|
10133
10137
|
inputs: inputs
|
|
10134
10138
|
},
|
|
@@ -10142,11 +10146,12 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10142
10146
|
getApiBaseUrl: getApiBaseUrl,
|
|
10143
10147
|
getAppHeader: getAppHeader,
|
|
10144
10148
|
app: app
|
|
10145
|
-
},
|
|
10149
|
+
}, "".concat(inputKey, "-").concat(itemIndex));
|
|
10146
10150
|
});
|
|
10147
10151
|
} else {
|
|
10152
|
+
var _merged$inputKey2;
|
|
10148
10153
|
const merged = mergeObject(value);
|
|
10149
|
-
const datastakeIdValue = merged
|
|
10154
|
+
const datastakeIdValue = (merged === null || merged === void 0 || (_merged$inputKey2 = merged[inputKey]) === null || _merged$inputKey2 === void 0 ? void 0 : _merged$inputKey2.datastakeId) || (merged === null || merged === void 0 ? void 0 : merged.datastakeId);
|
|
10150
10155
|
const {
|
|
10151
10156
|
inputs,
|
|
10152
10157
|
values
|
|
@@ -10168,7 +10173,7 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10168
10173
|
getApiBaseUrl: getApiBaseUrl,
|
|
10169
10174
|
getAppHeader: getAppHeader,
|
|
10170
10175
|
app: app
|
|
10171
|
-
},
|
|
10176
|
+
}, "".concat(inputKey, "-group"));
|
|
10172
10177
|
}
|
|
10173
10178
|
};
|
|
10174
10179
|
|
|
@@ -12465,6 +12470,8 @@ const Style$M = styled__default["default"].div`
|
|
|
12465
12470
|
width: 100%;
|
|
12466
12471
|
height: 472px;
|
|
12467
12472
|
|
|
12473
|
+
|
|
12474
|
+
|
|
12468
12475
|
.filter-cont {
|
|
12469
12476
|
position: absolute;
|
|
12470
12477
|
top: 24px;
|
|
@@ -12567,11 +12574,24 @@ const Style$M = styled__default["default"].div`
|
|
|
12567
12574
|
align-items: center;
|
|
12568
12575
|
}
|
|
12569
12576
|
|
|
12570
|
-
|
|
12571
|
-
|
|
12572
|
-
|
|
12573
|
-
|
|
12574
|
-
|
|
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
|
+
|
|
12575
12595
|
|
|
12576
12596
|
}
|
|
12577
12597
|
|
|
@@ -13017,18 +13037,15 @@ const VILLAGE = "village";
|
|
|
13017
13037
|
const EXPORTER = "exporter";
|
|
13018
13038
|
const PROCESSOR = "mineralProcessor";
|
|
13019
13039
|
const DEPOT = "depot";
|
|
13040
|
+
const OPERATOR = "miningOperator";
|
|
13020
13041
|
const MAX_EXTRA_SMALL_ZOOM_THRESHOLD = 2;
|
|
13021
13042
|
const MAX_SMALL_ZOOM_THRESHOLD = 3;
|
|
13022
13043
|
const MAX_MEDIUM_ZOOM_THRESHOLD = 6;
|
|
13023
13044
|
const LOCATION_TYPES = [MINE_SITE, VILLAGE];
|
|
13024
|
-
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT];
|
|
13045
|
+
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT, OPERATOR];
|
|
13025
13046
|
const RADIUS_SMALL = 15;
|
|
13026
13047
|
const RADIUS_MEDIUM = 35;
|
|
13027
13048
|
const RADIUS_LARGE = 60;
|
|
13028
|
-
const RADIUS_CURVE_SMALL = 10;
|
|
13029
|
-
const RADIUS_CURVE_MEDIUM = 15;
|
|
13030
|
-
const RADIUS_CURVE_LARGE = 20;
|
|
13031
|
-
const TENSION = 0.2;
|
|
13032
13049
|
function isLocation(type) {
|
|
13033
13050
|
return LOCATION_TYPES.includes(type);
|
|
13034
13051
|
}
|
|
@@ -13085,7 +13102,6 @@ function getStakeholderPosition({
|
|
|
13085
13102
|
const isLarge = isLargeMarker(zoom);
|
|
13086
13103
|
let radius;
|
|
13087
13104
|
let center = {
|
|
13088
|
-
// NOT BEING USED FOR NOW AND MAYBE NEVER
|
|
13089
13105
|
left: 0,
|
|
13090
13106
|
top: 0
|
|
13091
13107
|
};
|
|
@@ -13109,6 +13125,25 @@ function getStakeholderPosition({
|
|
|
13109
13125
|
angleDeg
|
|
13110
13126
|
};
|
|
13111
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
|
+
}
|
|
13112
13147
|
function createPolyline({
|
|
13113
13148
|
L,
|
|
13114
13149
|
startLatLng,
|
|
@@ -13118,109 +13153,47 @@ function createPolyline({
|
|
|
13118
13153
|
zoom,
|
|
13119
13154
|
listOfPolylines = [],
|
|
13120
13155
|
isFromStakeholder = false,
|
|
13121
|
-
isForceOpen = false
|
|
13156
|
+
isForceOpen = false,
|
|
13157
|
+
stakeholderType = null,
|
|
13158
|
+
animated = false,
|
|
13159
|
+
mapRef
|
|
13122
13160
|
}) {
|
|
13123
|
-
const
|
|
13124
|
-
const
|
|
13125
|
-
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 = {
|
|
13126
13166
|
color: "var(--base-gray-70)",
|
|
13127
|
-
weight:
|
|
13128
|
-
opacity: 0.5,
|
|
13129
|
-
smoothFactor:
|
|
13167
|
+
weight: lineWidth,
|
|
13168
|
+
opacity: isSelected ? 1 : 0.5,
|
|
13169
|
+
smoothFactor: 0,
|
|
13130
13170
|
id,
|
|
13131
|
-
dashArray: !isSelected ? "5, 5" : "
|
|
13171
|
+
dashArray: isShortLink ? "0, 0" : shouldAnimate ? "10, 10" : !isSelected ? "5, 5" : "10, 10",
|
|
13172
|
+
renderer: L.svg()
|
|
13132
13173
|
};
|
|
13133
|
-
const
|
|
13134
|
-
if (
|
|
13135
|
-
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
|
|
13142
|
-
|
|
13143
|
-
function createCurvePath({
|
|
13144
|
-
zoom,
|
|
13145
|
-
totalMarkers,
|
|
13146
|
-
markerIndex
|
|
13147
|
-
}) {
|
|
13148
|
-
const radius = getCurvePointRadius(zoom);
|
|
13149
|
-
const {
|
|
13150
|
-
x,
|
|
13151
|
-
y,
|
|
13152
|
-
angleDeg
|
|
13153
|
-
} = getAngleDeg(totalMarkers, markerIndex, radius);
|
|
13154
|
-
return {
|
|
13155
|
-
x,
|
|
13156
|
-
y,
|
|
13157
|
-
angleDeg
|
|
13158
|
-
};
|
|
13159
|
-
}
|
|
13160
|
-
function getCurvePointRadius(zoom) {
|
|
13161
|
-
const isSmall = isSmallMarker(zoom) || isExtraSmallMarker(zoom);
|
|
13162
|
-
const isMedium = isMediumMarker(zoom);
|
|
13163
|
-
if (isSmall) {
|
|
13164
|
-
return RADIUS_SMALL + RADIUS_CURVE_SMALL;
|
|
13165
|
-
} else if (isMedium) {
|
|
13166
|
-
return RADIUS_MEDIUM + RADIUS_CURVE_MEDIUM;
|
|
13167
|
-
} else {
|
|
13168
|
-
return RADIUS_LARGE + RADIUS_CURVE_LARGE;
|
|
13169
|
-
}
|
|
13170
|
-
}
|
|
13171
|
-
function buildSmoothCurve(layerPoints, mapRef) {
|
|
13172
|
-
const path = [];
|
|
13173
|
-
for (let i = 0; i < layerPoints.length - 1; i++) {
|
|
13174
|
-
const p0 = layerPoints[i];
|
|
13175
|
-
const p1 = layerPoints[i + 1];
|
|
13176
|
-
const pPrev = layerPoints[i - 1] || p0;
|
|
13177
|
-
const pNext = layerPoints[i + 2] || p1;
|
|
13178
|
-
const cp1 = L__namespace.point(p0.x + (p1.x - pPrev.x) * TENSION, p0.y + (p1.y - pPrev.y) * TENSION);
|
|
13179
|
-
const cp2 = L__namespace.point(p1.x - (pNext.x - p0.x) * TENSION, p1.y - (pNext.y - p0.y) * TENSION);
|
|
13180
|
-
if (i === 0) {
|
|
13181
|
-
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);
|
|
13182
13184
|
}
|
|
13183
|
-
|
|
13185
|
+
return existingPolyline;
|
|
13184
13186
|
}
|
|
13185
|
-
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
if (
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
startLatLng,
|
|
13196
|
-
endLatLng,
|
|
13197
|
-
zoom,
|
|
13198
|
-
isSelected,
|
|
13199
|
-
id
|
|
13200
|
-
}) {
|
|
13201
|
-
const fromPoint = mapRef.latLngToLayerPoint(startLatLng);
|
|
13202
|
-
const toPoint = mapRef.latLngToLayerPoint(endLatLng);
|
|
13203
|
-
const midX = (fromPoint.x + toPoint.x) / 2;
|
|
13204
|
-
const midY = (fromPoint.y + toPoint.y) / 2 + (isSmallMarker(zoom) ? RADIUS_CURVE_SMALL / 2 : 0);
|
|
13205
|
-
const dx = toPoint.x - fromPoint.x;
|
|
13206
|
-
const dy = toPoint.y - fromPoint.y;
|
|
13207
|
-
const normal = L__namespace.point(-dy, dx);
|
|
13208
|
-
const length = Math.sqrt(normal.x ** 2 + normal.y ** 2) || 1;
|
|
13209
|
-
const normalized = normal.multiplyBy(1 / length);
|
|
13210
|
-
const curveStrength = getSiblingCurveStrength(zoom);
|
|
13211
|
-
const controlPoint = L__namespace.point(midX, midY).add(normalized.multiplyBy(curveStrength));
|
|
13212
|
-
const latlngs = [startLatLng, mapRef.layerPointToLatLng(controlPoint), endLatLng];
|
|
13213
|
-
const layerPoints = latlngs.map(latlng => mapRef.latLngToLayerPoint(latlng));
|
|
13214
|
-
const path = buildSmoothCurve(layerPoints, mapRef);
|
|
13215
|
-
const curve = L__namespace.curve(path, {
|
|
13216
|
-
color: "var(--base-gray-70)",
|
|
13217
|
-
weight: isExtraSmallMarker(zoom) ? 0 : 1.2,
|
|
13218
|
-
opacity: 0.5,
|
|
13219
|
-
smoothFactor: 1,
|
|
13220
|
-
id,
|
|
13221
|
-
dashArray: !isSelected ? "5, 5" : "0, 0"
|
|
13222
|
-
});
|
|
13223
|
-
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;
|
|
13224
13197
|
}
|
|
13225
13198
|
|
|
13226
13199
|
const StakeholderMarker = styled__default["default"].div`
|
|
@@ -13522,6 +13495,9 @@ function StakeholderIcon$1({
|
|
|
13522
13495
|
return null;
|
|
13523
13496
|
}, [parentId, allData]);
|
|
13524
13497
|
React.useEffect(() => {
|
|
13498
|
+
if (selectedMarkersId.length === 0 || !isSelected) {
|
|
13499
|
+
return;
|
|
13500
|
+
}
|
|
13525
13501
|
linkNodesData.map(node => {
|
|
13526
13502
|
const isConnectingToStakeholder = node.isStakeholder;
|
|
13527
13503
|
const id = `${data.datastakeId}-${node.stakeholderId || node.datastakeId}`;
|
|
@@ -13533,8 +13509,6 @@ function StakeholderIcon$1({
|
|
|
13533
13509
|
const stakeholderPoint = centerPoint.add(L__namespace.point(x, y));
|
|
13534
13510
|
const stakeholderLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
|
|
13535
13511
|
let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
13536
|
-
const areNextToEachOther = targetMarkerIndex === index + 1 || targetMarkerIndex === index - 1 || index === 0 && targetMarkerIndex === node.totalStakeholders - 1 || targetMarkerIndex === 0 && index === node.totalStakeholders - 1;
|
|
13537
|
-
const areOnlyTwoSiblings = node.totalStakeholders === 2;
|
|
13538
13512
|
if (isExtraSmallMarker(zoom) && !isForceOpen) {
|
|
13539
13513
|
createPolyline({
|
|
13540
13514
|
L: L__namespace,
|
|
@@ -13544,7 +13518,8 @@ function StakeholderIcon$1({
|
|
|
13544
13518
|
zoom,
|
|
13545
13519
|
isSelected,
|
|
13546
13520
|
id,
|
|
13547
|
-
listOfPolylines: polylinesRef.current
|
|
13521
|
+
listOfPolylines: polylinesRef.current,
|
|
13522
|
+
animated: true
|
|
13548
13523
|
});
|
|
13549
13524
|
return;
|
|
13550
13525
|
}
|
|
@@ -13562,61 +13537,8 @@ function StakeholderIcon$1({
|
|
|
13562
13537
|
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
13563
13538
|
const endPoint = L__namespace.point(x + nodePoint.x + center.left, y + nodePoint.y + center.top);
|
|
13564
13539
|
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
13565
|
-
if (isSibling && (!areNextToEachOther || areOnlyTwoSiblings)) {
|
|
13566
|
-
if (areOnlyTwoSiblings) {
|
|
13567
|
-
buildCurveWIthTwoSiblings({
|
|
13568
|
-
mapRef,
|
|
13569
|
-
startLatLng: stakeholderLatLng,
|
|
13570
|
-
endLatLng,
|
|
13571
|
-
zoom,
|
|
13572
|
-
isSelected,
|
|
13573
|
-
id
|
|
13574
|
-
});
|
|
13575
|
-
return;
|
|
13576
|
-
}
|
|
13577
|
-
const total = node.totalStakeholders;
|
|
13578
|
-
let from = index;
|
|
13579
|
-
let to = targetMarkerIndex;
|
|
13580
|
-
let flip = false;
|
|
13581
|
-
const forwardDistance = (to - from + total) % total;
|
|
13582
|
-
const backwardDistance = (from - to + total) % total;
|
|
13583
|
-
if (backwardDistance < forwardDistance) {
|
|
13584
|
-
[from, to] = [to, from];
|
|
13585
|
-
flip = true;
|
|
13586
|
-
}
|
|
13587
|
-
const intermediateIndices = [];
|
|
13588
|
-
for (let i = 1; i < (to - from + total) % total; i++) {
|
|
13589
|
-
intermediateIndices.push((from + i) % total);
|
|
13590
|
-
}
|
|
13591
|
-
const indices = [from, ...intermediateIndices, to];
|
|
13592
|
-
const intermediatePoints = [];
|
|
13593
|
-
for (const i of indices) {
|
|
13594
|
-
const {
|
|
13595
|
-
x,
|
|
13596
|
-
y
|
|
13597
|
-
} = createCurvePath({
|
|
13598
|
-
zoom,
|
|
13599
|
-
totalMarkers: node.totalStakeholders,
|
|
13600
|
-
markerIndex: i
|
|
13601
|
-
});
|
|
13602
|
-
const point = centerPoint.add(L__namespace.point(x, y));
|
|
13603
|
-
const latlng = mapRef.layerPointToLatLng(point);
|
|
13604
|
-
intermediatePoints.push(latlng);
|
|
13605
|
-
}
|
|
13606
|
-
const latlngs = flip ? [endLatLng, ...intermediatePoints, stakeholderLatLng] : [stakeholderLatLng, ...intermediatePoints, endLatLng];
|
|
13607
|
-
const layerPoints = latlngs.map(latlng => mapRef.latLngToLayerPoint(latlng));
|
|
13608
|
-
const path = buildSmoothCurve(layerPoints, mapRef);
|
|
13609
|
-
const curve = L__namespace?.curve?.(path, {
|
|
13610
|
-
color: "var(--base-gray-70)",
|
|
13611
|
-
weight: isExtraSmallMarker(zoom) ? 0 : 1,
|
|
13612
|
-
opacity: isSelected ? 1 : 0.5,
|
|
13613
|
-
smoothFactor: 1,
|
|
13614
|
-
id
|
|
13615
|
-
});
|
|
13616
|
-
mapRef.addLayer(curve);
|
|
13617
|
-
return;
|
|
13618
|
-
}
|
|
13619
13540
|
}
|
|
13541
|
+
// Always use straight lines
|
|
13620
13542
|
createPolyline({
|
|
13621
13543
|
L: L__namespace,
|
|
13622
13544
|
mapRef,
|
|
@@ -13626,10 +13548,11 @@ function StakeholderIcon$1({
|
|
|
13626
13548
|
isFromStakeholder: false,
|
|
13627
13549
|
isSelected,
|
|
13628
13550
|
id,
|
|
13629
|
-
listOfPolylines: polylinesRef.current
|
|
13551
|
+
listOfPolylines: polylinesRef.current,
|
|
13552
|
+
animated: true
|
|
13630
13553
|
});
|
|
13631
13554
|
});
|
|
13632
|
-
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen]);
|
|
13555
|
+
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen, selectedMarkersId]);
|
|
13633
13556
|
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
13634
13557
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
|
|
13635
13558
|
content: renderTooltipJsx({
|
|
@@ -13641,7 +13564,8 @@ function StakeholderIcon$1({
|
|
|
13641
13564
|
link,
|
|
13642
13565
|
onClickLink: () => {
|
|
13643
13566
|
onClickLink(data);
|
|
13644
|
-
}
|
|
13567
|
+
},
|
|
13568
|
+
isNewTab: true
|
|
13645
13569
|
}),
|
|
13646
13570
|
getPopupContainer: triggerNode => {
|
|
13647
13571
|
const mapElement = document.getElementById("map");
|
|
@@ -13696,6 +13620,8 @@ function LocationIcon({
|
|
|
13696
13620
|
const linkedNodesData = React.useMemo(() => {
|
|
13697
13621
|
const nodes = [];
|
|
13698
13622
|
const links = data.links || [];
|
|
13623
|
+
|
|
13624
|
+
// Add links from the location itself
|
|
13699
13625
|
links.forEach(link => {
|
|
13700
13626
|
allData.forEach(d => {
|
|
13701
13627
|
if (d.datastakeId === link) {
|
|
@@ -13715,8 +13641,45 @@ function LocationIcon({
|
|
|
13715
13641
|
}
|
|
13716
13642
|
});
|
|
13717
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
|
+
});
|
|
13718
13681
|
return nodes;
|
|
13719
|
-
}, [JSON.stringify(allData), JSON.stringify(data.links), zoom]);
|
|
13682
|
+
}, [JSON.stringify(allData), JSON.stringify(data.links), JSON.stringify(data.stakeholders), zoom]);
|
|
13720
13683
|
const stakeholdersOfLocation = React.useMemo(() => {
|
|
13721
13684
|
return data?.stakeholders || [];
|
|
13722
13685
|
}, [data.stakeholders, zoom]);
|
|
@@ -13734,7 +13697,13 @@ function LocationIcon({
|
|
|
13734
13697
|
currentRoots.clear();
|
|
13735
13698
|
markersRef.current = [];
|
|
13736
13699
|
|
|
13737
|
-
//
|
|
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
|
|
13738
13707
|
stakeholdersOfLocation.forEach((stakeholder, index) => {
|
|
13739
13708
|
const markerId = `${stakeholder.datastakeId}`;
|
|
13740
13709
|
const {
|
|
@@ -13820,7 +13789,9 @@ function LocationIcon({
|
|
|
13820
13789
|
zoom,
|
|
13821
13790
|
isFromStakeholder: true,
|
|
13822
13791
|
isForceOpen,
|
|
13823
|
-
listOfPolylines: polylinesRef.current
|
|
13792
|
+
listOfPolylines: polylinesRef.current,
|
|
13793
|
+
stakeholderType: stakeholder.type,
|
|
13794
|
+
animated: true
|
|
13824
13795
|
});
|
|
13825
13796
|
});
|
|
13826
13797
|
return () => {
|
|
@@ -13835,38 +13806,88 @@ function LocationIcon({
|
|
|
13835
13806
|
rootsMapRef.current.clear();
|
|
13836
13807
|
markersRef.current = [];
|
|
13837
13808
|
};
|
|
13838
|
-
}, [stakeholdersOfLocation, selectedMarkersId, activeMarker]);
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
|
|
13843
|
-
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13848
|
-
|
|
13849
|
-
|
|
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,
|
|
13850
13886
|
zoom,
|
|
13851
|
-
|
|
13852
|
-
|
|
13853
|
-
});
|
|
13854
|
-
const nodeLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
13855
|
-
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
13856
|
-
const endPoint = L__namespace.point(x + nodePoint.x, y + nodePoint.y);
|
|
13857
|
-
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
13858
|
-
}
|
|
13859
|
-
createPolyline({
|
|
13860
|
-
L: L__namespace,
|
|
13861
|
-
mapRef,
|
|
13862
|
-
startLatLng: centerLatLng,
|
|
13863
|
-
endLatLng,
|
|
13864
|
-
isSelected: isConnectingToStakeholderSelected,
|
|
13865
|
-
id,
|
|
13866
|
-
zoom,
|
|
13867
|
-
listOfPolylines: polylinesRef.current
|
|
13887
|
+
listOfPolylines: polylinesRef.current
|
|
13888
|
+
});
|
|
13868
13889
|
});
|
|
13869
|
-
});
|
|
13890
|
+
}, [linkedNodesData, selectedMarkersId, zoom, stakeholdersOfLocation, isSelected]);
|
|
13870
13891
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
|
|
13871
13892
|
content: renderTooltipJsx({
|
|
13872
13893
|
title: data.name,
|
|
@@ -14382,7 +14403,8 @@ function useMapHelper$1({
|
|
|
14382
14403
|
link: link,
|
|
14383
14404
|
onClickLink: onClickLink,
|
|
14384
14405
|
activeStakeholder: activeStakeholder,
|
|
14385
|
-
setActiveStakeholder: setActiveStakeholder
|
|
14406
|
+
setActiveStakeholder: setActiveStakeholder,
|
|
14407
|
+
mapRef: mapRef
|
|
14386
14408
|
}));
|
|
14387
14409
|
roots.current.push(root);
|
|
14388
14410
|
} else if (type === "location") {
|
|
@@ -14587,7 +14609,8 @@ const useMap$1 = ({
|
|
|
14587
14609
|
MAP_TOKEN
|
|
14588
14610
|
} = useMapConfig({
|
|
14589
14611
|
app,
|
|
14590
|
-
isSatellite
|
|
14612
|
+
isSatellite,
|
|
14613
|
+
mapRef: container
|
|
14591
14614
|
});
|
|
14592
14615
|
const [initialMarkerSetIsDone, setInitialMarkerSetIsDone] = React.useState(false);
|
|
14593
14616
|
const [mapCenter, setMapCenter] = React.useState([0, 0]);
|
|
@@ -14604,6 +14627,8 @@ const useMap$1 = ({
|
|
|
14604
14627
|
const graph = new Map();
|
|
14605
14628
|
const stakeToLoc = new Map();
|
|
14606
14629
|
const nodeTypes = new Map();
|
|
14630
|
+
|
|
14631
|
+
// Build the graph
|
|
14607
14632
|
for (const loc of data) {
|
|
14608
14633
|
const locId = loc.datastakeId;
|
|
14609
14634
|
nodeTypes.set(locId, loc.type);
|
|
@@ -14628,26 +14653,45 @@ const useMap$1 = ({
|
|
|
14628
14653
|
}
|
|
14629
14654
|
}
|
|
14630
14655
|
const highlightTable = {};
|
|
14656
|
+
|
|
14657
|
+
// Perform BFS/DFS to find all connected nodes in the entire chain
|
|
14631
14658
|
for (const [node] of graph) {
|
|
14632
14659
|
const highlighted = new Set();
|
|
14633
|
-
|
|
14634
|
-
const
|
|
14635
|
-
|
|
14636
|
-
const
|
|
14637
|
-
highlighted.add(
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
const
|
|
14641
|
-
if (
|
|
14642
|
-
const
|
|
14643
|
-
if (
|
|
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
|
-
|
|
14646
|
-
|
|
14647
|
-
|
|
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
|
+
}
|
|
14648
14694
|
}
|
|
14649
|
-
} else {
|
|
14650
|
-
highlighted.add(neighbor);
|
|
14651
14695
|
}
|
|
14652
14696
|
}
|
|
14653
14697
|
highlightTable[node] = [...highlighted];
|
|
@@ -14685,10 +14729,20 @@ const useMap$1 = ({
|
|
|
14685
14729
|
function handleSelectMarker(clickedMarker) {
|
|
14686
14730
|
setSelectedMarkersId(prev => {
|
|
14687
14731
|
if (prev.includes(clickedMarker.datastakeId)) {
|
|
14732
|
+
// Deselecting - clear polylines
|
|
14688
14733
|
openPopupIdRef.current = null;
|
|
14689
14734
|
setMarkerWithPopup(null);
|
|
14690
14735
|
return [];
|
|
14691
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
|
+
}
|
|
14692
14746
|
setMarkerWithPopup(isStakeholder(clickedMarker.type) ? clickedMarker : null);
|
|
14693
14747
|
const newSelectedMarkersId = highlightTable[clickedMarker.datastakeId];
|
|
14694
14748
|
openPopupIdRef.current = clickedMarker.datastakeId;
|
|
@@ -14712,19 +14766,29 @@ const useMap$1 = ({
|
|
|
14712
14766
|
});
|
|
14713
14767
|
}
|
|
14714
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
|
+
}
|
|
14715
14779
|
clearMapMarkers();
|
|
14716
14780
|
if (data) {
|
|
14717
|
-
|
|
14718
|
-
const excludedType = ['village', 'town', 'area', 'territory'];
|
|
14719
|
-
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))));
|
|
14720
14782
|
const maxTotal = Math.max(...(data || []).map(d => d.total));
|
|
14721
14783
|
const dataToRender = type === "chain" ? filteredData : data;
|
|
14722
14784
|
dataToRender.forEach((d, i) => {
|
|
14723
14785
|
addIconToMapInitialy([d?.marker?.lat, d?.marker?.lng], "location", d.category || "mineSite", d, maxTotal, i);
|
|
14724
14786
|
});
|
|
14725
|
-
|
|
14726
|
-
|
|
14727
|
-
|
|
14787
|
+
if (selectedMarkersId.length > 0) {
|
|
14788
|
+
polylinesRef.current.forEach(polyline => {
|
|
14789
|
+
mapRef.addLayer(polyline);
|
|
14790
|
+
});
|
|
14791
|
+
}
|
|
14728
14792
|
mapRef.invalidateSize();
|
|
14729
14793
|
mapRef.fire("moveend");
|
|
14730
14794
|
}
|