datastake-daf 0.6.777 → 0.6.779

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.
@@ -9546,24 +9546,29 @@ const processConditionalTableKeys = (tableKeys, item) => {
9546
9546
  });
9547
9547
  return processedKeys;
9548
9548
  };
9549
- const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, getAppHeader = () => {}, app, allValues, formValues = {}) => {
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] : {};
9550
9555
  switch (type) {
9551
9556
  case 'year':
9552
9557
  return value !== '-' ? renderDateFormatted(value, 'YYYY', 'en') : '-';
9553
9558
  case 'date':
9554
9559
  {
9555
- const language = user?.language && user?.language === 'sp' ? 'es' : user?.language;
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;
9556
9561
  return value !== '-' ? renderDateFormatted(value, 'DD MMM YYYY', language || 'en') : '-';
9557
9562
  }
9558
9563
  case 'select':
9559
9564
  {
9560
- const options = config?.options || [];
9565
+ const options = (config === null || config === void 0 ? void 0 : config.options) || [];
9561
9566
  const option = findOptions(value, options);
9562
9567
  return option;
9563
9568
  }
9564
9569
  case 'multiselect':
9565
9570
  {
9566
- const options = config?.options || [];
9571
+ const options = (config === null || config === void 0 ? void 0 : config.options) || [];
9567
9572
  const _val = typeof value === 'string' ? value.split(',').map(v => v.trim()) : value;
9568
9573
  const option = findOptions(_val, options);
9569
9574
  return option.join(', ');
@@ -9578,7 +9583,7 @@ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, ge
9578
9583
  formValues: formValues
9579
9584
  });
9580
9585
  case 'percentage':
9581
- return value === '-' || value === null || value === undefined ? '-' : `${value} %`;
9586
+ return value === '-' || value === null || value === undefined ? '-' : "".concat(value, " %");
9582
9587
  case 'geolocation':
9583
9588
  {
9584
9589
  const val = JSON.parse(value) || {};
@@ -9592,7 +9597,7 @@ const renderFieldData = (type, value, user, config, getApiBaseUrl = () => {}, ge
9592
9597
  case 'upload':
9593
9598
  case 'videoUpload':
9594
9599
  {
9595
- const documentName = allValues?.map(item => item?.name).join(', ');
9600
+ const documentName = allValues === null || allValues === void 0 ? void 0 : allValues.map(item => item === null || item === void 0 ? void 0 : item.name).join(', ');
9596
9601
  return documentName;
9597
9602
  }
9598
9603
  default:
@@ -9716,19 +9721,18 @@ const resolveDynamicLabel = (labelConfig, item, defaultLabel) => {
9716
9721
  return labelConfig || defaultLabel;
9717
9722
  };
9718
9723
 
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;
9724
+ const handleSectionChildren = ({
9725
+ config,
9726
+ allData,
9727
+ level,
9728
+ t,
9729
+ rootForm,
9730
+ user,
9731
+ getApiBaseUrl = () => {},
9732
+ getAppHeader = () => {},
9733
+ app,
9734
+ TreeNodeComponent
9735
+ }) => {
9732
9736
  if (!(level === 0 && config && typeof config === 'object')) {
9733
9737
  return null;
9734
9738
  }
@@ -9742,14 +9746,14 @@ const handleSectionChildren = _ref => {
9742
9746
  let fieldValue;
9743
9747
 
9744
9748
  // Determine field value based on type
9745
- if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData === null || allData === void 0 ? void 0 : allData[fieldKey])) {
9749
+ if (fieldConfig.type === 'dataLinkGroup' && Array.isArray(allData?.[fieldKey])) {
9746
9750
  fieldValue = allData[fieldKey];
9747
- } else if (fieldConfig.type === 'dataLinkGroup' && allData !== null && allData !== void 0 && allData[fieldKey]) {
9751
+ } else if (fieldConfig.type === 'dataLinkGroup' && allData?.[fieldKey]) {
9748
9752
  fieldValue = allData[fieldKey];
9749
9753
  } else if (fieldConfig.type === 'group') {
9750
9754
  fieldValue = {};
9751
9755
  } else {
9752
- fieldValue = allData === null || allData === void 0 ? void 0 : allData[fieldKey];
9756
+ fieldValue = allData?.[fieldKey];
9753
9757
  }
9754
9758
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
9755
9759
  nodeKey: fieldKey,
@@ -10166,42 +10170,37 @@ const handleDataLinkGroupWithTableKeys = ({
10166
10170
  }
10167
10171
  };
10168
10172
 
10169
- const handleDataLinkWithTableKeys = _ref => {
10170
- var _inputConfig$meta, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
10171
- let {
10172
- inputConfig,
10173
- inputKey,
10174
- value,
10175
- level,
10176
- t,
10177
- rootForm,
10178
- allData,
10179
- user,
10180
- getApiBaseUrl = () => {},
10181
- getAppHeader = () => {},
10182
- app,
10183
- TreeNodeComponent
10184
- } = _ref;
10185
- 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)) {
10173
+ const handleDataLinkWithTableKeys = ({
10174
+ inputConfig,
10175
+ inputKey,
10176
+ value,
10177
+ level,
10178
+ t,
10179
+ rootForm,
10180
+ allData,
10181
+ user,
10182
+ getApiBaseUrl = () => {},
10183
+ getAppHeader = () => {},
10184
+ app,
10185
+ TreeNodeComponent
10186
+ }) => {
10187
+ if (inputConfig?.type !== 'dataLink' || !inputConfig?.meta?.tableKeys) {
10186
10188
  return null;
10187
10189
  }
10188
10190
  const tableKeys = inputConfig.meta.tableKeys;
10189
- const isAjaxModal = React.useMemo(() => {
10190
- var _inputConfig$meta2;
10191
- return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
10192
- }, [inputConfig]);
10191
+ const isAjaxModal = React.useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
10193
10192
  const ajaxModalValues = useAjaxModal$2({
10194
10193
  name: inputKey,
10195
10194
  user,
10196
- namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
10197
- skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
10195
+ namespace: inputConfig?.meta?.namespace,
10196
+ skipFetch: inputConfig?.meta?.skipFetch,
10198
10197
  isAjaxModal,
10199
- formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
10198
+ formScope: inputConfig?.meta?.formScope,
10200
10199
  APP: app,
10201
10200
  apiBaseUrl: getApiBaseUrl(),
10202
10201
  _getAppHeader: getAppHeader
10203
10202
  });
10204
- const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
10203
+ const dataLinkForm = ajaxModalValues?.form;
10205
10204
  const createInputsAndValues = item => {
10206
10205
  const inputs = {};
10207
10206
  const values = {};
@@ -10214,20 +10213,19 @@ const handleDataLinkWithTableKeys = _ref => {
10214
10213
  };
10215
10214
  const isUploadFieldEmpty = (fieldKey, itemToCheck) => {
10216
10215
  if (uploadTypeFields.includes(fieldKey)) {
10217
- const itemValue = itemToCheck === null || itemToCheck === void 0 ? void 0 : itemToCheck[fieldKey];
10216
+ const itemValue = itemToCheck?.[fieldKey];
10218
10217
  return itemValue === undefined || itemValue === null || Array.isArray(itemValue) && itemValue.length === 0;
10219
10218
  }
10220
10219
  return false;
10221
10220
  };
10222
10221
  const processedTableKeys = processConditionalTableKeys(tableKeys, item);
10223
10222
  processedTableKeys.filter(tableKey => tableKey !== 'datastakeId').filter(tableKey => !isUploadFieldEmpty(tableKey, item)).forEach(tableKey => {
10224
- var _dataLinkForm$identif;
10225
- 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]);
10223
+ const formInputConfig = dataLinkForm?.[tableKey] || dataLinkForm?.['identification']?.[tableKey];
10226
10224
  if (formInputConfig) {
10227
- var _item$linking, _formInputConfig$meta, _formInputConfig$tabl;
10228
- inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10225
+ inputs[tableKey] = {
10226
+ ...formInputConfig,
10229
10227
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
10230
- });
10228
+ };
10231
10229
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10232
10230
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10233
10231
  let resolvedLabel = null;
@@ -10235,7 +10233,7 @@ const handleDataLinkWithTableKeys = _ref => {
10235
10233
  const parts = labelKey.split(' is ');
10236
10234
  if (parts.length === 2) {
10237
10235
  const [conditionKey, conditionValue] = parts;
10238
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10236
+ if (item?.[conditionKey] === conditionValue) {
10239
10237
  resolvedLabel = formInputConfig.label[labelKey];
10240
10238
  break;
10241
10239
  }
@@ -10243,17 +10241,16 @@ const handleDataLinkWithTableKeys = _ref => {
10243
10241
  }
10244
10242
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
10245
10243
  }
10246
- 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]);
10244
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item[formInputConfig?.meta?.onNewSetValueKey] || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[tableKey];
10247
10245
  } else {
10248
- var _item$linking2;
10249
10246
  inputs[tableKey] = {
10250
10247
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
10251
- type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
10248
+ type: inputConfig?.type
10252
10249
  };
10253
- 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]);
10250
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[tableKey];
10254
10251
  }
10255
10252
  });
10256
- if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
10253
+ if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
10257
10254
  Object.keys(dataLinkForm.identification).filter(fieldKey => {
10258
10255
  if (uploadTypeFields.includes(fieldKey)) {
10259
10256
  return !isUploadFieldEmpty(fieldKey, item);
@@ -10263,11 +10260,11 @@ const handleDataLinkWithTableKeys = _ref => {
10263
10260
  const formInputConfig = dataLinkForm.identification[fieldKey];
10264
10261
  return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
10265
10262
  }).forEach(fieldKey => {
10266
- var _item$linking3, _formInputConfig$tabl2;
10267
10263
  const formInputConfig = dataLinkForm.identification[fieldKey];
10268
- inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10264
+ inputs[fieldKey] = {
10265
+ ...formInputConfig,
10269
10266
  label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
10270
- });
10267
+ };
10271
10268
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10272
10269
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10273
10270
  let resolvedLabel = null;
@@ -10275,7 +10272,7 @@ const handleDataLinkWithTableKeys = _ref => {
10275
10272
  const parts = labelKey.split(' is ');
10276
10273
  if (parts.length === 2) {
10277
10274
  const [conditionKey, conditionValue] = parts;
10278
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10275
+ if (item?.[conditionKey] === conditionValue) {
10279
10276
  resolvedLabel = formInputConfig.label[labelKey];
10280
10277
  break;
10281
10278
  }
@@ -10283,7 +10280,7 @@ const handleDataLinkWithTableKeys = _ref => {
10283
10280
  }
10284
10281
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
10285
10282
  }
10286
- 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]);
10283
+ values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[fieldKey];
10287
10284
  });
10288
10285
  }
10289
10286
  return {
@@ -10293,7 +10290,7 @@ const handleDataLinkWithTableKeys = _ref => {
10293
10290
  };
10294
10291
  if (Array.isArray(value)) {
10295
10292
  return value.map((item, itemIndex) => {
10296
- const datastakeIdValue = item === null || item === void 0 ? void 0 : item.datastakeId;
10293
+ const datastakeIdValue = item?.datastakeId;
10297
10294
  const {
10298
10295
  inputs,
10299
10296
  values
@@ -10302,9 +10299,9 @@ const handleDataLinkWithTableKeys = _ref => {
10302
10299
  return null;
10303
10300
  }
10304
10301
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
10305
- nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10302
+ nodeKey: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10306
10303
  config: {
10307
- label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10304
+ label: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10308
10305
  type: 'custom-datalink',
10309
10306
  inputs: inputs
10310
10307
  },
@@ -10318,10 +10315,10 @@ const handleDataLinkWithTableKeys = _ref => {
10318
10315
  getApiBaseUrl: getApiBaseUrl,
10319
10316
  getAppHeader: getAppHeader,
10320
10317
  app: app
10321
- }, "".concat(inputKey, "-").concat(itemIndex));
10318
+ }, `${inputKey}-${itemIndex}`);
10322
10319
  });
10323
10320
  } else {
10324
- const datastakeIdValue = value === null || value === void 0 ? void 0 : value.datastakeId;
10321
+ const datastakeIdValue = value?.datastakeId;
10325
10322
  const {
10326
10323
  inputs,
10327
10324
  values
@@ -10346,7 +10343,7 @@ const handleDataLinkWithTableKeys = _ref => {
10346
10343
  getApiBaseUrl: getApiBaseUrl,
10347
10344
  getAppHeader: getAppHeader,
10348
10345
  app: app
10349
- }, "".concat(inputKey, "-single"));
10346
+ }, `${inputKey}-single`);
10350
10347
  }
10351
10348
  };
10352
10349
 
@@ -42770,6 +42770,7 @@ const PlantingLocations = ({
42770
42770
  longitude: locationCheckArrival.longitude
42771
42771
  };
42772
42772
  const color = "#15FFFFB2";
42773
+ const locationName = matchingLocation?.name || locationCheckArrival.name || 'Planting Location';
42773
42774
  return {
42774
42775
  _id: locationCheckArrival._id || event._id || {},
42775
42776
  area: area,
@@ -42777,13 +42778,16 @@ const PlantingLocations = ({
42777
42778
  datastakeId: `LOC-${String(index + 1).padStart(9, '0')}`,
42778
42779
  gps: gps,
42779
42780
  id: matchingLocation?.id || locationCheckArrival._id || `event-${index}`,
42780
- name: locationCheckArrival.name || matchingLocation?.name || `Event ${index + 1}`,
42781
+ name: event.name || t("Activity Start"),
42782
+ date: event.date,
42781
42783
  sources: 1,
42782
- subTitle: locationCheckArrival.name || matchingLocation?.name || 'Planting Location',
42784
+ subTitle: event.date ? renderDateFormatted(event.date, "DD MMM YY") : locationName,
42785
+ plotName: locationName,
42786
+ territoryTitle: locationName,
42783
42787
  type: 'Planting Location'
42784
42788
  };
42785
42789
  });
42786
- }, [plantingLocationsData]);
42790
+ }, [plantingLocationsData, t]);
42787
42791
  return /*#__PURE__*/jsxRuntime.jsx("section", {
42788
42792
  children: /*#__PURE__*/jsxRuntime.jsx(Widget, {
42789
42793
  title: t("Planting Locations"),
@@ -42805,7 +42809,66 @@ const PlantingLocations = ({
42805
42809
  onClickLink: () => {},
42806
42810
  onFilterChange: () => {},
42807
42811
  primaryLink: true,
42808
- renderTooltip: () => {},
42812
+ renderTooltipForLocation: data => {
42813
+ const coordinates = data.gps?.latitude && data.gps?.longitude ? convertDMS(data.gps.latitude, data.gps.longitude) : null;
42814
+ if (!coordinates) {
42815
+ return [];
42816
+ }
42817
+ const iconColor = "#016C6E"; // Activity Start color
42818
+
42819
+ return [{
42820
+ label: t("Coordinates"),
42821
+ value: /*#__PURE__*/jsxRuntime.jsxs("div", {
42822
+ style: {
42823
+ display: 'flex',
42824
+ alignItems: 'center',
42825
+ gap: '6px',
42826
+ flexWrap: 'nowrap'
42827
+ },
42828
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
42829
+ style: {
42830
+ display: 'flex',
42831
+ alignItems: 'center'
42832
+ },
42833
+ children: [/*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
42834
+ name: "SpacingHeight",
42835
+ width: 14,
42836
+ height: 14,
42837
+ color: iconColor
42838
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
42839
+ style: {
42840
+ fontWeight: 600,
42841
+ marginLeft: '4px'
42842
+ },
42843
+ children: coordinates[0]
42844
+ })]
42845
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
42846
+ style: {
42847
+ display: 'flex',
42848
+ alignItems: 'center'
42849
+ },
42850
+ children: [/*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
42851
+ name: "SpacingWidth",
42852
+ width: 14,
42853
+ height: 14,
42854
+ color: iconColor
42855
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
42856
+ style: {
42857
+ fontWeight: 600,
42858
+ marginLeft: '4px'
42859
+ },
42860
+ children: coordinates[1]
42861
+ })]
42862
+ })]
42863
+ })
42864
+ }];
42865
+ },
42866
+ renderTooltipForTerritory: data => {
42867
+ return [{
42868
+ label: t("Plot Name"),
42869
+ value: data.plotName || data.name || "--"
42870
+ }];
42871
+ },
42809
42872
  renderTooltipTags: () => {},
42810
42873
  type: "location-territory"
42811
42874
  })
@@ -42957,11 +43020,9 @@ const processChartDateData = ({
42957
43020
  isCumulative = false,
42958
43021
  valueField = 'total'
42959
43022
  }) => {
42960
- if (!mainData || !Array.isArray(mainData) || mainData.length === 0) {
42961
- return [];
42962
- }
42963
43023
  const timeQuantity = getTimeQuantity(filter);
42964
- const dates = mainData;
43024
+ const dates = mainData || [];
43025
+ const isEmpty = !mainData || !Array.isArray(mainData) || mainData.length === 0;
42965
43026
  const _data = [];
42966
43027
  let end = filters?.timeframe?.endDate || dayjs__default["default"]();
42967
43028
  let start = filters?.timeframe?.startDate || dayjs__default["default"]().add(-12, timeQuantity);
@@ -42993,7 +43054,7 @@ const processChartDateData = ({
42993
43054
  let currentDate = start.clone();
42994
43055
  while (currentDate.isBefore(end) || currentDate.isSame(end, filter === "daily" ? "day" : filter === "weekly" ? "week" : "month")) {
42995
43056
  // Filter data points that fall within this period
42996
- const score = dates.filter(d => {
43057
+ const score = isEmpty ? 0 : dates.filter(d => {
42997
43058
  if (!d.date) return false;
42998
43059
  switch (filter) {
42999
43060
  case "daily":
@@ -43139,19 +43200,12 @@ const RestoredArea = ({
43139
43200
  } = useTimeFilter({
43140
43201
  defaultFilter: 'monthly'
43141
43202
  });
43142
-
43143
- // Map restoredAreaChart data to LineChart format with time filter support
43144
- // Y-axis: total/cumulated value
43145
- // X-axis: date (formatted based on timeFilter)
43146
- // Fill all periods in the range, even if empty
43147
43203
  const restoredAreaChartData = React.useMemo(() => {
43148
- if (!restoredAreaChart || !Array.isArray(restoredAreaChart) || restoredAreaChart.length === 0) {
43149
- return [];
43150
- }
43204
+ const dataToProcess = !restoredAreaChart || !Array.isArray(restoredAreaChart) || restoredAreaChart.length === 0 ? [] : restoredAreaChart;
43151
43205
 
43152
43206
  // Process data with cumulative calculation (for restored area)
43153
43207
  return processChartDateData({
43154
- mainData: restoredAreaChart,
43208
+ mainData: dataToProcess,
43155
43209
  isCumulative: true,
43156
43210
  valueField: 'total'
43157
43211
  });
@@ -43289,18 +43343,12 @@ const PlantingActivitiesTimeline = ({
43289
43343
  } = useTimeFilter({
43290
43344
  defaultFilter: 'monthly'
43291
43345
  });
43292
-
43293
- // Map activitiesTimelineChart data to ColumnChart format with time filter support
43294
- // Data structure: [{count: 2, date: "2025-11-03"}]
43295
- // Fill all periods in the range, even if empty
43296
43346
  const activitiesTimelineData = React.useMemo(() => {
43297
- if (!activitiesTimelineChart || !Array.isArray(activitiesTimelineChart) || activitiesTimelineChart.length === 0) {
43298
- return [];
43299
- }
43347
+ const dataToProcess = !activitiesTimelineChart || !Array.isArray(activitiesTimelineChart) || activitiesTimelineChart.length === 0 ? [] : activitiesTimelineChart;
43300
43348
 
43301
43349
  // Process data without cumulative calculation (for activities timeline)
43302
43350
  return processChartDateData({
43303
- mainData: activitiesTimelineChart,
43351
+ mainData: dataToProcess,
43304
43352
  isCumulative: false,
43305
43353
  valueField: 'count'
43306
43354
  });
@@ -44225,14 +44273,13 @@ const JobsTimeline = ({
44225
44273
  });
44226
44274
  const jobsData = Array.isArray(dayJobsTimeline) ? dayJobsTimeline : dayJobsTimeline?.jobsTimeline || dayJobsTimeline?.jobs || dayJobsTimeline?.timeline || [];
44227
44275
  const jobsTimelineData = React.useMemo(() => {
44228
- if (!jobsData || !Array.isArray(jobsData) || jobsData.length === 0) {
44229
- return [];
44230
- }
44276
+ // Always process data, even if empty, to generate default date range for x-axis
44277
+ const dataToProcess = !jobsData || !Array.isArray(jobsData) || jobsData.length === 0 ? [] : jobsData;
44231
44278
 
44232
44279
  // Process data without cumulative calculation (for jobs timeline)
44233
44280
  // Try to find value in total, count, jobs, or value fields
44234
44281
  return processChartDateData({
44235
- mainData: jobsData,
44282
+ mainData: dataToProcess,
44236
44283
  isCumulative: false,
44237
44284
  valueField: 'total' // Will fallback to count/jobs/value if total doesn't exist
44238
44285
  });
@@ -44855,9 +44902,10 @@ const getColumns = ({
44855
44902
  className: "daf-default-cell"
44856
44903
  });
44857
44904
  }
44905
+ const title = findOptions(value, selectOptions?.implPartnersCategory || []) || '-';
44858
44906
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44859
- title: value,
44860
- children: value || '-'
44907
+ title: title,
44908
+ children: title
44861
44909
  });
44862
44910
  }
44863
44911
  }, {
@@ -44871,9 +44919,10 @@ const getColumns = ({
44871
44919
  className: "daf-default-cell"
44872
44920
  });
44873
44921
  }
44922
+ const title = findOptions(value, selectOptions?.implPartnersSubcategory || []) || '-';
44874
44923
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
44875
- title: value,
44876
- children: value || '-'
44924
+ title: title,
44925
+ children: title
44877
44926
  });
44878
44927
  }
44879
44928
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.777",
3
+ "version": "0.6.779",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -348,7 +348,8 @@ export const getColumns = ({
348
348
  if (all.empty) {
349
349
  return <div className="daf-default-cell" />;
350
350
  }
351
- return <Tooltip title={value}>{value || '-'}</Tooltip>;
351
+ const title = findOptions(value, selectOptions?.implPartnersCategory || []) || '-';
352
+ return <Tooltip title={title}>{title}</Tooltip>;
352
353
  },
353
354
  },
354
355
  {
@@ -360,7 +361,8 @@ export const getColumns = ({
360
361
  if (all.empty) {
361
362
  return <div className="daf-default-cell" />;
362
363
  }
363
- return <Tooltip title={value}>{value || '-'}</Tooltip>;
364
+ const title = findOptions(value, selectOptions?.implPartnersSubcategory || []) || '-';
365
+ return <Tooltip title={title}>{title}</Tooltip>;
364
366
  },
365
367
  },
366
368
  {
@@ -50,6 +50,7 @@ const AssociatedInformation = ({
50
50
  }) => {
51
51
  const [activeTab, setActiveTab] = useState(ACTIVITIES_TAB);
52
52
  const [search, setSearch] = useState('');
53
+
53
54
 
54
55
  const searchFields = useMemo(() => searchFieldsMap(activeTab), [activeTab, searchFieldsMap]);
55
56
 
@@ -21,14 +21,15 @@ const JobsTimeline = ({
21
21
  : (dayJobsTimeline?.jobsTimeline || dayJobsTimeline?.jobs || dayJobsTimeline?.timeline || []);
22
22
 
23
23
  const jobsTimelineData = useMemo(() => {
24
- if (!jobsData || !Array.isArray(jobsData) || jobsData.length === 0) {
25
- return [];
26
- }
24
+ // Always process data, even if empty, to generate default date range for x-axis
25
+ const dataToProcess = (!jobsData || !Array.isArray(jobsData) || jobsData.length === 0)
26
+ ? []
27
+ : jobsData;
27
28
 
28
29
  // Process data without cumulative calculation (for jobs timeline)
29
30
  // Try to find value in total, count, jobs, or value fields
30
31
  return processChartDateData({
31
- mainData: jobsData,
32
+ mainData: dataToProcess,
32
33
  isCumulative: false,
33
34
  valueField: 'total', // Will fallback to count/jobs/value if total doesn't exist
34
35
  });
@@ -15,17 +15,15 @@ const PlantingActivitiesTimeline = ({
15
15
  }) => {
16
16
  const { timeFilter, setTimeFilter, formatDateAxis, processChartDateData } = useTimeFilter({ defaultFilter: 'monthly' });
17
17
 
18
- // Map activitiesTimelineChart data to ColumnChart format with time filter support
19
- // Data structure: [{count: 2, date: "2025-11-03"}]
20
- // Fill all periods in the range, even if empty
18
+
21
19
  const activitiesTimelineData = useMemo(() => {
22
- if (!activitiesTimelineChart || !Array.isArray(activitiesTimelineChart) || activitiesTimelineChart.length === 0) {
23
- return [];
24
- }
20
+ const dataToProcess = (!activitiesTimelineChart || !Array.isArray(activitiesTimelineChart) || activitiesTimelineChart.length === 0)
21
+ ? []
22
+ : activitiesTimelineChart;
25
23
 
26
24
  // Process data without cumulative calculation (for activities timeline)
27
25
  return processChartDateData({
28
- mainData: activitiesTimelineChart,
26
+ mainData: dataToProcess,
29
27
  isCumulative: false,
30
28
  valueField: 'count',
31
29
  });
@@ -15,18 +15,14 @@ const RestoredArea = ({
15
15
  }) => {
16
16
  const { timeFilter, setTimeFilter, formatDateAxis, processChartDateData } = useTimeFilter({ defaultFilter: 'monthly' });
17
17
 
18
- // Map restoredAreaChart data to LineChart format with time filter support
19
- // Y-axis: total/cumulated value
20
- // X-axis: date (formatted based on timeFilter)
21
- // Fill all periods in the range, even if empty
22
18
  const restoredAreaChartData = useMemo(() => {
23
- if (!restoredAreaChart || !Array.isArray(restoredAreaChart) || restoredAreaChart.length === 0) {
24
- return [];
25
- }
19
+ const dataToProcess = (!restoredAreaChart || !Array.isArray(restoredAreaChart) || restoredAreaChart.length === 0)
20
+ ? []
21
+ : restoredAreaChart;
26
22
 
27
23
  // Process data with cumulative calculation (for restored area)
28
24
  return processChartDateData({
29
- mainData: restoredAreaChart,
25
+ mainData: dataToProcess,
30
26
  isCumulative: true,
31
27
  valueField: 'total',
32
28
  });
@@ -1,6 +1,9 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { Widget, MineSiteMap } from '../../../../../../../../src/index.js';
3
3
  import { useWidgetFetch } from '../../../../../../hooks/useWidgetFetch.js';
4
+ import { convertDMS } from '../../../../../../../../src/helpers/Map';
5
+ import CustomIcon from '../../../../../../../../src/@daf/core/components/Icon/CustomIcon.jsx';
6
+ import { renderDateFormatted } from '../../../../../../../../src/helpers/Forms';
4
7
 
5
8
  const PlantingLocations = ({
6
9
  id,
@@ -76,6 +79,8 @@ const PlantingLocations = ({
76
79
 
77
80
  const color = "#15FFFFB2"
78
81
 
82
+ const locationName = matchingLocation?.name || locationCheckArrival.name || 'Planting Location';
83
+
79
84
  return {
80
85
  _id: locationCheckArrival._id || event._id || {},
81
86
  area: area,
@@ -83,13 +88,16 @@ const PlantingLocations = ({
83
88
  datastakeId: `LOC-${String(index + 1).padStart(9, '0')}`,
84
89
  gps: gps,
85
90
  id: matchingLocation?.id || locationCheckArrival._id || `event-${index}`,
86
- name: locationCheckArrival.name || matchingLocation?.name || `Event ${index + 1}`,
91
+ name: event.name || t("Activity Start"),
92
+ date: event.date,
87
93
  sources: 1,
88
- subTitle: locationCheckArrival.name || matchingLocation?.name || 'Planting Location',
94
+ subTitle: event.date ? renderDateFormatted(event.date, "DD MMM YY") : locationName,
95
+ plotName: locationName,
96
+ territoryTitle: locationName,
89
97
  type: 'Planting Location'
90
98
  };
91
99
  });
92
- }, [plantingLocationsData]);
100
+ }, [plantingLocationsData, t]);
93
101
 
94
102
  return (
95
103
  <section>
@@ -107,7 +115,55 @@ const PlantingLocations = ({
107
115
  onClickLink={() => { }}
108
116
  onFilterChange={() => { }}
109
117
  primaryLink
110
- renderTooltip={() => { }}
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
+ }}
111
167
  renderTooltipTags={() => { }}
112
168
  type="location-territory"
113
169
  />
@@ -99,12 +99,9 @@ export const processChartDateData = ({
99
99
  isCumulative = false,
100
100
  valueField = 'total'
101
101
  }) => {
102
- if (!mainData || !Array.isArray(mainData) || mainData.length === 0) {
103
- return [];
104
- }
105
-
106
102
  const timeQuantity = getTimeQuantity(filter);
107
- const dates = mainData;
103
+ const dates = mainData || [];
104
+ const isEmpty = !mainData || !Array.isArray(mainData) || mainData.length === 0;
108
105
 
109
106
  const _data = [];
110
107
  let end = filters?.timeframe?.endDate || dayjs();
@@ -140,7 +137,7 @@ export const processChartDateData = ({
140
137
  let currentDate = start.clone();
141
138
  while (currentDate.isBefore(end) || currentDate.isSame(end, filter === "daily" ? "day" : filter === "weekly" ? "week" : "month")) {
142
139
  // Filter data points that fall within this period
143
- const score = dates
140
+ const score = isEmpty ? 0 : dates
144
141
  .filter((d) => {
145
142
  if (!d.date) return false;
146
143
  switch (filter) {