datastake-daf 0.6.778 → 0.6.780

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.
Files changed (25) hide show
  1. package/dist/components/index.js +403 -355
  2. package/dist/pages/index.js +2120 -235
  3. package/dist/utils/index.js +13 -0
  4. package/package.json +1 -1
  5. package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +9 -76
  6. package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +116 -8
  7. package/src/@daf/core/components/Dashboard/Map/ChainIcon/utils.js +73 -17
  8. package/src/@daf/core/components/Dashboard/Map/helper.js +1 -0
  9. package/src/@daf/core/components/Dashboard/Map/hook.js +64 -29
  10. package/src/@daf/core/components/Dashboard/Map/style.js +20 -5
  11. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/AssociatedInformation/config.js +4 -2
  12. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/AssociatedInformation/index.jsx +1 -0
  13. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/PlantingLocations/index.jsx +60 -4
  14. package/src/@daf/pages/View/hooks/useCallToGetData.js +73 -0
  15. package/src/@daf/pages/View/hooks/usePrepareForm.js +86 -0
  16. package/src/@daf/pages/View/hooks/useSubmitSubject.js +40 -0
  17. package/src/@daf/pages/View/hooks/useViewActions.js +83 -0
  18. package/src/@daf/pages/View/hooks/useViewPermissions.js +75 -0
  19. package/src/@daf/pages/View/hooks/useViewUrlParams.js +93 -0
  20. package/src/@daf/pages/View/index.jsx +286 -0
  21. package/src/@daf/utils/object.js +3 -1
  22. package/src/pages.js +4 -1
  23. package/src/utils.js +1 -1
  24. package/dist/style/datastake/mapbox-gl.css +0 -330
  25. package/src/@daf/hooks/useViewFormUrlParams.js +0 -84
@@ -8486,20 +8486,22 @@ const useHeader = _ref => {
8486
8486
  const {
8487
8487
  useToken: useToken$m
8488
8488
  } = antd.theme;
8489
- function BreadCrumbs({
8490
- breadcrumbs = [],
8491
- mainContWidth = 0
8492
- }) {
8489
+ function BreadCrumbs(_ref) {
8490
+ let {
8491
+ breadcrumbs = [],
8492
+ mainContWidth = 0
8493
+ } = _ref;
8493
8494
  const [splitIndex, setSplitIndex] = React.useState(0);
8494
8495
  const {
8495
8496
  token
8496
8497
  } = useToken$m();
8497
- const _renderBreadcrumb = (b, i, isLast, noOnClickLast = false) => {
8498
+ const _renderBreadcrumb = function (b, i, isLast) {
8499
+ let noOnClickLast = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
8498
8500
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
8499
8501
  className: "flex breadcrumb-item",
8500
- onClick: noOnClickLast && isLast ? undefined : b?.onClick,
8502
+ onClick: noOnClickLast && isLast ? undefined : b === null || b === void 0 ? void 0 : b.onClick,
8501
8503
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
8502
- children: b?.label
8504
+ children: b === null || b === void 0 ? void 0 : b.label
8503
8505
  }), !isLast && /*#__PURE__*/jsxRuntime.jsx("div", {
8504
8506
  className: "flex flex-column justify-content-center",
8505
8507
  children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
@@ -8509,7 +8511,7 @@ function BreadCrumbs({
8509
8511
  color: token.baseGray50
8510
8512
  })
8511
8513
  })]
8512
- }, `breadcrumb-item-${i}`);
8514
+ }, "breadcrumb-item-".concat(i));
8513
8515
  };
8514
8516
  React.useEffect(() => {
8515
8517
  const _placeholderCont = document.getElementById("header-breadcrumbs");
@@ -8552,7 +8554,7 @@ function BreadCrumbs({
8552
8554
  placement: "bottomRight",
8553
8555
  menu: {
8554
8556
  items: groupedBreadCrumbs[2].map((it, i) => ({
8555
- key: `items-${i}`,
8557
+ key: "items-".concat(i),
8556
8558
  label: it.label,
8557
8559
  onClick: it.onClick
8558
8560
  }))
@@ -9544,29 +9546,24 @@ const processConditionalTableKeys = (tableKeys, item) => {
9544
9546
  });
9545
9547
  return processedKeys;
9546
9548
  };
9547
- const renderFieldData = function (type, value, user, config) {
9548
- let getApiBaseUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : () => {};
9549
- let getAppHeader = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : () => {};
9550
- let app = arguments.length > 6 ? arguments[6] : undefined;
9551
- let allValues = arguments.length > 7 ? arguments[7] : undefined;
9552
- let formValues = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : {};
9549
+ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, getAppHeader = () => {}, app, allValues, formValues = {}) => {
9553
9550
  switch (type) {
9554
9551
  case 'year':
9555
9552
  return value !== '-' ? renderDateFormatted(value, 'YYYY', 'en') : '-';
9556
9553
  case 'date':
9557
9554
  {
9558
- const language = user !== null && user !== void 0 && user.language && (user === null || user === void 0 ? void 0 : user.language) === 'sp' ? 'es' : user === null || user === void 0 ? void 0 : user.language;
9555
+ const language = user?.language && user?.language === 'sp' ? 'es' : user?.language;
9559
9556
  return value !== '-' ? renderDateFormatted(value, 'DD MMM YYYY', language || 'en') : '-';
9560
9557
  }
9561
9558
  case 'select':
9562
9559
  {
9563
- const options = (config === null || config === void 0 ? void 0 : config.options) || [];
9560
+ const options = config?.options || [];
9564
9561
  const option = findOptions(value, options);
9565
9562
  return option;
9566
9563
  }
9567
9564
  case 'multiselect':
9568
9565
  {
9569
- const options = (config === null || config === void 0 ? void 0 : config.options) || [];
9566
+ const options = config?.options || [];
9570
9567
  const _val = typeof value === 'string' ? value.split(',').map(v => v.trim()) : value;
9571
9568
  const option = findOptions(_val, options);
9572
9569
  return option.join(', ');
@@ -9581,7 +9578,7 @@ const renderFieldData = function (type, value, user, config) {
9581
9578
  formValues: formValues
9582
9579
  });
9583
9580
  case 'percentage':
9584
- return value === '-' || value === null || value === undefined ? '-' : "".concat(value, " %");
9581
+ return value === '-' || value === null || value === undefined ? '-' : `${value} %`;
9585
9582
  case 'geolocation':
9586
9583
  {
9587
9584
  const val = JSON.parse(value) || {};
@@ -9595,7 +9592,7 @@ const renderFieldData = function (type, value, user, config) {
9595
9592
  case 'upload':
9596
9593
  case 'videoUpload':
9597
9594
  {
9598
- const documentName = allValues === null || allValues === void 0 ? void 0 : allValues.map(item => item === null || item === void 0 ? void 0 : item.name).join(', ');
9595
+ const documentName = allValues?.map(item => item?.name).join(', ');
9599
9596
  return documentName;
9600
9597
  }
9601
9598
  default:
@@ -9603,27 +9600,25 @@ const renderFieldData = function (type, value, user, config) {
9603
9600
  }
9604
9601
  };
9605
9602
 
9606
- const renderValue = _ref => {
9607
- let {
9608
- value,
9609
- hasChildren,
9610
- config,
9611
- user,
9612
- getApiBaseUrl = () => {},
9613
- getAppHeader = () => {},
9614
- app,
9615
- allData = {}
9616
- } = _ref;
9617
- if ((config === null || config === void 0 ? void 0 : config.type) === 'groupInputs') {
9618
- if (!(config !== null && config !== void 0 && config.inputs)) return null;
9603
+ const renderValue = ({
9604
+ value,
9605
+ hasChildren,
9606
+ config,
9607
+ user,
9608
+ getApiBaseUrl = () => {},
9609
+ getAppHeader = () => {},
9610
+ app,
9611
+ allData = {}
9612
+ }) => {
9613
+ if (config?.type === 'groupInputs') {
9614
+ if (!config?.inputs) return null;
9619
9615
  const inputKeys = Object.keys(config.inputs).sort((a, b) => {
9620
- var _config$inputs$a, _config$inputs$b;
9621
- const positionA = ((_config$inputs$a = config.inputs[a]) === null || _config$inputs$a === void 0 ? void 0 : _config$inputs$a.position) || 0;
9622
- const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
9616
+ const positionA = config.inputs[a]?.position || 0;
9617
+ const positionB = config.inputs[b]?.position || 0;
9623
9618
  return positionA - positionB;
9624
9619
  });
9625
9620
  const values = inputKeys.map(inputKey => {
9626
- let inputValue = value === null || value === void 0 ? void 0 : value[inputKey];
9621
+ let inputValue = value?.[inputKey];
9627
9622
  if (inputValue === null || inputValue === undefined || inputValue === '') {
9628
9623
  return '';
9629
9624
  } else if (typeof inputValue === 'object' && inputValue !== null) {
@@ -9664,8 +9659,8 @@ const renderValue = _ref => {
9664
9659
  } else {
9665
9660
  displayValue = String(value);
9666
9661
  }
9667
- const fieldType = (config === null || config === void 0 ? void 0 : config.type) || 'text';
9668
- let cssClass = "tree-value ".concat(fieldType, "-type");
9662
+ const fieldType = config?.type || 'text';
9663
+ let cssClass = `tree-value ${fieldType}-type`;
9669
9664
  if (displayValue === '-') {
9670
9665
  cssClass += ' empty';
9671
9666
  }
@@ -9675,21 +9670,19 @@ const renderValue = _ref => {
9675
9670
  children: displayValue
9676
9671
  });
9677
9672
  };
9678
- const determineHasChildren = _ref2 => {
9679
- var _config$meta;
9680
- let {
9681
- config,
9682
- level
9683
- } = _ref2;
9684
- if ((config === null || config === void 0 ? void 0 : config.type) === 'groupInputs') {
9673
+ const determineHasChildren = ({
9674
+ config,
9675
+ level
9676
+ }) => {
9677
+ if (config?.type === 'groupInputs') {
9685
9678
  return false;
9686
9679
  }
9687
- if ((config === null || config === void 0 ? void 0 : config.type) === 'header' && config !== null && config !== void 0 && config.inputs && Object.keys(config.inputs).length > 0) {
9680
+ if (config?.type === 'header' && config?.inputs && Object.keys(config.inputs).length > 0) {
9688
9681
  return true;
9689
9682
  }
9690
- return (config === null || config === void 0 ? void 0 : config.inputs) || (config === null || config === void 0 ? void 0 : config.type) === 'group' || (config === null || config === void 0 ? void 0 : config.type) === 'dataLinkGroup' || (config === null || config === void 0 ? void 0 : config.type) === 'section' || (config === null || config === void 0 ? void 0 : config.type) === 'ajaxSubGroup' ||
9683
+ return config?.inputs || config?.type === 'group' || config?.type === 'dataLinkGroup' || config?.type === 'section' || config?.type === 'ajaxSubGroup' ||
9691
9684
  // Add this line
9692
- (config === null || config === void 0 ? void 0 : config.type) === 'dataLink' && (config === null || config === void 0 || (_config$meta = config.meta) === null || _config$meta === void 0 ? void 0 : _config$meta.tableKeys) || level === 0 && config && typeof config === 'object' && Object.keys(config).some(key => key !== 'id' && key !== 'label' && key !== 'position' && key !== 'subTitle' && typeof config[key] === 'object' && config[key] !== null);
9685
+ config?.type === 'dataLink' && config?.meta?.tableKeys || level === 0 && config && typeof config === 'object' && Object.keys(config).some(key => key !== 'id' && key !== 'label' && key !== 'position' && key !== 'subTitle' && typeof config[key] === 'object' && config[key] !== null);
9693
9686
  };
9694
9687
 
9695
9688
  const sortByPosition = (items, getConfig) => {
@@ -9723,18 +9716,19 @@ const resolveDynamicLabel = (labelConfig, item, defaultLabel) => {
9723
9716
  return labelConfig || defaultLabel;
9724
9717
  };
9725
9718
 
9726
- const handleSectionChildren = ({
9727
- config,
9728
- allData,
9729
- level,
9730
- t,
9731
- rootForm,
9732
- user,
9733
- getApiBaseUrl = () => {},
9734
- getAppHeader = () => {},
9735
- app,
9736
- TreeNodeComponent
9737
- }) => {
9719
+ const handleSectionChildren = _ref => {
9720
+ let {
9721
+ config,
9722
+ allData,
9723
+ level,
9724
+ t,
9725
+ rootForm,
9726
+ user,
9727
+ getApiBaseUrl = () => {},
9728
+ getAppHeader = () => {},
9729
+ app,
9730
+ TreeNodeComponent
9731
+ } = _ref;
9738
9732
  if (!(level === 0 && config && typeof config === 'object')) {
9739
9733
  return null;
9740
9734
  }
@@ -9748,14 +9742,14 @@ const handleSectionChildren = ({
9748
9742
  let fieldValue;
9749
9743
 
9750
9744
  // Determine field value based on type
9751
- if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData?.[fieldKey])) {
9745
+ if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData === null || allData === void 0 ? void 0 : allData[fieldKey])) {
9752
9746
  fieldValue = allData[fieldKey];
9753
- } else if (fieldConfig.type === 'dataLinkGroup' && allData?.[fieldKey]) {
9747
+ } else if (fieldConfig.type === 'dataLinkGroup' && allData !== null && allData !== void 0 && allData[fieldKey]) {
9754
9748
  fieldValue = allData[fieldKey];
9755
9749
  } else if (fieldConfig.type === 'group') {
9756
9750
  fieldValue = {};
9757
9751
  } else {
9758
- fieldValue = allData?.[fieldKey];
9752
+ fieldValue = allData === null || allData === void 0 ? void 0 : allData[fieldKey];
9759
9753
  }
9760
9754
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
9761
9755
  nodeKey: fieldKey,
@@ -9774,28 +9768,30 @@ const handleSectionChildren = ({
9774
9768
  });
9775
9769
  };
9776
9770
 
9777
- const handleArrayChildren = ({
9778
- value,
9779
- config,
9780
- label,
9781
- level,
9782
- t,
9783
- rootForm,
9784
- allData,
9785
- user,
9786
- getApiBaseUrl = () => {},
9787
- getAppHeader = () => {},
9788
- app,
9789
- TreeNodeComponent
9790
- }) => {
9771
+ const handleArrayChildren = _ref => {
9772
+ let {
9773
+ value,
9774
+ config,
9775
+ label,
9776
+ level,
9777
+ t,
9778
+ rootForm,
9779
+ allData,
9780
+ user,
9781
+ getApiBaseUrl = () => {},
9782
+ getAppHeader = () => {},
9783
+ app,
9784
+ TreeNodeComponent
9785
+ } = _ref;
9791
9786
  if (!Array.isArray(value)) {
9792
9787
  return null;
9793
9788
  }
9794
9789
  return value.map((item, itemIndex) => /*#__PURE__*/jsxRuntime.jsx("div", {
9795
9790
  className: "array-item",
9796
9791
  children: Object.keys(config.inputs).sort((a, b) => {
9797
- const positionA = config.inputs[a]?.position || 0;
9798
- const positionB = config.inputs[b]?.position || 0;
9792
+ var _config$inputs$a, _config$inputs$b;
9793
+ const positionA = ((_config$inputs$a = config.inputs[a]) === null || _config$inputs$a === void 0 ? void 0 : _config$inputs$a.position) || 0;
9794
+ const positionB = ((_config$inputs$b = config.inputs[b]) === null || _config$inputs$b === void 0 ? void 0 : _config$inputs$b.position) || 0;
9799
9795
  return positionA - positionB;
9800
9796
  }).map(subInputKey => {
9801
9797
  const subInputConfig = config.inputs[subInputKey];
@@ -9813,9 +9809,9 @@ const handleArrayChildren = ({
9813
9809
  getApiBaseUrl: getApiBaseUrl,
9814
9810
  getAppHeader: getAppHeader,
9815
9811
  app: app
9816
- }, `${itemIndex}-${subInputKey}`);
9812
+ }, "".concat(itemIndex, "-").concat(subInputKey));
9817
9813
  })
9818
- }, `${itemIndex}`));
9814
+ }, "".concat(itemIndex)));
9819
9815
  };
9820
9816
 
9821
9817
  const noDafApps = ['tif', 'cukura']; //PACKAGE_CHANGE_LATER (remove sbg)
@@ -10170,42 +10166,37 @@ const handleDataLinkGroupWithTableKeys = ({
10170
10166
  }
10171
10167
  };
10172
10168
 
10173
- const handleDataLinkWithTableKeys = _ref => {
10174
- var _inputConfig$meta, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
10175
- let {
10176
- inputConfig,
10177
- inputKey,
10178
- value,
10179
- level,
10180
- t,
10181
- rootForm,
10182
- allData,
10183
- user,
10184
- getApiBaseUrl = () => {},
10185
- getAppHeader = () => {},
10186
- app,
10187
- TreeNodeComponent
10188
- } = _ref;
10189
- 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)) {
10169
+ const handleDataLinkWithTableKeys = ({
10170
+ inputConfig,
10171
+ inputKey,
10172
+ value,
10173
+ level,
10174
+ t,
10175
+ rootForm,
10176
+ allData,
10177
+ user,
10178
+ getApiBaseUrl = () => {},
10179
+ getAppHeader = () => {},
10180
+ app,
10181
+ TreeNodeComponent
10182
+ }) => {
10183
+ if (inputConfig?.type !== 'dataLink' || !inputConfig?.meta?.tableKeys) {
10190
10184
  return null;
10191
10185
  }
10192
10186
  const tableKeys = inputConfig.meta.tableKeys;
10193
- const isAjaxModal = React.useMemo(() => {
10194
- var _inputConfig$meta2;
10195
- return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
10196
- }, [inputConfig]);
10187
+ const isAjaxModal = React.useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
10197
10188
  const ajaxModalValues = useAjaxModal$2({
10198
10189
  name: inputKey,
10199
10190
  user,
10200
- namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
10201
- skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
10191
+ namespace: inputConfig?.meta?.namespace,
10192
+ skipFetch: inputConfig?.meta?.skipFetch,
10202
10193
  isAjaxModal,
10203
- formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
10194
+ formScope: inputConfig?.meta?.formScope,
10204
10195
  APP: app,
10205
10196
  apiBaseUrl: getApiBaseUrl(),
10206
10197
  _getAppHeader: getAppHeader
10207
10198
  });
10208
- const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
10199
+ const dataLinkForm = ajaxModalValues?.form;
10209
10200
  const createInputsAndValues = item => {
10210
10201
  const inputs = {};
10211
10202
  const values = {};
@@ -10218,20 +10209,19 @@ const handleDataLinkWithTableKeys = _ref => {
10218
10209
  };
10219
10210
  const isUploadFieldEmpty = (fieldKey, itemToCheck) => {
10220
10211
  if (uploadTypeFields.includes(fieldKey)) {
10221
- const itemValue = itemToCheck === null || itemToCheck === void 0 ? void 0 : itemToCheck[fieldKey];
10212
+ const itemValue = itemToCheck?.[fieldKey];
10222
10213
  return itemValue === undefined || itemValue === null || Array.isArray(itemValue) && itemValue.length === 0;
10223
10214
  }
10224
10215
  return false;
10225
10216
  };
10226
10217
  const processedTableKeys = processConditionalTableKeys(tableKeys, item);
10227
10218
  processedTableKeys.filter(tableKey => tableKey !== 'datastakeId').filter(tableKey => !isUploadFieldEmpty(tableKey, item)).forEach(tableKey => {
10228
- var _dataLinkForm$identif;
10229
- 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]);
10219
+ const formInputConfig = dataLinkForm?.[tableKey] || dataLinkForm?.['identification']?.[tableKey];
10230
10220
  if (formInputConfig) {
10231
- var _item$linking, _formInputConfig$meta, _formInputConfig$tabl;
10232
- inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10221
+ inputs[tableKey] = {
10222
+ ...formInputConfig,
10233
10223
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
10234
- });
10224
+ };
10235
10225
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10236
10226
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10237
10227
  let resolvedLabel = null;
@@ -10239,7 +10229,7 @@ const handleDataLinkWithTableKeys = _ref => {
10239
10229
  const parts = labelKey.split(' is ');
10240
10230
  if (parts.length === 2) {
10241
10231
  const [conditionKey, conditionValue] = parts;
10242
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10232
+ if (item?.[conditionKey] === conditionValue) {
10243
10233
  resolvedLabel = formInputConfig.label[labelKey];
10244
10234
  break;
10245
10235
  }
@@ -10247,17 +10237,16 @@ const handleDataLinkWithTableKeys = _ref => {
10247
10237
  }
10248
10238
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
10249
10239
  }
10250
- 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[formInputConfig === null || formInputConfig === void 0 || (_formInputConfig$meta = formInputConfig.meta) === null || _formInputConfig$meta === void 0 ? void 0 : _formInputConfig$meta.onNewSetValueKey] || (item === null || item === void 0 ? void 0 : item[formInputConfig === null || formInputConfig === void 0 || (_formInputConfig$tabl = formInputConfig.tableLabel) === null || _formInputConfig$tabl === void 0 ? void 0 : _formInputConfig$tabl.toLowerCase()]) || (item === null || item === void 0 ? void 0 : item[tableKey]);
10240
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item[formInputConfig?.meta?.onNewSetValueKey] || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[tableKey];
10251
10241
  } else {
10252
- var _item$linking2;
10253
10242
  inputs[tableKey] = {
10254
10243
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
10255
- type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
10244
+ type: inputConfig?.type
10256
10245
  };
10257
- values[tableKey] = (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[tableKey]]) === null || _item$linking2 === void 0 ? void 0 : _item$linking2.name) || (item === null || item === void 0 ? void 0 : item[tableKey]);
10246
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[tableKey];
10258
10247
  }
10259
10248
  });
10260
- if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
10249
+ if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
10261
10250
  Object.keys(dataLinkForm.identification).filter(fieldKey => {
10262
10251
  if (uploadTypeFields.includes(fieldKey)) {
10263
10252
  return !isUploadFieldEmpty(fieldKey, item);
@@ -10267,11 +10256,11 @@ const handleDataLinkWithTableKeys = _ref => {
10267
10256
  const formInputConfig = dataLinkForm.identification[fieldKey];
10268
10257
  return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
10269
10258
  }).forEach(fieldKey => {
10270
- var _item$linking3, _formInputConfig$tabl2;
10271
10259
  const formInputConfig = dataLinkForm.identification[fieldKey];
10272
- inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10260
+ inputs[fieldKey] = {
10261
+ ...formInputConfig,
10273
10262
  label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
10274
- });
10263
+ };
10275
10264
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10276
10265
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10277
10266
  let resolvedLabel = null;
@@ -10279,7 +10268,7 @@ const handleDataLinkWithTableKeys = _ref => {
10279
10268
  const parts = labelKey.split(' is ');
10280
10269
  if (parts.length === 2) {
10281
10270
  const [conditionKey, conditionValue] = parts;
10282
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10271
+ if (item?.[conditionKey] === conditionValue) {
10283
10272
  resolvedLabel = formInputConfig.label[labelKey];
10284
10273
  break;
10285
10274
  }
@@ -10287,7 +10276,7 @@ const handleDataLinkWithTableKeys = _ref => {
10287
10276
  }
10288
10277
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
10289
10278
  }
10290
- values[fieldKey] = (item === null || item === void 0 || (_item$linking3 = item.linking) === null || _item$linking3 === void 0 || (_item$linking3 = _item$linking3.SCL) === null || _item$linking3 === void 0 || (_item$linking3 = _item$linking3[item === null || item === void 0 ? void 0 : item[fieldKey]]) === null || _item$linking3 === void 0 ? void 0 : _item$linking3.name) || (item === null || item === void 0 ? void 0 : item[formInputConfig === null || formInputConfig === void 0 || (_formInputConfig$tabl2 = formInputConfig.tableLabel) === null || _formInputConfig$tabl2 === void 0 ? void 0 : _formInputConfig$tabl2.toLowerCase()]) || (item === null || item === void 0 ? void 0 : item[fieldKey]);
10279
+ values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[fieldKey];
10291
10280
  });
10292
10281
  }
10293
10282
  return {
@@ -10297,7 +10286,7 @@ const handleDataLinkWithTableKeys = _ref => {
10297
10286
  };
10298
10287
  if (Array.isArray(value)) {
10299
10288
  return value.map((item, itemIndex) => {
10300
- const datastakeIdValue = item === null || item === void 0 ? void 0 : item.datastakeId;
10289
+ const datastakeIdValue = item?.datastakeId;
10301
10290
  const {
10302
10291
  inputs,
10303
10292
  values
@@ -10306,9 +10295,9 @@ const handleDataLinkWithTableKeys = _ref => {
10306
10295
  return null;
10307
10296
  }
10308
10297
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
10309
- nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10298
+ nodeKey: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10310
10299
  config: {
10311
- label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10300
+ label: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10312
10301
  type: 'custom-datalink',
10313
10302
  inputs: inputs
10314
10303
  },
@@ -10322,10 +10311,10 @@ const handleDataLinkWithTableKeys = _ref => {
10322
10311
  getApiBaseUrl: getApiBaseUrl,
10323
10312
  getAppHeader: getAppHeader,
10324
10313
  app: app
10325
- }, "".concat(inputKey, "-").concat(itemIndex));
10314
+ }, `${inputKey}-${itemIndex}`);
10326
10315
  });
10327
10316
  } else {
10328
- const datastakeIdValue = value === null || value === void 0 ? void 0 : value.datastakeId;
10317
+ const datastakeIdValue = value?.datastakeId;
10329
10318
  const {
10330
10319
  inputs,
10331
10320
  values
@@ -10350,7 +10339,7 @@ const handleDataLinkWithTableKeys = _ref => {
10350
10339
  getApiBaseUrl: getApiBaseUrl,
10351
10340
  getAppHeader: getAppHeader,
10352
10341
  app: app
10353
- }, "".concat(inputKey, "-single"));
10342
+ }, `${inputKey}-single`);
10354
10343
  }
10355
10344
  };
10356
10345
 
@@ -12470,6 +12459,8 @@ const Style$M = styled__default["default"].div`
12470
12459
  width: 100%;
12471
12460
  height: 472px;
12472
12461
 
12462
+
12463
+
12473
12464
  .filter-cont {
12474
12465
  position: absolute;
12475
12466
  top: 24px;
@@ -12572,11 +12563,24 @@ const Style$M = styled__default["default"].div`
12572
12563
  align-items: center;
12573
12564
  }
12574
12565
 
12575
- .marker-chain {
12576
- display: flex;
12577
- align-items: center;
12578
- justify-content: center;
12579
- }
12566
+ .marker-chain {
12567
+ display: flex;
12568
+ align-items: center;
12569
+ justify-content: center;
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
+
12580
12584
 
12581
12585
  }
12582
12586
 
@@ -13022,18 +13026,15 @@ const VILLAGE = "village";
13022
13026
  const EXPORTER = "exporter";
13023
13027
  const PROCESSOR = "mineralProcessor";
13024
13028
  const DEPOT = "depot";
13029
+ const OPERATOR = "miningOperator";
13025
13030
  const MAX_EXTRA_SMALL_ZOOM_THRESHOLD = 2;
13026
13031
  const MAX_SMALL_ZOOM_THRESHOLD = 3;
13027
13032
  const MAX_MEDIUM_ZOOM_THRESHOLD = 6;
13028
13033
  const LOCATION_TYPES = [MINE_SITE, VILLAGE];
13029
- const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT];
13034
+ const STAKEHOLDER_TYPES = [EXPORTER, PROCESSOR, DEPOT, OPERATOR];
13030
13035
  const RADIUS_SMALL = 15;
13031
13036
  const RADIUS_MEDIUM = 35;
13032
13037
  const RADIUS_LARGE = 60;
13033
- const RADIUS_CURVE_SMALL = 10;
13034
- const RADIUS_CURVE_MEDIUM = 15;
13035
- const RADIUS_CURVE_LARGE = 20;
13036
- const TENSION = 0.2;
13037
13038
  function isLocation(type) {
13038
13039
  return LOCATION_TYPES.includes(type);
13039
13040
  }
@@ -13090,7 +13091,6 @@ function getStakeholderPosition({
13090
13091
  const isLarge = isLargeMarker(zoom);
13091
13092
  let radius;
13092
13093
  let center = {
13093
- // NOT BEING USED FOR NOW AND MAYBE NEVER
13094
13094
  left: 0,
13095
13095
  top: 0
13096
13096
  };
@@ -13114,6 +13114,25 @@ function getStakeholderPosition({
13114
13114
  angleDeg
13115
13115
  };
13116
13116
  }
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
+ }
13117
13136
  function createPolyline({
13118
13137
  L,
13119
13138
  startLatLng,
@@ -13123,109 +13142,47 @@ function createPolyline({
13123
13142
  zoom,
13124
13143
  listOfPolylines = [],
13125
13144
  isFromStakeholder = false,
13126
- isForceOpen = false
13145
+ isForceOpen = false,
13146
+ stakeholderType = null,
13147
+ animated = false,
13148
+ mapRef
13127
13149
  }) {
13128
- const width = isFromStakeholder && isExtraSmallMarker(zoom) && !isForceOpen ? 0 : 1.2;
13129
- const coordinates = [[startLatLng.lat, startLatLng.lng], [endLatLng.lat, endLatLng.lng]];
13130
- const style = {
13150
+ const lineWidth = isFromStakeholder && isExtraSmallMarker(zoom) && !isForceOpen ? 0 : 1.2;
13151
+ const isShortLink = stakeholderType === OPERATOR || isFromStakeholder;
13152
+ const shouldAnimate = animated;
13153
+ const lineCoordinates = [[startLatLng.lat, startLatLng.lng], [endLatLng.lat, endLatLng.lng]];
13154
+ const polylineStyle = {
13131
13155
  color: "var(--base-gray-70)",
13132
- weight: width,
13133
- opacity: 0.5,
13134
- smoothFactor: 1,
13156
+ weight: lineWidth,
13157
+ opacity: isSelected ? 1 : 0.5,
13158
+ smoothFactor: 0,
13135
13159
  id,
13136
- dashArray: !isSelected ? "5, 5" : "0, 0"
13160
+ dashArray: isShortLink ? "0, 0" : shouldAnimate ? "10, 10" : !isSelected ? "5, 5" : "10, 10",
13161
+ renderer: L.svg()
13137
13162
  };
13138
- const newPolyline = L.polyline(coordinates, style);
13139
- if (listOfPolylines.find(p => p.options.id === id)) {
13140
- const polylineToUpdateCoordinates = listOfPolylines.find(p => p.options.id === id);
13141
- polylineToUpdateCoordinates.setLatLngs(coordinates);
13142
- polylineToUpdateCoordinates.setStyle(style);
13143
- } else {
13144
- listOfPolylines.push(newPolyline);
13145
- }
13146
- return newPolyline;
13147
- }
13148
- function createCurvePath({
13149
- zoom,
13150
- totalMarkers,
13151
- markerIndex
13152
- }) {
13153
- const radius = getCurvePointRadius(zoom);
13154
- const {
13155
- x,
13156
- y,
13157
- angleDeg
13158
- } = getAngleDeg(totalMarkers, markerIndex, radius);
13159
- return {
13160
- x,
13161
- y,
13162
- angleDeg
13163
- };
13164
- }
13165
- function getCurvePointRadius(zoom) {
13166
- const isSmall = isSmallMarker(zoom) || isExtraSmallMarker(zoom);
13167
- const isMedium = isMediumMarker(zoom);
13168
- if (isSmall) {
13169
- return RADIUS_SMALL + RADIUS_CURVE_SMALL;
13170
- } else if (isMedium) {
13171
- return RADIUS_MEDIUM + RADIUS_CURVE_MEDIUM;
13172
- } else {
13173
- return RADIUS_LARGE + RADIUS_CURVE_LARGE;
13174
- }
13175
- }
13176
- function buildSmoothCurve(layerPoints, mapRef) {
13177
- const path = [];
13178
- for (let i = 0; i < layerPoints.length - 1; i++) {
13179
- const p0 = layerPoints[i];
13180
- const p1 = layerPoints[i + 1];
13181
- const pPrev = layerPoints[i - 1] || p0;
13182
- const pNext = layerPoints[i + 2] || p1;
13183
- const cp1 = L__namespace.point(p0.x + (p1.x - pPrev.x) * TENSION, p0.y + (p1.y - pPrev.y) * TENSION);
13184
- const cp2 = L__namespace.point(p1.x - (pNext.x - p0.x) * TENSION, p1.y - (pNext.y - p0.y) * TENSION);
13185
- if (i === 0) {
13186
- path.push("M", [mapRef.layerPointToLatLng(p0).lat, mapRef.layerPointToLatLng(p0).lng]);
13163
+ const existingPolyline = listOfPolylines.find(p => p.options.id === id);
13164
+ if (existingPolyline) {
13165
+ removeAnimationFromElement(existingPolyline.getElement());
13166
+ existingPolyline.setLatLngs(lineCoordinates);
13167
+ existingPolyline.setStyle(polylineStyle);
13168
+ if (shouldAnimate && isSelected) {
13169
+ existingPolyline.once('add', () => {
13170
+ applyAnimationToPolyline(existingPolyline, isShortLink);
13171
+ });
13172
+ applyAnimationToPolyline(existingPolyline, isShortLink);
13187
13173
  }
13188
- 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]);
13174
+ return existingPolyline;
13189
13175
  }
13190
- return path;
13191
- }
13192
- function getSiblingCurveStrength(zoom) {
13193
- if (isExtraSmallMarker(zoom)) return RADIUS_CURVE_SMALL / 2;
13194
- if (isSmallMarker(zoom)) return RADIUS_CURVE_MEDIUM;
13195
- if (isMediumMarker(zoom)) return RADIUS_CURVE_LARGE;
13196
- return RADIUS_CURVE_LARGE;
13197
- }
13198
- function buildCurveWIthTwoSiblings({
13199
- mapRef,
13200
- startLatLng,
13201
- endLatLng,
13202
- zoom,
13203
- isSelected,
13204
- id
13205
- }) {
13206
- const fromPoint = mapRef.latLngToLayerPoint(startLatLng);
13207
- const toPoint = mapRef.latLngToLayerPoint(endLatLng);
13208
- const midX = (fromPoint.x + toPoint.x) / 2;
13209
- const midY = (fromPoint.y + toPoint.y) / 2 + (isSmallMarker(zoom) ? RADIUS_CURVE_SMALL / 2 : 0);
13210
- const dx = toPoint.x - fromPoint.x;
13211
- const dy = toPoint.y - fromPoint.y;
13212
- const normal = L__namespace.point(-dy, dx);
13213
- const length = Math.sqrt(normal.x ** 2 + normal.y ** 2) || 1;
13214
- const normalized = normal.multiplyBy(1 / length);
13215
- const curveStrength = getSiblingCurveStrength(zoom);
13216
- const controlPoint = L__namespace.point(midX, midY).add(normalized.multiplyBy(curveStrength));
13217
- const latlngs = [startLatLng, mapRef.layerPointToLatLng(controlPoint), endLatLng];
13218
- const layerPoints = latlngs.map(latlng => mapRef.latLngToLayerPoint(latlng));
13219
- const path = buildSmoothCurve(layerPoints, mapRef);
13220
- const curve = L__namespace.curve(path, {
13221
- color: "var(--base-gray-70)",
13222
- weight: isExtraSmallMarker(zoom) ? 0 : 1.2,
13223
- opacity: 0.5,
13224
- smoothFactor: 1,
13225
- id,
13226
- dashArray: !isSelected ? "5, 5" : "0, 0"
13227
- });
13228
- mapRef.addLayer(curve);
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);
13184
+ }
13185
+ return newPolyline;
13229
13186
  }
13230
13187
 
13231
13188
  const StakeholderMarker = styled__default["default"].div`
@@ -13527,6 +13484,9 @@ function StakeholderIcon$1({
13527
13484
  return null;
13528
13485
  }, [parentId, allData]);
13529
13486
  React.useEffect(() => {
13487
+ if (selectedMarkersId.length === 0 || !isSelected) {
13488
+ return;
13489
+ }
13530
13490
  linkNodesData.map(node => {
13531
13491
  const isConnectingToStakeholder = node.isStakeholder;
13532
13492
  const id = `${data.datastakeId}-${node.stakeholderId || node.datastakeId}`;
@@ -13538,8 +13498,6 @@ function StakeholderIcon$1({
13538
13498
  const stakeholderPoint = centerPoint.add(L__namespace.point(x, y));
13539
13499
  const stakeholderLatLng = mapRef.layerPointToLatLng(stakeholderPoint);
13540
13500
  let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
13541
- const areNextToEachOther = targetMarkerIndex === index + 1 || targetMarkerIndex === index - 1 || index === 0 && targetMarkerIndex === node.totalStakeholders - 1 || targetMarkerIndex === 0 && index === node.totalStakeholders - 1;
13542
- const areOnlyTwoSiblings = node.totalStakeholders === 2;
13543
13501
  if (isExtraSmallMarker(zoom) && !isForceOpen) {
13544
13502
  createPolyline({
13545
13503
  L: L__namespace,
@@ -13549,7 +13507,8 @@ function StakeholderIcon$1({
13549
13507
  zoom,
13550
13508
  isSelected,
13551
13509
  id,
13552
- listOfPolylines: polylinesRef.current
13510
+ listOfPolylines: polylinesRef.current,
13511
+ animated: true
13553
13512
  });
13554
13513
  return;
13555
13514
  }
@@ -13567,61 +13526,8 @@ function StakeholderIcon$1({
13567
13526
  const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
13568
13527
  const endPoint = L__namespace.point(x + nodePoint.x + center.left, y + nodePoint.y + center.top);
13569
13528
  endLatLng = mapRef.layerPointToLatLng(endPoint);
13570
- if (isSibling && (!areNextToEachOther || areOnlyTwoSiblings)) {
13571
- if (areOnlyTwoSiblings) {
13572
- buildCurveWIthTwoSiblings({
13573
- mapRef,
13574
- startLatLng: stakeholderLatLng,
13575
- endLatLng,
13576
- zoom,
13577
- isSelected,
13578
- id
13579
- });
13580
- return;
13581
- }
13582
- const total = node.totalStakeholders;
13583
- let from = index;
13584
- let to = targetMarkerIndex;
13585
- let flip = false;
13586
- const forwardDistance = (to - from + total) % total;
13587
- const backwardDistance = (from - to + total) % total;
13588
- if (backwardDistance < forwardDistance) {
13589
- [from, to] = [to, from];
13590
- flip = true;
13591
- }
13592
- const intermediateIndices = [];
13593
- for (let i = 1; i < (to - from + total) % total; i++) {
13594
- intermediateIndices.push((from + i) % total);
13595
- }
13596
- const indices = [from, ...intermediateIndices, to];
13597
- const intermediatePoints = [];
13598
- for (const i of indices) {
13599
- const {
13600
- x,
13601
- y
13602
- } = createCurvePath({
13603
- zoom,
13604
- totalMarkers: node.totalStakeholders,
13605
- markerIndex: i
13606
- });
13607
- const point = centerPoint.add(L__namespace.point(x, y));
13608
- const latlng = mapRef.layerPointToLatLng(point);
13609
- intermediatePoints.push(latlng);
13610
- }
13611
- const latlngs = flip ? [endLatLng, ...intermediatePoints, stakeholderLatLng] : [stakeholderLatLng, ...intermediatePoints, endLatLng];
13612
- const layerPoints = latlngs.map(latlng => mapRef.latLngToLayerPoint(latlng));
13613
- const path = buildSmoothCurve(layerPoints, mapRef);
13614
- const curve = L__namespace?.curve?.(path, {
13615
- color: "var(--base-gray-70)",
13616
- weight: isExtraSmallMarker(zoom) ? 0 : 1,
13617
- opacity: isSelected ? 1 : 0.5,
13618
- smoothFactor: 1,
13619
- id
13620
- });
13621
- mapRef.addLayer(curve);
13622
- return;
13623
- }
13624
13529
  }
13530
+ // Always use straight lines
13625
13531
  createPolyline({
13626
13532
  L: L__namespace,
13627
13533
  mapRef,
@@ -13631,10 +13537,11 @@ function StakeholderIcon$1({
13631
13537
  isFromStakeholder: false,
13632
13538
  isSelected,
13633
13539
  id,
13634
- listOfPolylines: polylinesRef.current
13540
+ listOfPolylines: polylinesRef.current,
13541
+ animated: true
13635
13542
  });
13636
13543
  });
13637
- }, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen]);
13544
+ }, [mapRef, x, y, parentData, linkNodesData, isSelected, zoom, isForceOpen, selectedMarkersId]);
13638
13545
  return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
13639
13546
  children: /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
13640
13547
  content: renderTooltipJsx({
@@ -13646,7 +13553,8 @@ function StakeholderIcon$1({
13646
13553
  link,
13647
13554
  onClickLink: () => {
13648
13555
  onClickLink(data);
13649
- }
13556
+ },
13557
+ isNewTab: true
13650
13558
  }),
13651
13559
  getPopupContainer: triggerNode => {
13652
13560
  const mapElement = document.getElementById("map");
@@ -13701,6 +13609,8 @@ function LocationIcon({
13701
13609
  const linkedNodesData = React.useMemo(() => {
13702
13610
  const nodes = [];
13703
13611
  const links = data.links || [];
13612
+
13613
+ // Add links from the location itself
13704
13614
  links.forEach(link => {
13705
13615
  allData.forEach(d => {
13706
13616
  if (d.datastakeId === link) {
@@ -13720,8 +13630,45 @@ function LocationIcon({
13720
13630
  }
13721
13631
  });
13722
13632
  });
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
+ });
13723
13670
  return nodes;
13724
- }, [JSON.stringify(allData), JSON.stringify(data.links), zoom]);
13671
+ }, [JSON.stringify(allData), JSON.stringify(data.links), JSON.stringify(data.stakeholders), zoom]);
13725
13672
  const stakeholdersOfLocation = React.useMemo(() => {
13726
13673
  return data?.stakeholders || [];
13727
13674
  }, [data.stakeholders, zoom]);
@@ -13739,7 +13686,13 @@ function LocationIcon({
13739
13686
  currentRoots.clear();
13740
13687
  markersRef.current = [];
13741
13688
 
13742
- // Create new markers
13689
+ // Only create stakeholder markers if this location or any of its stakeholders are selected
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
13743
13696
  stakeholdersOfLocation.forEach((stakeholder, index) => {
13744
13697
  const markerId = `${stakeholder.datastakeId}`;
13745
13698
  const {
@@ -13825,7 +13778,9 @@ function LocationIcon({
13825
13778
  zoom,
13826
13779
  isFromStakeholder: true,
13827
13780
  isForceOpen,
13828
- listOfPolylines: polylinesRef.current
13781
+ listOfPolylines: polylinesRef.current,
13782
+ stakeholderType: stakeholder.type,
13783
+ animated: true
13829
13784
  });
13830
13785
  });
13831
13786
  return () => {
@@ -13840,38 +13795,88 @@ function LocationIcon({
13840
13795
  rootsMapRef.current.clear();
13841
13796
  markersRef.current = [];
13842
13797
  };
13843
- }, [stakeholdersOfLocation, selectedMarkersId, activeMarker]);
13844
- linkedNodesData.map(node => {
13845
- const id = `${data.datastakeId}-${node.datastakeId}`;
13846
- const isConnectingToStakeholder = node.isStakeholder;
13847
- const centerLatLng = L__namespace.latLng(data.gps.latitude, data.gps.longitude);
13848
- let endLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
13849
- const isConnectingToStakeholderSelected = selectedMarkersId.includes(node.datastakeId);
13850
- if (isConnectingToStakeholder && !isExtraSmallMarker(zoom)) {
13851
- const {
13852
- x,
13853
- y
13854
- } = getStakeholderPosition({
13798
+ }, [stakeholdersOfLocation, selectedMarkersId, activeMarker, zoom]);
13799
+
13800
+ // Only create polylines for linked nodes when something is selected
13801
+ React.useEffect(() => {
13802
+ if (selectedMarkersId.length === 0) {
13803
+ return;
13804
+ }
13805
+
13806
+ // IMPORTANT: Only draw links if this location is actually selected
13807
+ // Not just highlighted as part of the chain
13808
+ if (!isSelected) {
13809
+ return;
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,
13855
13875
  zoom,
13856
- totalMarkers: node.totalStakeholders,
13857
- markerIndex: node.stakeholdersIndex
13858
- });
13859
- const nodeLatLng = L__namespace.latLng(node.gps.latitude, node.gps.longitude);
13860
- const nodePoint = mapRef.latLngToLayerPoint(nodeLatLng);
13861
- const endPoint = L__namespace.point(x + nodePoint.x, y + nodePoint.y);
13862
- endLatLng = mapRef.layerPointToLatLng(endPoint);
13863
- }
13864
- createPolyline({
13865
- L: L__namespace,
13866
- mapRef,
13867
- startLatLng: centerLatLng,
13868
- endLatLng,
13869
- isSelected: isConnectingToStakeholderSelected,
13870
- id,
13871
- zoom,
13872
- listOfPolylines: polylinesRef.current
13876
+ listOfPolylines: polylinesRef.current
13877
+ });
13873
13878
  });
13874
- });
13879
+ }, [linkedNodesData, selectedMarkersId, zoom, stakeholdersOfLocation, isSelected]);
13875
13880
  return /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
13876
13881
  content: renderTooltipJsx({
13877
13882
  title: data.name,
@@ -14387,7 +14392,8 @@ function useMapHelper$1({
14387
14392
  link: link,
14388
14393
  onClickLink: onClickLink,
14389
14394
  activeStakeholder: activeStakeholder,
14390
- setActiveStakeholder: setActiveStakeholder
14395
+ setActiveStakeholder: setActiveStakeholder,
14396
+ mapRef: mapRef
14391
14397
  }));
14392
14398
  roots.current.push(root);
14393
14399
  } else if (type === "location") {
@@ -14592,7 +14598,8 @@ const useMap$1 = ({
14592
14598
  MAP_TOKEN
14593
14599
  } = useMapConfig({
14594
14600
  app,
14595
- isSatellite
14601
+ isSatellite,
14602
+ mapRef: container
14596
14603
  });
14597
14604
  const [initialMarkerSetIsDone, setInitialMarkerSetIsDone] = React.useState(false);
14598
14605
  const [mapCenter, setMapCenter] = React.useState([0, 0]);
@@ -14609,6 +14616,8 @@ const useMap$1 = ({
14609
14616
  const graph = new Map();
14610
14617
  const stakeToLoc = new Map();
14611
14618
  const nodeTypes = new Map();
14619
+
14620
+ // Build the graph
14612
14621
  for (const loc of data) {
14613
14622
  const locId = loc.datastakeId;
14614
14623
  nodeTypes.set(locId, loc.type);
@@ -14633,26 +14642,45 @@ const useMap$1 = ({
14633
14642
  }
14634
14643
  }
14635
14644
  const highlightTable = {};
14645
+
14646
+ // Perform BFS/DFS to find all connected nodes in the entire chain
14636
14647
  for (const [node] of graph) {
14637
14648
  const highlighted = new Set();
14638
- highlighted.add(node);
14639
- const nodeIsStakeholder = !isLocation(nodeTypes.get(node));
14640
- if (nodeIsStakeholder && stakeToLoc.has(node)) {
14641
- const parentLoc = stakeToLoc.get(node);
14642
- highlighted.add(parentLoc);
14643
- }
14644
- for (const neighbor of graph.get(node) || []) {
14645
- const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
14646
- if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
14647
- const neighborParent = stakeToLoc.get(neighbor);
14648
- if (isLocation(nodeTypes.get(node)) && neighborParent === node || nodeIsStakeholder && stakeToLoc.get(node) === neighborParent) {
14649
- highlighted.add(neighbor);
14650
- } else {
14649
+ const queue = [node];
14650
+ const visited = new Set([node]);
14651
+ while (queue.length > 0) {
14652
+ const current = queue.shift();
14653
+ highlighted.add(current);
14654
+
14655
+ // Add parent location if current is stakeholder
14656
+ const currentIsStakeholder = !isLocation(nodeTypes.get(current));
14657
+ if (currentIsStakeholder && stakeToLoc.has(current)) {
14658
+ const parentLoc = stakeToLoc.get(current);
14659
+ if (!visited.has(parentLoc)) {
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);
14651
14671
  highlighted.add(neighbor);
14652
- highlighted.add(neighborParent);
14672
+
14673
+ // If neighbor is stakeholder, add its parent location
14674
+ const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
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
+ }
14653
14683
  }
14654
- } else {
14655
- highlighted.add(neighbor);
14656
14684
  }
14657
14685
  }
14658
14686
  highlightTable[node] = [...highlighted];
@@ -14690,10 +14718,20 @@ const useMap$1 = ({
14690
14718
  function handleSelectMarker(clickedMarker) {
14691
14719
  setSelectedMarkersId(prev => {
14692
14720
  if (prev.includes(clickedMarker.datastakeId)) {
14721
+ // Deselecting - clear polylines
14693
14722
  openPopupIdRef.current = null;
14694
14723
  setMarkerWithPopup(null);
14695
14724
  return [];
14696
14725
  } 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
+ }
14697
14735
  setMarkerWithPopup(isStakeholder(clickedMarker.type) ? clickedMarker : null);
14698
14736
  const newSelectedMarkersId = highlightTable[clickedMarker.datastakeId];
14699
14737
  openPopupIdRef.current = clickedMarker.datastakeId;
@@ -14717,19 +14755,29 @@ const useMap$1 = ({
14717
14755
  });
14718
14756
  }
14719
14757
  }
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
+ }
14720
14768
  clearMapMarkers();
14721
14769
  if (data) {
14722
- // Filters out locations that are not connected to any stakeholders
14723
- const excludedType = ['village', 'town', 'area', 'territory'];
14724
- 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)))));
14770
+ 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))));
14725
14771
  const maxTotal = Math.max(...(data || []).map(d => d.total));
14726
14772
  const dataToRender = type === "chain" ? filteredData : data;
14727
14773
  dataToRender.forEach((d, i) => {
14728
14774
  addIconToMapInitialy([d?.marker?.lat, d?.marker?.lng], "location", d.category || "mineSite", d, maxTotal, i);
14729
14775
  });
14730
- polylinesRef.current.forEach(polyline => {
14731
- mapRef.addLayer(polyline);
14732
- });
14776
+ if (selectedMarkersId.length > 0) {
14777
+ polylinesRef.current.forEach(polyline => {
14778
+ mapRef.addLayer(polyline);
14779
+ });
14780
+ }
14733
14781
  mapRef.invalidateSize();
14734
14782
  mapRef.fire("moveend");
14735
14783
  }