datastake-daf 0.6.780 → 0.6.781
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.js +314 -369
- package/dist/pages/index.js +232 -2049
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/dist/utils/index.js +0 -13
- package/package.json +1 -1
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +76 -9
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +8 -116
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/utils.js +17 -73
- package/src/@daf/core/components/Dashboard/Map/helper.js +0 -1
- package/src/@daf/core/components/Dashboard/Map/hook.js +29 -64
- package/src/@daf/core/components/Dashboard/Map/style.js +5 -20
- package/src/@daf/hooks/useViewFormUrlParams.js +84 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/components/PlantingLocations/index.jsx +168 -163
- package/src/@daf/utils/object.js +1 -3
- package/src/pages.js +1 -4
- package/src/utils.js +1 -1
- package/src/@daf/pages/View/hooks/useCallToGetData.js +0 -73
- package/src/@daf/pages/View/hooks/usePrepareForm.js +0 -86
- package/src/@daf/pages/View/hooks/useSubmitSubject.js +0 -40
- package/src/@daf/pages/View/hooks/useViewActions.js +0 -83
- package/src/@daf/pages/View/hooks/useViewPermissions.js +0 -75
- package/src/@daf/pages/View/hooks/useViewUrlParams.js +0 -93
- package/src/@daf/pages/View/index.jsx +0 -286
package/dist/components/index.js
CHANGED
|
@@ -8486,22 +8486,20 @@ const useHeader = _ref => {
|
|
|
8486
8486
|
const {
|
|
8487
8487
|
useToken: useToken$m
|
|
8488
8488
|
} = antd.theme;
|
|
8489
|
-
function BreadCrumbs(
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
} = _ref;
|
|
8489
|
+
function BreadCrumbs({
|
|
8490
|
+
breadcrumbs = [],
|
|
8491
|
+
mainContWidth = 0
|
|
8492
|
+
}) {
|
|
8494
8493
|
const [splitIndex, setSplitIndex] = React.useState(0);
|
|
8495
8494
|
const {
|
|
8496
8495
|
token
|
|
8497
8496
|
} = useToken$m();
|
|
8498
|
-
const _renderBreadcrumb =
|
|
8499
|
-
let noOnClickLast = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
8497
|
+
const _renderBreadcrumb = (b, i, isLast, noOnClickLast = false) => {
|
|
8500
8498
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
8501
8499
|
className: "flex breadcrumb-item",
|
|
8502
|
-
onClick: noOnClickLast && isLast ? undefined : b
|
|
8500
|
+
onClick: noOnClickLast && isLast ? undefined : b?.onClick,
|
|
8503
8501
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
8504
|
-
children: b
|
|
8502
|
+
children: b?.label
|
|
8505
8503
|
}), !isLast && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
8506
8504
|
className: "flex flex-column justify-content-center",
|
|
8507
8505
|
children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
|
|
@@ -8511,7 +8509,7 @@ function BreadCrumbs(_ref) {
|
|
|
8511
8509
|
color: token.baseGray50
|
|
8512
8510
|
})
|
|
8513
8511
|
})]
|
|
8514
|
-
},
|
|
8512
|
+
}, `breadcrumb-item-${i}`);
|
|
8515
8513
|
};
|
|
8516
8514
|
React.useEffect(() => {
|
|
8517
8515
|
const _placeholderCont = document.getElementById("header-breadcrumbs");
|
|
@@ -8554,7 +8552,7 @@ function BreadCrumbs(_ref) {
|
|
|
8554
8552
|
placement: "bottomRight",
|
|
8555
8553
|
menu: {
|
|
8556
8554
|
items: groupedBreadCrumbs[2].map((it, i) => ({
|
|
8557
|
-
key:
|
|
8555
|
+
key: `items-${i}`,
|
|
8558
8556
|
label: it.label,
|
|
8559
8557
|
onClick: it.onClick
|
|
8560
8558
|
}))
|
|
@@ -9956,44 +9954,44 @@ function useAjaxModal$2({
|
|
|
9956
9954
|
}
|
|
9957
9955
|
|
|
9958
9956
|
const mergeObject = obj => {
|
|
9959
|
-
return Object.entries(obj || {}).reduce((acc,
|
|
9957
|
+
return Object.entries(obj || {}).reduce((acc, _ref) => {
|
|
9958
|
+
let [key, value] = _ref;
|
|
9960
9959
|
if (typeof value === "object" && !Array.isArray(value) && value !== null) {
|
|
9961
|
-
return {
|
|
9962
|
-
...acc,
|
|
9963
|
-
...value
|
|
9964
|
-
};
|
|
9960
|
+
return _objectSpread2(_objectSpread2({}, acc), value);
|
|
9965
9961
|
}
|
|
9966
|
-
return {
|
|
9967
|
-
...acc,
|
|
9962
|
+
return _objectSpread2(_objectSpread2({}, acc), {}, {
|
|
9968
9963
|
[key]: value
|
|
9969
|
-
};
|
|
9964
|
+
});
|
|
9970
9965
|
}, {});
|
|
9971
9966
|
};
|
|
9972
|
-
const handleDataLinkGroupWithTableKeys =
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9967
|
+
const handleDataLinkGroupWithTableKeys = _ref2 => {
|
|
9968
|
+
var _inputConfig$meta, _config$meta2, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
|
|
9969
|
+
let {
|
|
9970
|
+
config,
|
|
9971
|
+
inputConfig,
|
|
9972
|
+
inputKey,
|
|
9973
|
+
value,
|
|
9974
|
+
level,
|
|
9975
|
+
t,
|
|
9976
|
+
rootForm,
|
|
9977
|
+
allData,
|
|
9978
|
+
user,
|
|
9979
|
+
getApiBaseUrl = () => {},
|
|
9980
|
+
getAppHeader = () => {},
|
|
9981
|
+
app,
|
|
9982
|
+
TreeNodeComponent
|
|
9983
|
+
} = _ref2;
|
|
9987
9984
|
if (!(config.type === 'dataLinkGroup' || config.type === 'dataLink')) {
|
|
9988
9985
|
return null;
|
|
9989
9986
|
}
|
|
9990
|
-
if (inputConfig
|
|
9987
|
+
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)) {
|
|
9991
9988
|
const parentInputKeys = Object.keys(config.inputs || {});
|
|
9992
9989
|
const isHandledBySiblingDataLink = parentInputKeys.some(otherInputKey => {
|
|
9993
9990
|
const otherConfig = config.inputs[otherInputKey];
|
|
9994
|
-
if (otherConfig
|
|
9995
|
-
|
|
9996
|
-
const
|
|
9991
|
+
if ((otherConfig === null || otherConfig === void 0 ? void 0 : otherConfig.type) === 'dataLink') {
|
|
9992
|
+
var _otherConfig$meta, _config$meta;
|
|
9993
|
+
const siblingTableKeys = (otherConfig === null || otherConfig === void 0 || (_otherConfig$meta = otherConfig.meta) === null || _otherConfig$meta === void 0 ? void 0 : _otherConfig$meta.tableKeys) || [];
|
|
9994
|
+
const additionalTableKeys = ((_config$meta = config.meta) === null || _config$meta === void 0 ? void 0 : _config$meta.additionalTableKeys) || [];
|
|
9997
9995
|
const allSiblingKeys = [...siblingTableKeys, ...additionalTableKeys];
|
|
9998
9996
|
return allSiblingKeys.includes(inputKey) && otherInputKey !== inputKey;
|
|
9999
9997
|
}
|
|
@@ -10007,23 +10005,26 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10007
10005
|
return null;
|
|
10008
10006
|
}
|
|
10009
10007
|
const tableKeys = inputConfig.meta.tableKeys;
|
|
10010
|
-
const additionalTableKeys = config.meta
|
|
10008
|
+
const additionalTableKeys = ((_config$meta2 = config.meta) === null || _config$meta2 === void 0 ? void 0 : _config$meta2.additionalTableKeys) || [];
|
|
10011
10009
|
const parentInputKeys = Object.keys(config.inputs || {});
|
|
10012
10010
|
const siblingInputsMatchingTableKeys = parentInputKeys.filter(siblingKey => siblingKey !== inputKey).filter(siblingKey => tableKeys.includes(siblingKey) || additionalTableKeys.includes(siblingKey));
|
|
10013
10011
|
[...new Set([...tableKeys, ...siblingInputsMatchingTableKeys])];
|
|
10014
|
-
const isAjaxModal = React.useMemo(() =>
|
|
10012
|
+
const isAjaxModal = React.useMemo(() => {
|
|
10013
|
+
var _inputConfig$meta2;
|
|
10014
|
+
return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
|
|
10015
|
+
}, [inputConfig]);
|
|
10015
10016
|
const ajaxModalValues = useAjaxModal$2({
|
|
10016
10017
|
name: inputKey,
|
|
10017
10018
|
user,
|
|
10018
|
-
namespace: inputConfig
|
|
10019
|
-
skipFetch: inputConfig
|
|
10019
|
+
namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
|
|
10020
|
+
skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
|
|
10020
10021
|
isAjaxModal,
|
|
10021
|
-
formScope: inputConfig
|
|
10022
|
+
formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
|
|
10022
10023
|
APP: app,
|
|
10023
10024
|
apiBaseUrl: getApiBaseUrl(),
|
|
10024
10025
|
_getAppHeader: getAppHeader
|
|
10025
10026
|
});
|
|
10026
|
-
const dataLinkForm = ajaxModalValues
|
|
10027
|
+
const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
|
|
10027
10028
|
const createInputsAndValues = item => {
|
|
10028
10029
|
const inputs = {};
|
|
10029
10030
|
const values = {};
|
|
@@ -10035,12 +10036,12 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10035
10036
|
'videos': 'Video'
|
|
10036
10037
|
};
|
|
10037
10038
|
tableKeys.filter(tableKey => tableKey !== 'datastakeId').forEach(tableKey => {
|
|
10038
|
-
|
|
10039
|
+
var _dataLinkForm$identif;
|
|
10040
|
+
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]);
|
|
10039
10041
|
if (formInputConfig) {
|
|
10040
|
-
inputs[tableKey] = {
|
|
10041
|
-
...formInputConfig,
|
|
10042
|
+
inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
|
|
10042
10043
|
label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
|
|
10043
|
-
};
|
|
10044
|
+
});
|
|
10044
10045
|
if (formInputConfig.label && typeof formInputConfig.label === 'object') {
|
|
10045
10046
|
const dynamicLabelKeys = Object.keys(formInputConfig.label);
|
|
10046
10047
|
let resolvedLabel = null;
|
|
@@ -10048,7 +10049,7 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10048
10049
|
const parts = labelKey.split(' is ');
|
|
10049
10050
|
if (parts.length === 2) {
|
|
10050
10051
|
const [conditionKey, conditionValue] = parts;
|
|
10051
|
-
if (item
|
|
10052
|
+
if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
|
|
10052
10053
|
resolvedLabel = formInputConfig.label[labelKey];
|
|
10053
10054
|
break;
|
|
10054
10055
|
}
|
|
@@ -10056,37 +10057,37 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10056
10057
|
}
|
|
10057
10058
|
inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
|
|
10058
10059
|
}
|
|
10059
|
-
values[tableKey] = item
|
|
10060
|
+
values[tableKey] = item === null || item === void 0 ? void 0 : item[tableKey];
|
|
10060
10061
|
} else {
|
|
10062
|
+
var _item$linking;
|
|
10061
10063
|
inputs[tableKey] = {
|
|
10062
10064
|
label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
|
|
10063
|
-
type: inputConfig
|
|
10065
|
+
type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
|
|
10064
10066
|
};
|
|
10065
|
-
values[tableKey] = item
|
|
10067
|
+
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]);
|
|
10066
10068
|
}
|
|
10067
10069
|
});
|
|
10068
10070
|
siblingInputsMatchingTableKeys.forEach(siblingKey => {
|
|
10069
10071
|
const siblingConfig = config.inputs[siblingKey];
|
|
10070
10072
|
if (siblingConfig) {
|
|
10071
|
-
inputs[siblingKey] = {
|
|
10072
|
-
...siblingConfig,
|
|
10073
|
+
inputs[siblingKey] = _objectSpread2(_objectSpread2({}, siblingConfig), {}, {
|
|
10073
10074
|
label: siblingConfig.label || siblingKey
|
|
10074
|
-
};
|
|
10075
|
-
values[siblingKey] = item
|
|
10075
|
+
});
|
|
10076
|
+
values[siblingKey] = item === null || item === void 0 ? void 0 : item[siblingKey];
|
|
10076
10077
|
}
|
|
10077
10078
|
});
|
|
10078
|
-
if (dataLinkForm
|
|
10079
|
+
if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
|
|
10079
10080
|
Object.keys(dataLinkForm.identification).filter(fieldKey => fieldKey !== 'datastakeId' && !tableKeys.includes(fieldKey)).filter(fieldKey => {
|
|
10080
10081
|
const formInputConfig = dataLinkForm.identification[fieldKey];
|
|
10081
10082
|
return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
|
|
10082
10083
|
}).forEach(fieldKey => {
|
|
10084
|
+
var _item$linking2;
|
|
10083
10085
|
const formInputConfig = dataLinkForm.identification[fieldKey];
|
|
10084
|
-
inputs[fieldKey] = {
|
|
10085
|
-
...formInputConfig,
|
|
10086
|
+
inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
|
|
10086
10087
|
label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
|
|
10087
|
-
};
|
|
10088
|
-
if (formInputConfig
|
|
10089
|
-
const dynamicLabelKeys = Object.keys(formInputConfig
|
|
10088
|
+
});
|
|
10089
|
+
if (formInputConfig !== null && formInputConfig !== void 0 && formInputConfig.label && typeof (formInputConfig === null || formInputConfig === void 0 ? void 0 : formInputConfig.label) === 'object') {
|
|
10090
|
+
const dynamicLabelKeys = Object.keys(formInputConfig === null || formInputConfig === void 0 ? void 0 : formInputConfig.label);
|
|
10090
10091
|
let resolvedLabel = null;
|
|
10091
10092
|
for (const labelKey of dynamicLabelKeys) {
|
|
10092
10093
|
const parts = labelKey.split(' is ');
|
|
@@ -10095,7 +10096,7 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10095
10096
|
const flattenedItem = Object.assign({}, item.location, {
|
|
10096
10097
|
address: item.address
|
|
10097
10098
|
});
|
|
10098
|
-
if (flattenedItem
|
|
10099
|
+
if ((flattenedItem === null || flattenedItem === void 0 ? void 0 : flattenedItem[conditionKey]) === conditionValue) {
|
|
10099
10100
|
resolvedLabel = formInputConfig.label[labelKey];
|
|
10100
10101
|
break;
|
|
10101
10102
|
}
|
|
@@ -10103,7 +10104,7 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10103
10104
|
}
|
|
10104
10105
|
inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
|
|
10105
10106
|
}
|
|
10106
|
-
values[fieldKey] = item
|
|
10107
|
+
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]);
|
|
10107
10108
|
});
|
|
10108
10109
|
}
|
|
10109
10110
|
return {
|
|
@@ -10113,16 +10114,17 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10113
10114
|
};
|
|
10114
10115
|
if (Array.isArray(value)) {
|
|
10115
10116
|
return value.map((item, itemIndex) => {
|
|
10117
|
+
var _merged$inputKey;
|
|
10116
10118
|
const merged = mergeObject(item);
|
|
10117
|
-
const datastakeIdValue = merged
|
|
10119
|
+
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);
|
|
10118
10120
|
const {
|
|
10119
10121
|
inputs,
|
|
10120
10122
|
values
|
|
10121
10123
|
} = createInputsAndValues(merged);
|
|
10122
10124
|
return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
|
|
10123
|
-
nodeKey: datastakeIdValue || t(
|
|
10125
|
+
nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
|
|
10124
10126
|
config: {
|
|
10125
|
-
label: datastakeIdValue || t(
|
|
10127
|
+
label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
|
|
10126
10128
|
type: 'custom-datalink-group',
|
|
10127
10129
|
inputs: inputs
|
|
10128
10130
|
},
|
|
@@ -10136,11 +10138,12 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10136
10138
|
getApiBaseUrl: getApiBaseUrl,
|
|
10137
10139
|
getAppHeader: getAppHeader,
|
|
10138
10140
|
app: app
|
|
10139
|
-
},
|
|
10141
|
+
}, "".concat(inputKey, "-").concat(itemIndex));
|
|
10140
10142
|
});
|
|
10141
10143
|
} else {
|
|
10144
|
+
var _merged$inputKey2;
|
|
10142
10145
|
const merged = mergeObject(value);
|
|
10143
|
-
const datastakeIdValue = merged
|
|
10146
|
+
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);
|
|
10144
10147
|
const {
|
|
10145
10148
|
inputs,
|
|
10146
10149
|
values
|
|
@@ -10162,7 +10165,7 @@ const handleDataLinkGroupWithTableKeys = ({
|
|
|
10162
10165
|
getApiBaseUrl: getApiBaseUrl,
|
|
10163
10166
|
getAppHeader: getAppHeader,
|
|
10164
10167
|
app: app
|
|
10165
|
-
},
|
|
10168
|
+
}, "".concat(inputKey, "-group"));
|
|
10166
10169
|
}
|
|
10167
10170
|
};
|
|
10168
10171
|
|
|
@@ -10343,20 +10346,21 @@ const handleDataLinkWithTableKeys = ({
|
|
|
10343
10346
|
}
|
|
10344
10347
|
};
|
|
10345
10348
|
|
|
10346
|
-
const handleGroupChildren =
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10349
|
+
const handleGroupChildren = _ref => {
|
|
10350
|
+
let {
|
|
10351
|
+
config,
|
|
10352
|
+
value,
|
|
10353
|
+
allData,
|
|
10354
|
+
level,
|
|
10355
|
+
t,
|
|
10356
|
+
rootForm,
|
|
10357
|
+
user,
|
|
10358
|
+
getApiBaseUrl = () => {},
|
|
10359
|
+
getAppHeader = () => {},
|
|
10360
|
+
app,
|
|
10361
|
+
TreeNodeComponent
|
|
10362
|
+
} = _ref;
|
|
10363
|
+
if (!(config !== null && config !== void 0 && config.inputs)) {
|
|
10360
10364
|
return null;
|
|
10361
10365
|
}
|
|
10362
10366
|
const inputKeys = Object.keys(config.inputs);
|
|
@@ -10369,7 +10373,7 @@ const handleGroupChildren = ({
|
|
|
10369
10373
|
if (value && typeof value === 'object' && value[inputKey]) {
|
|
10370
10374
|
inputValue = value[inputKey];
|
|
10371
10375
|
} else {
|
|
10372
|
-
inputValue = allData
|
|
10376
|
+
inputValue = allData === null || allData === void 0 ? void 0 : allData[inputKey];
|
|
10373
10377
|
}
|
|
10374
10378
|
return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
|
|
10375
10379
|
nodeKey: inputKey,
|
|
@@ -12459,8 +12463,6 @@ const Style$M = styled__default["default"].div`
|
|
|
12459
12463
|
width: 100%;
|
|
12460
12464
|
height: 472px;
|
|
12461
12465
|
|
|
12462
|
-
|
|
12463
|
-
|
|
12464
12466
|
.filter-cont {
|
|
12465
12467
|
position: absolute;
|
|
12466
12468
|
top: 24px;
|
|
@@ -12563,24 +12565,11 @@ const Style$M = styled__default["default"].div`
|
|
|
12563
12565
|
align-items: center;
|
|
12564
12566
|
}
|
|
12565
12567
|
|
|
12566
|
-
|
|
12567
|
-
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12571
|
-
|
|
12572
|
-
.animated-polyline {
|
|
12573
|
-
stroke-dasharray: 10 10;
|
|
12574
|
-
animation: dash-flow 1.5s linear infinite;
|
|
12575
|
-
stroke-linecap: round;
|
|
12576
|
-
}
|
|
12577
|
-
|
|
12578
|
-
@keyframes dash-flow {
|
|
12579
|
-
to {
|
|
12580
|
-
stroke-dashoffset: -20;
|
|
12581
|
-
}
|
|
12582
|
-
}
|
|
12583
|
-
|
|
12568
|
+
.marker-chain {
|
|
12569
|
+
display: flex;
|
|
12570
|
+
align-items: center;
|
|
12571
|
+
justify-content: center;
|
|
12572
|
+
}
|
|
12584
12573
|
|
|
12585
12574
|
}
|
|
12586
12575
|
|
|
@@ -13026,15 +13015,18 @@ const VILLAGE = "village";
|
|
|
13026
13015
|
const EXPORTER = "exporter";
|
|
13027
13016
|
const PROCESSOR = "mineralProcessor";
|
|
13028
13017
|
const DEPOT = "depot";
|
|
13029
|
-
const OPERATOR = "miningOperator";
|
|
13030
13018
|
const MAX_EXTRA_SMALL_ZOOM_THRESHOLD = 2;
|
|
13031
13019
|
const MAX_SMALL_ZOOM_THRESHOLD = 3;
|
|
13032
13020
|
const MAX_MEDIUM_ZOOM_THRESHOLD = 6;
|
|
13033
13021
|
const LOCATION_TYPES = [MINE_SITE, VILLAGE];
|
|
13034
|
-
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT
|
|
13022
|
+
const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT];
|
|
13035
13023
|
const RADIUS_SMALL = 15;
|
|
13036
13024
|
const RADIUS_MEDIUM = 35;
|
|
13037
13025
|
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;
|
|
13038
13030
|
function isLocation(type) {
|
|
13039
13031
|
return LOCATION_TYPES.includes(type);
|
|
13040
13032
|
}
|
|
@@ -13091,6 +13083,7 @@ function getStakeholderPosition({
|
|
|
13091
13083
|
const isLarge = isLargeMarker(zoom);
|
|
13092
13084
|
let radius;
|
|
13093
13085
|
let center = {
|
|
13086
|
+
// NOT BEING USED FOR NOW AND MAYBE NEVER
|
|
13094
13087
|
left: 0,
|
|
13095
13088
|
top: 0
|
|
13096
13089
|
};
|
|
@@ -13114,25 +13107,6 @@ function getStakeholderPosition({
|
|
|
13114
13107
|
angleDeg
|
|
13115
13108
|
};
|
|
13116
13109
|
}
|
|
13117
|
-
function applyAnimationDirect(el, isShortLink) {
|
|
13118
|
-
if (!(el instanceof SVGElement) || isShortLink) return;
|
|
13119
|
-
el.style.strokeDasharray = "10, 10";
|
|
13120
|
-
el.style.strokeDashoffset = "0";
|
|
13121
|
-
el.style.animation = "dash-flow 1.2s linear infinite";
|
|
13122
|
-
el.classList.add('animated-polyline');
|
|
13123
|
-
}
|
|
13124
|
-
function removeAnimationFromElement(element) {
|
|
13125
|
-
if (!element) return;
|
|
13126
|
-
element.classList.remove('animated-polyline');
|
|
13127
|
-
element.style.animation = '';
|
|
13128
|
-
element.style.strokeDasharray = '';
|
|
13129
|
-
}
|
|
13130
|
-
function applyAnimationToPolyline(polyline, isShortLink) {
|
|
13131
|
-
const element = polyline.getElement();
|
|
13132
|
-
if (element) {
|
|
13133
|
-
applyAnimationDirect(element, isShortLink);
|
|
13134
|
-
}
|
|
13135
|
-
}
|
|
13136
13110
|
function createPolyline({
|
|
13137
13111
|
L,
|
|
13138
13112
|
startLatLng,
|
|
@@ -13142,48 +13116,110 @@ function createPolyline({
|
|
|
13142
13116
|
zoom,
|
|
13143
13117
|
listOfPolylines = [],
|
|
13144
13118
|
isFromStakeholder = false,
|
|
13145
|
-
isForceOpen = false
|
|
13146
|
-
stakeholderType = null,
|
|
13147
|
-
animated = false,
|
|
13148
|
-
mapRef
|
|
13119
|
+
isForceOpen = false
|
|
13149
13120
|
}) {
|
|
13150
|
-
const
|
|
13151
|
-
const
|
|
13152
|
-
const
|
|
13153
|
-
const lineCoordinates = [[startLatLng.lat, startLatLng.lng], [endLatLng.lat, endLatLng.lng]];
|
|
13154
|
-
const polylineStyle = {
|
|
13121
|
+
const width = isFromStakeholder && isExtraSmallMarker(zoom) && !isForceOpen ? 0 : 1.2;
|
|
13122
|
+
const coordinates = [[startLatLng.lat, startLatLng.lng], [endLatLng.lat, endLatLng.lng]];
|
|
13123
|
+
const style = {
|
|
13155
13124
|
color: "var(--base-gray-70)",
|
|
13156
|
-
weight:
|
|
13157
|
-
opacity:
|
|
13158
|
-
smoothFactor:
|
|
13125
|
+
weight: width,
|
|
13126
|
+
opacity: 0.5,
|
|
13127
|
+
smoothFactor: 1,
|
|
13159
13128
|
id,
|
|
13160
|
-
dashArray:
|
|
13161
|
-
renderer: L.svg()
|
|
13129
|
+
dashArray: !isSelected ? "5, 5" : "0, 0"
|
|
13162
13130
|
};
|
|
13163
|
-
const
|
|
13164
|
-
if (
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
13171
|
-
});
|
|
13172
|
-
applyAnimationToPolyline(existingPolyline, isShortLink);
|
|
13173
|
-
}
|
|
13174
|
-
return existingPolyline;
|
|
13175
|
-
}
|
|
13176
|
-
const newPolyline = L.polyline(lineCoordinates, polylineStyle);
|
|
13177
|
-
newPolyline.addTo(mapRef);
|
|
13178
|
-
listOfPolylines.push(newPolyline);
|
|
13179
|
-
if (shouldAnimate && isSelected) {
|
|
13180
|
-
newPolyline.once('add', () => {
|
|
13181
|
-
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
13182
|
-
});
|
|
13183
|
-
applyAnimationToPolyline(newPolyline, isShortLink);
|
|
13131
|
+
const newPolyline = L.polyline(coordinates, style);
|
|
13132
|
+
if (listOfPolylines.find(p => p.options.id === id)) {
|
|
13133
|
+
const polylineToUpdateCoordinates = listOfPolylines.find(p => p.options.id === id);
|
|
13134
|
+
polylineToUpdateCoordinates.setLatLngs(coordinates);
|
|
13135
|
+
polylineToUpdateCoordinates.setStyle(style);
|
|
13136
|
+
} else {
|
|
13137
|
+
listOfPolylines.push(newPolyline);
|
|
13184
13138
|
}
|
|
13185
13139
|
return newPolyline;
|
|
13186
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]);
|
|
13180
|
+
}
|
|
13181
|
+
path.push("C", [mapRef.layerPointToLatLng(cp1).lat, mapRef.layerPointToLatLng(cp1).lng], [mapRef.layerPointToLatLng(cp2).lat, mapRef.layerPointToLatLng(cp2).lng], [mapRef.layerPointToLatLng(p1).lat, mapRef.layerPointToLatLng(p1).lng]);
|
|
13182
|
+
}
|
|
13183
|
+
return path;
|
|
13184
|
+
}
|
|
13185
|
+
function getSiblingCurveStrength(zoom) {
|
|
13186
|
+
if (isExtraSmallMarker(zoom)) return RADIUS_CURVE_SMALL / 2;
|
|
13187
|
+
if (isSmallMarker(zoom)) return RADIUS_CURVE_MEDIUM;
|
|
13188
|
+
if (isMediumMarker(zoom)) return RADIUS_CURVE_LARGE;
|
|
13189
|
+
return RADIUS_CURVE_LARGE;
|
|
13190
|
+
}
|
|
13191
|
+
function buildCurveWIthTwoSiblings({
|
|
13192
|
+
mapRef,
|
|
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);
|
|
13222
|
+
}
|
|
13187
13223
|
|
|
13188
13224
|
const StakeholderMarker = styled__default["default"].div`
|
|
13189
13225
|
background-color: var(--blue-50);
|
|
@@ -13484,9 +13520,6 @@ function StakeholderIcon$1({
|
|
|
13484
13520
|
return null;
|
|
13485
13521
|
}, [parentId, allData]);
|
|
13486
13522
|
React.useEffect(() => {
|
|
13487
|
-
if (selectedMarkersId.length === 0 || !isSelected) {
|
|
13488
|
-
return;
|
|
13489
|
-
}
|
|
13490
13523
|
linkNodesData.map(node => {
|
|
13491
13524
|
const isConnectingToStakeholder = node.isStakeholder;
|
|
13492
13525
|
const id = `${data.datastakeId}-${node.stakeholderId || node.datastakeId}`;
|
|
@@ -13498,6 +13531,8 @@ function StakeholderIcon$1({
|
|
|
13498
13531
|
const stakeholderPoint = centerPoint.add(L__namespace.point(x, y));
|
|
13499
13532
|
const stakeholderLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
|
|
13500
13533
|
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;
|
|
13501
13536
|
if (isExtraSmallMarker(zoom) && !isForceOpen) {
|
|
13502
13537
|
createPolyline({
|
|
13503
13538
|
L: L__namespace,
|
|
@@ -13507,8 +13542,7 @@ function StakeholderIcon$1({
|
|
|
13507
13542
|
zoom,
|
|
13508
13543
|
isSelected,
|
|
13509
13544
|
id,
|
|
13510
|
-
listOfPolylines: polylinesRef.current
|
|
13511
|
-
animated: true
|
|
13545
|
+
listOfPolylines: polylinesRef.current
|
|
13512
13546
|
});
|
|
13513
13547
|
return;
|
|
13514
13548
|
}
|
|
@@ -13526,8 +13560,61 @@ function StakeholderIcon$1({
|
|
|
13526
13560
|
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
13527
13561
|
const endPoint = L__namespace.point(x + nodePoint.x + center.left, y + nodePoint.y + center.top);
|
|
13528
13562
|
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
|
+
}
|
|
13529
13617
|
}
|
|
13530
|
-
// Always use straight lines
|
|
13531
13618
|
createPolyline({
|
|
13532
13619
|
L: L__namespace,
|
|
13533
13620
|
mapRef,
|
|
@@ -13537,11 +13624,10 @@ function StakeholderIcon$1({
|
|
|
13537
13624
|
isFromStakeholder: false,
|
|
13538
13625
|
isSelected,
|
|
13539
13626
|
id,
|
|
13540
|
-
listOfPolylines: polylinesRef.current
|
|
13541
|
-
animated: true
|
|
13627
|
+
listOfPolylines: polylinesRef.current
|
|
13542
13628
|
});
|
|
13543
13629
|
});
|
|
13544
|
-
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen
|
|
13630
|
+
}, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen]);
|
|
13545
13631
|
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
13546
13632
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
|
|
13547
13633
|
content: renderTooltipJsx({
|
|
@@ -13553,8 +13639,7 @@ function StakeholderIcon$1({
|
|
|
13553
13639
|
link,
|
|
13554
13640
|
onClickLink: () => {
|
|
13555
13641
|
onClickLink(data);
|
|
13556
|
-
}
|
|
13557
|
-
isNewTab: true
|
|
13642
|
+
}
|
|
13558
13643
|
}),
|
|
13559
13644
|
getPopupContainer: triggerNode => {
|
|
13560
13645
|
const mapElement = document.getElementById("map");
|
|
@@ -13609,8 +13694,6 @@ function LocationIcon({
|
|
|
13609
13694
|
const linkedNodesData = React.useMemo(() => {
|
|
13610
13695
|
const nodes = [];
|
|
13611
13696
|
const links = data.links || [];
|
|
13612
|
-
|
|
13613
|
-
// Add links from the location itself
|
|
13614
13697
|
links.forEach(link => {
|
|
13615
13698
|
allData.forEach(d => {
|
|
13616
13699
|
if (d.datastakeId === link) {
|
|
@@ -13630,45 +13713,8 @@ function LocationIcon({
|
|
|
13630
13713
|
}
|
|
13631
13714
|
});
|
|
13632
13715
|
});
|
|
13633
|
-
|
|
13634
|
-
// ADD: Also include links from this location's stakeholders
|
|
13635
|
-
const stakeholders = data.stakeholders || [];
|
|
13636
|
-
stakeholders.forEach(stakeholder => {
|
|
13637
|
-
const stakeholderLinks = stakeholder.links || [];
|
|
13638
|
-
stakeholderLinks.forEach(link => {
|
|
13639
|
-
allData.forEach(d => {
|
|
13640
|
-
// Check if it's a direct location link
|
|
13641
|
-
if (d.datastakeId === link) {
|
|
13642
|
-
// Avoid duplicates
|
|
13643
|
-
if (!nodes.find(n => n.datastakeId === link && !n.isStakeholder)) {
|
|
13644
|
-
nodes.push({
|
|
13645
|
-
...d,
|
|
13646
|
-
fromStakeholderId: stakeholder.datastakeId
|
|
13647
|
-
});
|
|
13648
|
-
}
|
|
13649
|
-
}
|
|
13650
|
-
// Check if it's a stakeholder link
|
|
13651
|
-
if (d.stakeholders && d.stakeholders.length > 0) {
|
|
13652
|
-
d.stakeholders.forEach(targetStakeholder => {
|
|
13653
|
-
if (targetStakeholder.datastakeId === link) {
|
|
13654
|
-
// Avoid duplicates
|
|
13655
|
-
if (!nodes.find(n => n.isStakeholder && n.datastakeId === d.datastakeId && n.stakeholdersIndex === d.stakeholders.indexOf(targetStakeholder))) {
|
|
13656
|
-
nodes.push({
|
|
13657
|
-
...d,
|
|
13658
|
-
isStakeholder: true,
|
|
13659
|
-
totalStakeholders: d.stakeholders.length,
|
|
13660
|
-
stakeholdersIndex: d.stakeholders.indexOf(targetStakeholder),
|
|
13661
|
-
fromStakeholderId: stakeholder.datastakeId
|
|
13662
|
-
});
|
|
13663
|
-
}
|
|
13664
|
-
}
|
|
13665
|
-
});
|
|
13666
|
-
}
|
|
13667
|
-
});
|
|
13668
|
-
});
|
|
13669
|
-
});
|
|
13670
13716
|
return nodes;
|
|
13671
|
-
}, [JSON.stringify(allData), JSON.stringify(data.links),
|
|
13717
|
+
}, [JSON.stringify(allData), JSON.stringify(data.links), zoom]);
|
|
13672
13718
|
const stakeholdersOfLocation = React.useMemo(() => {
|
|
13673
13719
|
return data?.stakeholders || [];
|
|
13674
13720
|
}, [data.stakeholders, zoom]);
|
|
@@ -13686,13 +13732,7 @@ function LocationIcon({
|
|
|
13686
13732
|
currentRoots.clear();
|
|
13687
13733
|
markersRef.current = [];
|
|
13688
13734
|
|
|
13689
|
-
//
|
|
13690
|
-
const shouldShowStakeholders = isSelected || stakeholdersOfLocation.some(stk => selectedMarkersId.includes(stk.datastakeId));
|
|
13691
|
-
if (!shouldShowStakeholders || selectedMarkersId.length === 0) {
|
|
13692
|
-
return;
|
|
13693
|
-
}
|
|
13694
|
-
|
|
13695
|
-
// Create new markers only when selected
|
|
13735
|
+
// Create new markers
|
|
13696
13736
|
stakeholdersOfLocation.forEach((stakeholder, index) => {
|
|
13697
13737
|
const markerId = `${stakeholder.datastakeId}`;
|
|
13698
13738
|
const {
|
|
@@ -13778,9 +13818,7 @@ function LocationIcon({
|
|
|
13778
13818
|
zoom,
|
|
13779
13819
|
isFromStakeholder: true,
|
|
13780
13820
|
isForceOpen,
|
|
13781
|
-
listOfPolylines: polylinesRef.current
|
|
13782
|
-
stakeholderType: stakeholder.type,
|
|
13783
|
-
animated: true
|
|
13821
|
+
listOfPolylines: polylinesRef.current
|
|
13784
13822
|
});
|
|
13785
13823
|
});
|
|
13786
13824
|
return () => {
|
|
@@ -13795,88 +13833,38 @@ function LocationIcon({
|
|
|
13795
13833
|
rootsMapRef.current.clear();
|
|
13796
13834
|
markersRef.current = [];
|
|
13797
13835
|
};
|
|
13798
|
-
}, [stakeholdersOfLocation, selectedMarkersId, activeMarker
|
|
13799
|
-
|
|
13800
|
-
|
|
13801
|
-
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
}
|
|
13811
|
-
|
|
13812
|
-
// Filter linkedNodesData to only include nodes that are in the selected chain
|
|
13813
|
-
const relevantLinks = linkedNodesData.filter(node => {
|
|
13814
|
-
// Check if the target node (location) is in the selected markers
|
|
13815
|
-
const targetLocationInSelection = selectedMarkersId.includes(node.datastakeId);
|
|
13816
|
-
|
|
13817
|
-
// If connecting to a stakeholder, check if that stakeholder is selected
|
|
13818
|
-
if (node.isStakeholder) {
|
|
13819
|
-
const stakeholderInSelection = node.stakeholdersIndex !== undefined && selectedMarkersId.includes(node.datastakeId);
|
|
13820
|
-
return stakeholderInSelection;
|
|
13821
|
-
}
|
|
13822
|
-
return targetLocationInSelection;
|
|
13823
|
-
});
|
|
13824
|
-
relevantLinks.forEach(node => {
|
|
13825
|
-
const id = node.fromStakeholderId ? `${node.fromStakeholderId}-${node.datastakeId}` : `${data.datastakeId}-${node.datastakeId}`;
|
|
13826
|
-
const isConnectingToStakeholder = node.isStakeholder;
|
|
13827
|
-
|
|
13828
|
-
// If the link is from a stakeholder, start from the stakeholder position
|
|
13829
|
-
let startLatLng;
|
|
13830
|
-
if (node.fromStakeholderId) {
|
|
13831
|
-
// Find the stakeholder index in this location's stakeholders
|
|
13832
|
-
const stakeholderIndex = stakeholdersOfLocation.findIndex(s => s.datastakeId === node.fromStakeholderId);
|
|
13833
|
-
if (stakeholderIndex !== -1) {
|
|
13834
|
-
const {
|
|
13835
|
-
x,
|
|
13836
|
-
y
|
|
13837
|
-
} = getStakeholderPosition({
|
|
13838
|
-
zoom,
|
|
13839
|
-
totalMarkers: stakeholdersOfLocation.length,
|
|
13840
|
-
markerIndex: stakeholderIndex
|
|
13841
|
-
});
|
|
13842
|
-
const centerLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
13843
|
-
const centerPoint = mapRef.latLngToLayerPoint(centerLatLng);
|
|
13844
|
-
const stakeholderPoint = centerPoint.add(L__namespace.point(x, y));
|
|
13845
|
-
startLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
|
|
13846
|
-
} else {
|
|
13847
|
-
startLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
13848
|
-
}
|
|
13849
|
-
} else {
|
|
13850
|
-
startLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
13851
|
-
}
|
|
13852
|
-
let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
13853
|
-
const isConnectingToStakeholderSelected = selectedMarkersId.includes(node.datastakeId);
|
|
13854
|
-
if (isConnectingToStakeholder && !isExtraSmallMarker(zoom)) {
|
|
13855
|
-
const {
|
|
13856
|
-
x,
|
|
13857
|
-
y
|
|
13858
|
-
} = getStakeholderPosition({
|
|
13859
|
-
zoom,
|
|
13860
|
-
totalMarkers: node.totalStakeholders,
|
|
13861
|
-
markerIndex: node.stakeholdersIndex
|
|
13862
|
-
});
|
|
13863
|
-
const nodeLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
13864
|
-
const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
|
|
13865
|
-
const endPoint = L__namespace.point(x + nodePoint.x, y + nodePoint.y);
|
|
13866
|
-
endLatLng = mapRef.layerPointToLatLng(endPoint);
|
|
13867
|
-
}
|
|
13868
|
-
createPolyline({
|
|
13869
|
-
L: L__namespace,
|
|
13870
|
-
mapRef,
|
|
13871
|
-
startLatLng,
|
|
13872
|
-
endLatLng,
|
|
13873
|
-
isSelected: isConnectingToStakeholderSelected,
|
|
13874
|
-
id,
|
|
13836
|
+
}, [stakeholdersOfLocation, selectedMarkersId, activeMarker]);
|
|
13837
|
+
linkedNodesData.map(node => {
|
|
13838
|
+
const id = `${data.datastakeId}-${node.datastakeId}`;
|
|
13839
|
+
const isConnectingToStakeholder = node.isStakeholder;
|
|
13840
|
+
const centerLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
|
|
13841
|
+
let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
|
|
13842
|
+
const isConnectingToStakeholderSelected = selectedMarkersId.includes(node.datastakeId);
|
|
13843
|
+
if (isConnectingToStakeholder && !isExtraSmallMarker(zoom)) {
|
|
13844
|
+
const {
|
|
13845
|
+
x,
|
|
13846
|
+
y
|
|
13847
|
+
} = getStakeholderPosition({
|
|
13875
13848
|
zoom,
|
|
13876
|
-
|
|
13877
|
-
|
|
13849
|
+
totalMarkers: node.totalStakeholders,
|
|
13850
|
+
markerIndex: node.stakeholdersIndex
|
|
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
|
|
13878
13866
|
});
|
|
13879
|
-
}
|
|
13867
|
+
});
|
|
13880
13868
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
|
|
13881
13869
|
content: renderTooltipJsx({
|
|
13882
13870
|
title: data.name,
|
|
@@ -14392,8 +14380,7 @@ function useMapHelper$1({
|
|
|
14392
14380
|
link: link,
|
|
14393
14381
|
onClickLink: onClickLink,
|
|
14394
14382
|
activeStakeholder: activeStakeholder,
|
|
14395
|
-
setActiveStakeholder: setActiveStakeholder
|
|
14396
|
-
mapRef: mapRef
|
|
14383
|
+
setActiveStakeholder: setActiveStakeholder
|
|
14397
14384
|
}));
|
|
14398
14385
|
roots.current.push(root);
|
|
14399
14386
|
} else if (type === "location") {
|
|
@@ -14598,8 +14585,7 @@ const useMap$1 = ({
|
|
|
14598
14585
|
MAP_TOKEN
|
|
14599
14586
|
} = useMapConfig({
|
|
14600
14587
|
app,
|
|
14601
|
-
isSatellite
|
|
14602
|
-
mapRef: container
|
|
14588
|
+
isSatellite
|
|
14603
14589
|
});
|
|
14604
14590
|
const [initialMarkerSetIsDone, setInitialMarkerSetIsDone] = React.useState(false);
|
|
14605
14591
|
const [mapCenter, setMapCenter] = React.useState([0, 0]);
|
|
@@ -14616,8 +14602,6 @@ const useMap$1 = ({
|
|
|
14616
14602
|
const graph = new Map();
|
|
14617
14603
|
const stakeToLoc = new Map();
|
|
14618
14604
|
const nodeTypes = new Map();
|
|
14619
|
-
|
|
14620
|
-
// Build the graph
|
|
14621
14605
|
for (const loc of data) {
|
|
14622
14606
|
const locId = loc.datastakeId;
|
|
14623
14607
|
nodeTypes.set(locId, loc.type);
|
|
@@ -14642,45 +14626,26 @@ const useMap$1 = ({
|
|
|
14642
14626
|
}
|
|
14643
14627
|
}
|
|
14644
14628
|
const highlightTable = {};
|
|
14645
|
-
|
|
14646
|
-
// Perform BFS/DFS to find all connected nodes in the entire chain
|
|
14647
14629
|
for (const [node] of graph) {
|
|
14648
14630
|
const highlighted = new Set();
|
|
14649
|
-
|
|
14650
|
-
const
|
|
14651
|
-
|
|
14652
|
-
const
|
|
14653
|
-
highlighted.add(
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
const
|
|
14657
|
-
if (
|
|
14658
|
-
const
|
|
14659
|
-
if (
|
|
14660
|
-
highlighted.add(parentLoc);
|
|
14661
|
-
visited.add(parentLoc);
|
|
14662
|
-
queue.push(parentLoc);
|
|
14663
|
-
}
|
|
14664
|
-
}
|
|
14665
|
-
|
|
14666
|
-
// Traverse all neighbors
|
|
14667
|
-
for (const neighbor of graph.get(current) || []) {
|
|
14668
|
-
if (!visited.has(neighbor)) {
|
|
14669
|
-
visited.add(neighbor);
|
|
14670
|
-
queue.push(neighbor);
|
|
14631
|
+
highlighted.add(node);
|
|
14632
|
+
const nodeIsStakeholder = !isLocation(nodeTypes.get(node));
|
|
14633
|
+
if (nodeIsStakeholder && stakeToLoc.has(node)) {
|
|
14634
|
+
const parentLoc = stakeToLoc.get(node);
|
|
14635
|
+
highlighted.add(parentLoc);
|
|
14636
|
+
}
|
|
14637
|
+
for (const neighbor of graph.get(node) || []) {
|
|
14638
|
+
const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
|
|
14639
|
+
if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
|
|
14640
|
+
const neighborParent = stakeToLoc.get(neighbor);
|
|
14641
|
+
if (isLocation(nodeTypes.get(node)) && neighborParent === node || nodeIsStakeholder && stakeToLoc.get(node) === neighborParent) {
|
|
14671
14642
|
highlighted.add(neighbor);
|
|
14672
|
-
|
|
14673
|
-
|
|
14674
|
-
|
|
14675
|
-
if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
|
|
14676
|
-
const neighborParent = stakeToLoc.get(neighbor);
|
|
14677
|
-
if (!visited.has(neighborParent)) {
|
|
14678
|
-
highlighted.add(neighborParent);
|
|
14679
|
-
visited.add(neighborParent);
|
|
14680
|
-
queue.push(neighborParent);
|
|
14681
|
-
}
|
|
14682
|
-
}
|
|
14643
|
+
} else {
|
|
14644
|
+
highlighted.add(neighbor);
|
|
14645
|
+
highlighted.add(neighborParent);
|
|
14683
14646
|
}
|
|
14647
|
+
} else {
|
|
14648
|
+
highlighted.add(neighbor);
|
|
14684
14649
|
}
|
|
14685
14650
|
}
|
|
14686
14651
|
highlightTable[node] = [...highlighted];
|
|
@@ -14718,20 +14683,10 @@ const useMap$1 = ({
|
|
|
14718
14683
|
function handleSelectMarker(clickedMarker) {
|
|
14719
14684
|
setSelectedMarkersId(prev => {
|
|
14720
14685
|
if (prev.includes(clickedMarker.datastakeId)) {
|
|
14721
|
-
// Deselecting - clear polylines
|
|
14722
14686
|
openPopupIdRef.current = null;
|
|
14723
14687
|
setMarkerWithPopup(null);
|
|
14724
14688
|
return [];
|
|
14725
14689
|
} else {
|
|
14726
|
-
// CLEAR OLD POLYLINES BEFORE SELECTING NEW MARKER
|
|
14727
|
-
if (polylinesRef.current.length > 0) {
|
|
14728
|
-
polylinesRef.current.forEach(polyline => {
|
|
14729
|
-
if (mapRef.hasLayer(polyline)) {
|
|
14730
|
-
mapRef.removeLayer(polyline);
|
|
14731
|
-
}
|
|
14732
|
-
});
|
|
14733
|
-
polylinesRef.current = [];
|
|
14734
|
-
}
|
|
14735
14690
|
setMarkerWithPopup(isStakeholder(clickedMarker.type) ? clickedMarker : null);
|
|
14736
14691
|
const newSelectedMarkersId = highlightTable[clickedMarker.datastakeId];
|
|
14737
14692
|
openPopupIdRef.current = clickedMarker.datastakeId;
|
|
@@ -14755,29 +14710,19 @@ const useMap$1 = ({
|
|
|
14755
14710
|
});
|
|
14756
14711
|
}
|
|
14757
14712
|
}
|
|
14758
|
-
if (type === "chain" && selectedMarkersId.length === 0) {
|
|
14759
|
-
if (polylinesRef.current.length) {
|
|
14760
|
-
polylinesRef.current.forEach(polyline => {
|
|
14761
|
-
if (mapRef.hasLayer(polyline)) {
|
|
14762
|
-
mapRef.removeLayer(polyline);
|
|
14763
|
-
}
|
|
14764
|
-
});
|
|
14765
|
-
polylinesRef.current = [];
|
|
14766
|
-
}
|
|
14767
|
-
}
|
|
14768
14713
|
clearMapMarkers();
|
|
14769
14714
|
if (data) {
|
|
14770
|
-
|
|
14715
|
+
// Filters out locations that are not connected to any stakeholders
|
|
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)))));
|
|
14771
14718
|
const maxTotal = Math.max(...(data || []).map(d => d.total));
|
|
14772
14719
|
const dataToRender = type === "chain" ? filteredData : data;
|
|
14773
14720
|
dataToRender.forEach((d, i) => {
|
|
14774
14721
|
addIconToMapInitialy([d?.marker?.lat, d?.marker?.lng], "location", d.category || "mineSite", d, maxTotal, i);
|
|
14775
14722
|
});
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
});
|
|
14780
|
-
}
|
|
14723
|
+
polylinesRef.current.forEach(polyline => {
|
|
14724
|
+
mapRef.addLayer(polyline);
|
|
14725
|
+
});
|
|
14781
14726
|
mapRef.invalidateSize();
|
|
14782
14727
|
mapRef.fire("moveend");
|
|
14783
14728
|
}
|