datastake-daf 0.6.779 → 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.
@@ -8486,22 +8486,20 @@ const useHeader = _ref => {
8486
8486
  const {
8487
8487
  useToken: useToken$m
8488
8488
  } = antd.theme;
8489
- function BreadCrumbs(_ref) {
8490
- let {
8491
- breadcrumbs = [],
8492
- mainContWidth = 0
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 = function (b, i, isLast) {
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 === null || b === void 0 ? void 0 : b.onClick,
8500
+ onClick: noOnClickLast && isLast ? undefined : b?.onClick,
8503
8501
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
8504
- children: b === null || b === void 0 ? void 0 : b.label
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
- }, "breadcrumb-item-".concat(i));
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: "items-".concat(i),
8555
+ key: `items-${i}`,
8558
8556
  label: it.label,
8559
8557
  onClick: it.onClick
8560
8558
  }))
@@ -9546,29 +9544,24 @@ const processConditionalTableKeys = (tableKeys, item) => {
9546
9544
  });
9547
9545
  return processedKeys;
9548
9546
  };
9549
- const renderFieldData = function (type, value, user, config) {
9550
- let getApiBaseUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : () => {};
9551
- let getAppHeader = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : () => {};
9552
- let app = arguments.length > 6 ? arguments[6] : undefined;
9553
- let allValues = arguments.length > 7 ? arguments[7] : undefined;
9554
- let formValues = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : {};
9547
+ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, getAppHeader = () => {}, app, allValues, formValues = {}) => {
9555
9548
  switch (type) {
9556
9549
  case 'year':
9557
9550
  return value !== '-' ? renderDateFormatted(value, 'YYYY', 'en') : '-';
9558
9551
  case 'date':
9559
9552
  {
9560
- const language = user !== null && user !== void 0 && user.language && (user === null || user === void 0 ? void 0 : user.language) === 'sp' ? 'es' : user === null || user === void 0 ? void 0 : user.language;
9553
+ const language = user?.language && user?.language === 'sp' ? 'es' : user?.language;
9561
9554
  return value !== '-' ? renderDateFormatted(value, 'DD MMM YYYY', language || 'en') : '-';
9562
9555
  }
9563
9556
  case 'select':
9564
9557
  {
9565
- const options = (config === null || config === void 0 ? void 0 : config.options) || [];
9558
+ const options = config?.options || [];
9566
9559
  const option = findOptions(value, options);
9567
9560
  return option;
9568
9561
  }
9569
9562
  case 'multiselect':
9570
9563
  {
9571
- const options = (config === null || config === void 0 ? void 0 : config.options) || [];
9564
+ const options = config?.options || [];
9572
9565
  const _val = typeof value === 'string' ? value.split(',').map(v => v.trim()) : value;
9573
9566
  const option = findOptions(_val, options);
9574
9567
  return option.join(', ');
@@ -9583,7 +9576,7 @@ const renderFieldData = function (type, value, user, config) {
9583
9576
  formValues: formValues
9584
9577
  });
9585
9578
  case 'percentage':
9586
- return value === '-' || value === null || value === undefined ? '-' : "".concat(value, " %");
9579
+ return value === '-' || value === null || value === undefined ? '-' : `${value} %`;
9587
9580
  case 'geolocation':
9588
9581
  {
9589
9582
  const val = JSON.parse(value) || {};
@@ -9597,7 +9590,7 @@ const renderFieldData = function (type, value, user, config) {
9597
9590
  case 'upload':
9598
9591
  case 'videoUpload':
9599
9592
  {
9600
- const documentName = allValues === null || allValues === void 0 ? void 0 : allValues.map(item => item === null || item === void 0 ? void 0 : item.name).join(', ');
9593
+ const documentName = allValues?.map(item => item?.name).join(', ');
9601
9594
  return documentName;
9602
9595
  }
9603
9596
  default:
@@ -9721,18 +9714,19 @@ const resolveDynamicLabel = (labelConfig, item, defaultLabel) => {
9721
9714
  return labelConfig || defaultLabel;
9722
9715
  };
9723
9716
 
9724
- const handleSectionChildren = ({
9725
- config,
9726
- allData,
9727
- level,
9728
- t,
9729
- rootForm,
9730
- user,
9731
- getApiBaseUrl = () => {},
9732
- getAppHeader = () => {},
9733
- app,
9734
- TreeNodeComponent
9735
- }) => {
9717
+ const handleSectionChildren = _ref => {
9718
+ let {
9719
+ config,
9720
+ allData,
9721
+ level,
9722
+ t,
9723
+ rootForm,
9724
+ user,
9725
+ getApiBaseUrl = () => {},
9726
+ getAppHeader = () => {},
9727
+ app,
9728
+ TreeNodeComponent
9729
+ } = _ref;
9736
9730
  if (!(level === 0 && config && typeof config === 'object')) {
9737
9731
  return null;
9738
9732
  }
@@ -9746,14 +9740,14 @@ const handleSectionChildren = ({
9746
9740
  let fieldValue;
9747
9741
 
9748
9742
  // Determine field value based on type
9749
- if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData?.[fieldKey])) {
9743
+ if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData === null || allData === void 0 ? void 0 : allData[fieldKey])) {
9750
9744
  fieldValue = allData[fieldKey];
9751
- } else if (fieldConfig.type === 'dataLinkGroup' && allData?.[fieldKey]) {
9745
+ } else if (fieldConfig.type === 'dataLinkGroup' && allData !== null && allData !== void 0 && allData[fieldKey]) {
9752
9746
  fieldValue = allData[fieldKey];
9753
9747
  } else if (fieldConfig.type === 'group') {
9754
9748
  fieldValue = {};
9755
9749
  } else {
9756
- fieldValue = allData?.[fieldKey];
9750
+ fieldValue = allData === null || allData === void 0 ? void 0 : allData[fieldKey];
9757
9751
  }
9758
9752
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
9759
9753
  nodeKey: fieldKey,
@@ -9960,44 +9954,44 @@ function useAjaxModal$2({
9960
9954
  }
9961
9955
 
9962
9956
  const mergeObject = obj => {
9963
- return Object.entries(obj || {}).reduce((acc, [key, value]) => {
9957
+ return Object.entries(obj || {}).reduce((acc, _ref) => {
9958
+ let [key, value] = _ref;
9964
9959
  if (typeof value === "object" && !Array.isArray(value) && value !== null) {
9965
- return {
9966
- ...acc,
9967
- ...value
9968
- };
9960
+ return _objectSpread2(_objectSpread2({}, acc), value);
9969
9961
  }
9970
- return {
9971
- ...acc,
9962
+ return _objectSpread2(_objectSpread2({}, acc), {}, {
9972
9963
  [key]: value
9973
- };
9964
+ });
9974
9965
  }, {});
9975
9966
  };
9976
- const handleDataLinkGroupWithTableKeys = ({
9977
- config,
9978
- inputConfig,
9979
- inputKey,
9980
- value,
9981
- level,
9982
- t,
9983
- rootForm,
9984
- allData,
9985
- user,
9986
- getApiBaseUrl = () => {},
9987
- getAppHeader = () => {},
9988
- app,
9989
- TreeNodeComponent
9990
- }) => {
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;
9991
9984
  if (!(config.type === 'dataLinkGroup' || config.type === 'dataLink')) {
9992
9985
  return null;
9993
9986
  }
9994
- if (inputConfig?.type !== 'dataLink' || !inputConfig?.meta?.tableKeys) {
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)) {
9995
9988
  const parentInputKeys = Object.keys(config.inputs || {});
9996
9989
  const isHandledBySiblingDataLink = parentInputKeys.some(otherInputKey => {
9997
9990
  const otherConfig = config.inputs[otherInputKey];
9998
- if (otherConfig?.type === 'dataLink') {
9999
- const siblingTableKeys = otherConfig?.meta?.tableKeys || [];
10000
- const additionalTableKeys = config.meta?.additionalTableKeys || [];
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) || [];
10001
9995
  const allSiblingKeys = [...siblingTableKeys, ...additionalTableKeys];
10002
9996
  return allSiblingKeys.includes(inputKey) && otherInputKey !== inputKey;
10003
9997
  }
@@ -10011,23 +10005,26 @@ const handleDataLinkGroupWithTableKeys = ({
10011
10005
  return null;
10012
10006
  }
10013
10007
  const tableKeys = inputConfig.meta.tableKeys;
10014
- const additionalTableKeys = config.meta?.additionalTableKeys || [];
10008
+ const additionalTableKeys = ((_config$meta2 = config.meta) === null || _config$meta2 === void 0 ? void 0 : _config$meta2.additionalTableKeys) || [];
10015
10009
  const parentInputKeys = Object.keys(config.inputs || {});
10016
10010
  const siblingInputsMatchingTableKeys = parentInputKeys.filter(siblingKey => siblingKey !== inputKey).filter(siblingKey => tableKeys.includes(siblingKey) || additionalTableKeys.includes(siblingKey));
10017
10011
  [...new Set([...tableKeys, ...siblingInputsMatchingTableKeys])];
10018
- const isAjaxModal = React.useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
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]);
10019
10016
  const ajaxModalValues = useAjaxModal$2({
10020
10017
  name: inputKey,
10021
10018
  user,
10022
- namespace: inputConfig?.meta?.namespace,
10023
- skipFetch: inputConfig?.meta?.skipFetch,
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,
10024
10021
  isAjaxModal,
10025
- formScope: inputConfig?.meta?.formScope,
10022
+ formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
10026
10023
  APP: app,
10027
10024
  apiBaseUrl: getApiBaseUrl(),
10028
10025
  _getAppHeader: getAppHeader
10029
10026
  });
10030
- const dataLinkForm = ajaxModalValues?.form;
10027
+ const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
10031
10028
  const createInputsAndValues = item => {
10032
10029
  const inputs = {};
10033
10030
  const values = {};
@@ -10039,12 +10036,12 @@ const handleDataLinkGroupWithTableKeys = ({
10039
10036
  'videos': 'Video'
10040
10037
  };
10041
10038
  tableKeys.filter(tableKey => tableKey !== 'datastakeId').forEach(tableKey => {
10042
- const formInputConfig = dataLinkForm?.[tableKey] || dataLinkForm?.['identification']?.[tableKey];
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]);
10043
10041
  if (formInputConfig) {
10044
- inputs[tableKey] = {
10045
- ...formInputConfig,
10042
+ inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10046
10043
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
10047
- };
10044
+ });
10048
10045
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10049
10046
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10050
10047
  let resolvedLabel = null;
@@ -10052,7 +10049,7 @@ const handleDataLinkGroupWithTableKeys = ({
10052
10049
  const parts = labelKey.split(' is ');
10053
10050
  if (parts.length === 2) {
10054
10051
  const [conditionKey, conditionValue] = parts;
10055
- if (item?.[conditionKey] === conditionValue) {
10052
+ if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10056
10053
  resolvedLabel = formInputConfig.label[labelKey];
10057
10054
  break;
10058
10055
  }
@@ -10060,37 +10057,37 @@ const handleDataLinkGroupWithTableKeys = ({
10060
10057
  }
10061
10058
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
10062
10059
  }
10063
- values[tableKey] = item?.[tableKey];
10060
+ values[tableKey] = item === null || item === void 0 ? void 0 : item[tableKey];
10064
10061
  } else {
10062
+ var _item$linking;
10065
10063
  inputs[tableKey] = {
10066
10064
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
10067
- type: inputConfig?.type
10065
+ type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
10068
10066
  };
10069
- values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[tableKey];
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]);
10070
10068
  }
10071
10069
  });
10072
10070
  siblingInputsMatchingTableKeys.forEach(siblingKey => {
10073
10071
  const siblingConfig = config.inputs[siblingKey];
10074
10072
  if (siblingConfig) {
10075
- inputs[siblingKey] = {
10076
- ...siblingConfig,
10073
+ inputs[siblingKey] = _objectSpread2(_objectSpread2({}, siblingConfig), {}, {
10077
10074
  label: siblingConfig.label || siblingKey
10078
- };
10079
- values[siblingKey] = item?.[siblingKey];
10075
+ });
10076
+ values[siblingKey] = item === null || item === void 0 ? void 0 : item[siblingKey];
10080
10077
  }
10081
10078
  });
10082
- if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
10079
+ if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
10083
10080
  Object.keys(dataLinkForm.identification).filter(fieldKey => fieldKey !== 'datastakeId' && !tableKeys.includes(fieldKey)).filter(fieldKey => {
10084
10081
  const formInputConfig = dataLinkForm.identification[fieldKey];
10085
10082
  return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
10086
10083
  }).forEach(fieldKey => {
10084
+ var _item$linking2;
10087
10085
  const formInputConfig = dataLinkForm.identification[fieldKey];
10088
- inputs[fieldKey] = {
10089
- ...formInputConfig,
10086
+ inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10090
10087
  label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
10091
- };
10092
- if (formInputConfig?.label && typeof formInputConfig?.label === 'object') {
10093
- const dynamicLabelKeys = Object.keys(formInputConfig?.label);
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);
10094
10091
  let resolvedLabel = null;
10095
10092
  for (const labelKey of dynamicLabelKeys) {
10096
10093
  const parts = labelKey.split(' is ');
@@ -10099,7 +10096,7 @@ const handleDataLinkGroupWithTableKeys = ({
10099
10096
  const flattenedItem = Object.assign({}, item.location, {
10100
10097
  address: item.address
10101
10098
  });
10102
- if (flattenedItem?.[conditionKey] === conditionValue) {
10099
+ if ((flattenedItem === null || flattenedItem === void 0 ? void 0 : flattenedItem[conditionKey]) === conditionValue) {
10103
10100
  resolvedLabel = formInputConfig.label[labelKey];
10104
10101
  break;
10105
10102
  }
@@ -10107,7 +10104,7 @@ const handleDataLinkGroupWithTableKeys = ({
10107
10104
  }
10108
10105
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
10109
10106
  }
10110
- values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[fieldKey];
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]);
10111
10108
  });
10112
10109
  }
10113
10110
  return {
@@ -10117,16 +10114,17 @@ const handleDataLinkGroupWithTableKeys = ({
10117
10114
  };
10118
10115
  if (Array.isArray(value)) {
10119
10116
  return value.map((item, itemIndex) => {
10117
+ var _merged$inputKey;
10120
10118
  const merged = mergeObject(item);
10121
- const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
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);
10122
10120
  const {
10123
10121
  inputs,
10124
10122
  values
10125
10123
  } = createInputsAndValues(merged);
10126
10124
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
10127
- nodeKey: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10125
+ nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10128
10126
  config: {
10129
- label: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10127
+ label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10130
10128
  type: 'custom-datalink-group',
10131
10129
  inputs: inputs
10132
10130
  },
@@ -10140,11 +10138,12 @@ const handleDataLinkGroupWithTableKeys = ({
10140
10138
  getApiBaseUrl: getApiBaseUrl,
10141
10139
  getAppHeader: getAppHeader,
10142
10140
  app: app
10143
- }, `${inputKey}-${itemIndex}`);
10141
+ }, "".concat(inputKey, "-").concat(itemIndex));
10144
10142
  });
10145
10143
  } else {
10144
+ var _merged$inputKey2;
10146
10145
  const merged = mergeObject(value);
10147
- const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
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);
10148
10147
  const {
10149
10148
  inputs,
10150
10149
  values
@@ -10166,7 +10165,7 @@ const handleDataLinkGroupWithTableKeys = ({
10166
10165
  getApiBaseUrl: getApiBaseUrl,
10167
10166
  getAppHeader: getAppHeader,
10168
10167
  app: app
10169
- }, `${inputKey}-group`);
10168
+ }, "".concat(inputKey, "-group"));
10170
10169
  }
10171
10170
  };
10172
10171
 
@@ -10347,20 +10346,21 @@ const handleDataLinkWithTableKeys = ({
10347
10346
  }
10348
10347
  };
10349
10348
 
10350
- const handleGroupChildren = ({
10351
- config,
10352
- value,
10353
- allData,
10354
- level,
10355
- t,
10356
- rootForm,
10357
- user,
10358
- getApiBaseUrl = () => {},
10359
- getAppHeader = () => {},
10360
- app,
10361
- TreeNodeComponent
10362
- }) => {
10363
- if (!config?.inputs) {
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)) {
10364
10364
  return null;
10365
10365
  }
10366
10366
  const inputKeys = Object.keys(config.inputs);
@@ -10373,7 +10373,7 @@ const handleGroupChildren = ({
10373
10373
  if (value && typeof value === 'object' && value[inputKey]) {
10374
10374
  inputValue = value[inputKey];
10375
10375
  } else {
10376
- inputValue = allData?.[inputKey];
10376
+ inputValue = allData === null || allData === void 0 ? void 0 : allData[inputKey];
10377
10377
  }
10378
10378
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
10379
10379
  nodeKey: inputKey,
@@ -42764,7 +42764,10 @@ const PlantingLocations = ({
42764
42764
  return eventsWithGPS.map((event, index) => {
42765
42765
  const locationCheckArrival = event.locationCheckArrival;
42766
42766
  const matchingLocation = locations.find(location => locationCheckArrival.name === location.name || locationCheckArrival._id === location.id || location.id === locationCheckArrival._id) || locations[0];
42767
- const area = matchingLocation?.perimeter ? matchingLocation.perimeter.map(coord => Array.isArray(coord) && coord.length >= 2 ? [coord[1], coord[0]] : coord) : [];
42767
+ const area = matchingLocation?.perimeter ? matchingLocation.perimeter.map(coord => Array.isArray(coord) && coord.length >= 2 ? [coord[1], coord[0]] : coord) : null;
42768
+
42769
+ // Only include area if it has at least 3 valid coordinates
42770
+ const validArea = area && Array.isArray(area) && area.length >= 3 ? area : null;
42768
42771
  const gps = {
42769
42772
  latitude: locationCheckArrival.latitude,
42770
42773
  longitude: locationCheckArrival.longitude
@@ -42773,7 +42776,7 @@ const PlantingLocations = ({
42773
42776
  const locationName = matchingLocation?.name || locationCheckArrival.name || 'Planting Location';
42774
42777
  return {
42775
42778
  _id: locationCheckArrival._id || event._id || {},
42776
- area: area,
42779
+ area: validArea,
42777
42780
  color: color,
42778
42781
  datastakeId: `LOC-${String(index + 1).padStart(9, '0')}`,
42779
42782
  gps: gps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.779",
3
+ "version": "0.6.781",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -6,171 +6,176 @@ import CustomIcon from '../../../../../../../../src/@daf/core/components/Icon/Cu
6
6
  import { renderDateFormatted } from '../../../../../../../../src/helpers/Forms';
7
7
 
8
8
  const PlantingLocations = ({
9
- id,
10
- getSummaryDetail,
11
- loading = false,
12
- t = (s) => s
9
+ id,
10
+ getSummaryDetail,
11
+ loading = false,
12
+ t = (s) => s
13
13
  }) => {
14
- const defaultConfig = useMemo(
15
- () => ({
16
- basepath: "planting-cycle",
17
- url: `/summary/${id}/locations`,
18
- stop: !id,
19
- }),
20
- [id],
21
- );
22
-
23
- const customGetData = useMemo(() => {
24
- if (getSummaryDetail && id) {
25
- return ({ url, params = {} }) => {
26
- const match = url.match(/\/summary\/[^/]+\/(.+)/);
27
- if (match) {
28
- const [, type] = match;
29
- return getSummaryDetail(id, type, params);
30
- }
31
- throw new Error(`Invalid URL format: ${url}`);
32
- };
33
- }
34
- return undefined;
35
- }, [getSummaryDetail, id]);
36
-
37
- const { loading: plantingLocationsLoading, data: plantingLocationsData } = useWidgetFetch({
38
- config: defaultConfig,
39
- getData: customGetData
40
- });
41
-
42
-
43
- const mappedData = useMemo(() => {
44
- if (!plantingLocationsData || !plantingLocationsData.events) {
45
- return [];
46
- }
47
-
48
- const { locations = [], events } = plantingLocationsData;
49
-
50
- // Filter events that have valid GPS coordinates
51
- const eventsWithGPS = events.filter(event =>
52
- event.locationCheckArrival &&
53
- event.locationCheckArrival.latitude &&
54
- event.locationCheckArrival.longitude
55
- );
56
-
57
- return eventsWithGPS.map((event, index) => {
58
- const locationCheckArrival = event.locationCheckArrival;
59
-
60
- const matchingLocation = locations.find(location =>
61
- locationCheckArrival.name === location.name ||
62
- locationCheckArrival._id === location.id ||
63
- location.id === locationCheckArrival._id
64
- ) || locations[0];
65
-
66
-
67
- const area = matchingLocation?.perimeter ? matchingLocation.perimeter.map(coord =>
68
- Array.isArray(coord) && coord.length >= 2
69
- ? [coord[1], coord[0]]
70
- : coord
71
- ) : [];
72
-
73
-
74
- const gps = {
75
- latitude: locationCheckArrival.latitude,
76
- longitude: locationCheckArrival.longitude
77
- };
78
-
79
-
80
- const color = "#15FFFFB2"
81
-
82
- const locationName = matchingLocation?.name || locationCheckArrival.name || 'Planting Location';
83
-
84
- return {
85
- _id: locationCheckArrival._id || event._id || {},
86
- area: area,
87
- color: color,
88
- datastakeId: `LOC-${String(index + 1).padStart(9, '0')}`,
89
- gps: gps,
90
- id: matchingLocation?.id || locationCheckArrival._id || `event-${index}`,
91
- name: event.name || t("Activity Start"),
92
- date: event.date,
93
- sources: 1,
94
- subTitle: event.date ? renderDateFormatted(event.date, "DD MMM YY") : locationName,
95
- plotName: locationName,
96
- territoryTitle: locationName,
97
- type: 'Planting Location'
98
- };
99
- });
100
- }, [plantingLocationsData, t]);
101
-
102
- return (
103
- <section>
104
- <Widget
105
- title={t("Planting Locations")}
106
- className="no-px h-w-btn-header no-pt-body no-p-body no-pb-body"
107
- style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
108
- >
109
- <MineSiteMap
110
- data={mappedData}
111
- link
112
- style={{ height: '100%', width: '100%' }}
113
- maxZoom={18}
114
- isSatellite={true}
115
- onClickLink={() => { }}
116
- onFilterChange={() => { }}
117
- primaryLink
118
- renderTooltipForLocation={(data) => {
119
- const coordinates = data.gps?.latitude && data.gps?.longitude
120
- ? convertDMS(data.gps.latitude, data.gps.longitude)
121
- : null;
122
-
123
- if (!coordinates) {
124
- return [];
125
- }
126
-
127
- const iconColor = "#016C6E"; // Activity Start color
128
-
129
- return [
130
- {
131
- label: t("Coordinates"),
132
- value: (
133
- <div style={{ display: 'flex', alignItems: 'center', gap: '6px', flexWrap: 'nowrap' }}>
134
- {/* Latitude icon (vertical) */}
135
- <div style={{ display: 'flex', alignItems: 'center' }}>
136
- <CustomIcon
137
- name="SpacingHeight"
138
- width={14}
139
- height={14}
140
- color={iconColor}
141
- />
142
- <span style={{ fontWeight: 600, marginLeft: '4px' }}>{coordinates[0]}</span>
143
- </div>
144
- {/* Longitude icon (horizontal) */}
145
- <div style={{ display: 'flex', alignItems: 'center' }}>
146
- <CustomIcon
147
- name="SpacingWidth"
148
- width={14}
149
- height={14}
150
- color={iconColor}
151
- />
152
- <span style={{ fontWeight: 600, marginLeft: '4px' }}>{coordinates[1]}</span>
153
- </div>
154
- </div>
155
- ),
156
- },
157
- ];
158
- }}
159
- renderTooltipForTerritory={(data) => {
160
- return [
161
- {
162
- label: t("Plot Name"),
163
- value: data.plotName || data.name || "--",
164
- },
165
- ];
166
- }}
167
- renderTooltipTags={() => { }}
168
- type="location-territory"
169
- />
170
- </Widget>
171
- </section>
172
- );
14
+ const defaultConfig = useMemo(
15
+ () => ({
16
+ basepath: "planting-cycle",
17
+ url: `/summary/${id}/locations`,
18
+ stop: !id,
19
+ }),
20
+ [id],
21
+ );
22
+
23
+ const customGetData = useMemo(() => {
24
+ if (getSummaryDetail && id) {
25
+ return ({ url, params = {} }) => {
26
+ const match = url.match(/\/summary\/[^/]+\/(.+)/);
27
+ if (match) {
28
+ const [, type] = match;
29
+ return getSummaryDetail(id, type, params);
30
+ }
31
+ throw new Error(`Invalid URL format: ${url}`);
32
+ };
33
+ }
34
+ return undefined;
35
+ }, [getSummaryDetail, id]);
36
+
37
+ const { loading: plantingLocationsLoading, data: plantingLocationsData } = useWidgetFetch({
38
+ config: defaultConfig,
39
+ getData: customGetData
40
+ });
41
+
42
+
43
+ const mappedData = useMemo(() => {
44
+ if (!plantingLocationsData || !plantingLocationsData.events) {
45
+ return [];
46
+ }
47
+
48
+ const { locations = [], events } = plantingLocationsData;
49
+
50
+ // Filter events that have valid GPS coordinates
51
+ const eventsWithGPS = events.filter(event =>
52
+ event.locationCheckArrival &&
53
+ event.locationCheckArrival.latitude &&
54
+ event.locationCheckArrival.longitude
55
+ );
56
+
57
+ return eventsWithGPS.map((event, index) => {
58
+ const locationCheckArrival = event.locationCheckArrival;
59
+
60
+ const matchingLocation = locations.find(location =>
61
+ locationCheckArrival.name === location.name ||
62
+ locationCheckArrival._id === location.id ||
63
+ location.id === locationCheckArrival._id
64
+ ) || locations[0];
65
+
66
+
67
+ const area = matchingLocation?.perimeter ? matchingLocation.perimeter.map(coord =>
68
+ Array.isArray(coord) && coord.length >= 2
69
+ ? [coord[1], coord[0]]
70
+ : coord
71
+ ) : null;
72
+
73
+ // Only include area if it has at least 3 valid coordinates
74
+ const validArea = area && Array.isArray(area) && area.length >= 3 ? area : null;
75
+
76
+
77
+ const gps = {
78
+ latitude: locationCheckArrival.latitude,
79
+ longitude: locationCheckArrival.longitude
80
+ };
81
+
82
+
83
+ const color = "#15FFFFB2"
84
+
85
+ const locationName = matchingLocation?.name || locationCheckArrival.name || 'Planting Location';
86
+
87
+ return {
88
+ _id: locationCheckArrival._id || event._id || {},
89
+ area: validArea,
90
+ color: color,
91
+ datastakeId: `LOC-${String(index + 1).padStart(9, '0')}`,
92
+ gps: gps,
93
+ id: matchingLocation?.id || locationCheckArrival._id || `event-${index}`,
94
+ name: event.name || t("Activity Start"),
95
+ date: event.date,
96
+ sources: 1,
97
+ subTitle: event.date ? renderDateFormatted(event.date, "DD MMM YY") : locationName,
98
+ plotName: locationName,
99
+ territoryTitle: locationName,
100
+ type: 'Planting Location'
101
+ };
102
+ });
103
+ }, [plantingLocationsData, t]);
104
+
105
+ return (
106
+ <section>
107
+ <Widget
108
+ title={t("Planting Locations")}
109
+ className="no-px h-w-btn-header no-pt-body no-p-body no-pb-body"
110
+ style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
111
+ >
112
+ <MineSiteMap
113
+ data={mappedData}
114
+ link
115
+ style={{ height: '100%', width: '100%' }}
116
+ maxZoom={18}
117
+ isSatellite={true}
118
+ onClickLink={() => { }}
119
+ onFilterChange={() => { }}
120
+ primaryLink
121
+ renderTooltipForLocation={(data) => {
122
+ const coordinates = data.gps?.latitude && data.gps?.longitude
123
+ ? convertDMS(data.gps.latitude, data.gps.longitude)
124
+ : null;
125
+
126
+ if (!coordinates) {
127
+ return [];
128
+ }
129
+
130
+ const iconColor = "#016C6E"; // Activity Start color
131
+
132
+ return [
133
+ {
134
+ label: t("Coordinates"),
135
+ value: (
136
+ <div style={{ display: 'flex', alignItems: 'center', gap: '6px', flexWrap: 'nowrap' }}>
137
+ {/* Latitude icon (vertical) */}
138
+ <div style={{ display: 'flex', alignItems: 'center' }}>
139
+ <CustomIcon
140
+ name="SpacingHeight"
141
+ width={14}
142
+ height={14}
143
+ color={iconColor}
144
+ />
145
+ <span style={{ fontWeight: 600, marginLeft: '4px' }}>{coordinates[0]}</span>
146
+ </div>
147
+ {/* Longitude icon (horizontal) */}
148
+ <div style={{ display: 'flex', alignItems: 'center' }}>
149
+ <CustomIcon
150
+ name="SpacingWidth"
151
+ width={14}
152
+ height={14}
153
+ color={iconColor}
154
+ />
155
+ <span style={{ fontWeight: 600, marginLeft: '4px' }}>{coordinates[1]}</span>
156
+ </div>
157
+ </div>
158
+ ),
159
+ },
160
+ ];
161
+ }}
162
+ renderTooltipForTerritory={(data) => {
163
+ return [
164
+ {
165
+ label: t("Plot Name"),
166
+ value: data.plotName || data.name || "--",
167
+ },
168
+ ];
169
+ }}
170
+ renderTooltipTags={() => { }}
171
+ type="location-territory"
172
+ />
173
+ </Widget>
174
+ </section>
175
+ );
173
176
  };
174
177
 
175
178
  export default PlantingLocations;
176
179
 
180
+
181
+