datastake-daf 0.6.110 → 0.6.112

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.
@@ -13548,6 +13548,13 @@ function Geolocation$2({
13548
13548
 
13549
13549
  const evaluateShowIfCondition = (condition, item) => {
13550
13550
  if (!condition || !item) return false;
13551
+ if (condition.includes(' notEmpty ')) {
13552
+ const parts = condition.split(' notEmpty ');
13553
+ if (parts.length === 2) {
13554
+ const [field, expectedValue] = parts.map(p => p.trim());
13555
+ return item[field] !== '' || item[field] !== null || item[field] !== undefined;
13556
+ }
13557
+ }
13551
13558
 
13552
13559
  // Handle boolean AND operations
13553
13560
  if (condition.includes(' && ')) {
@@ -13711,7 +13718,7 @@ const renderValue = ({
13711
13718
  displayValue = '-';
13712
13719
  } else if (typeof value === 'object' && value !== null) {
13713
13720
  if (Array.isArray(value)) {
13714
- displayValue = value.length > 0 ? value.join(', ') : '-'; // Changed from '' to '-'
13721
+ displayValue = value.length > 0 ? value.join(', ') : '-';
13715
13722
  } else if (value.name || value.fullName) {
13716
13723
  displayValue = value.name || value.fullName;
13717
13724
  } else if (value.label) {
@@ -14015,6 +14022,20 @@ function useAjaxModal$2({
14015
14022
  };
14016
14023
  }
14017
14024
 
14025
+ const mergeObject = obj => {
14026
+ return Object.entries(obj).reduce((acc, [key, value]) => {
14027
+ if (typeof value === "object" && !Array.isArray(value) && value !== null) {
14028
+ return {
14029
+ ...acc,
14030
+ ...value
14031
+ };
14032
+ }
14033
+ return {
14034
+ ...acc,
14035
+ [key]: value
14036
+ };
14037
+ }, {});
14038
+ };
14018
14039
  const handleDataLinkGroupWithTableKeys = ({
14019
14040
  config,
14020
14041
  inputConfig,
@@ -14039,9 +14060,9 @@ const handleDataLinkGroupWithTableKeys = ({
14039
14060
  const otherConfig = config.inputs[otherInputKey];
14040
14061
  if (otherConfig?.type === 'dataLink') {
14041
14062
  const siblingTableKeys = otherConfig?.meta?.tableKeys || [];
14042
- const siblingAdditionalTableKeys = config.meta?.additionalTableKeys || [];
14043
- const siblingAllTableKeys = [...siblingTableKeys, ...siblingAdditionalTableKeys];
14044
- return siblingAllTableKeys.includes(inputKey) && otherInputKey !== inputKey;
14063
+ const additionalTableKeys = config.meta?.additionalTableKeys || [];
14064
+ const allSiblingKeys = [...siblingTableKeys, ...additionalTableKeys];
14065
+ return allSiblingKeys.includes(inputKey) && otherInputKey !== inputKey;
14045
14066
  }
14046
14067
  return false;
14047
14068
  });
@@ -14054,8 +14075,9 @@ const handleDataLinkGroupWithTableKeys = ({
14054
14075
  }
14055
14076
  const tableKeys = inputConfig.meta.tableKeys;
14056
14077
  const additionalTableKeys = config.meta?.additionalTableKeys || [];
14057
- [...new Set([...tableKeys, ...additionalTableKeys])];
14058
- Object.keys(config.inputs || {});
14078
+ const parentInputKeys = Object.keys(config.inputs || {});
14079
+ const siblingInputsMatchingTableKeys = parentInputKeys.filter(siblingKey => siblingKey !== inputKey).filter(siblingKey => tableKeys.includes(siblingKey) || additionalTableKeys.includes(siblingKey));
14080
+ [...new Set([...tableKeys, ...siblingInputsMatchingTableKeys])];
14059
14081
  const isAjaxModal = React.useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
14060
14082
  const ajaxModalValues = useAjaxModal$2({
14061
14083
  name: inputKey,
@@ -14110,6 +14132,16 @@ const handleDataLinkGroupWithTableKeys = ({
14110
14132
  values[tableKey] = item?.[tableKey];
14111
14133
  }
14112
14134
  });
14135
+ siblingInputsMatchingTableKeys.forEach(siblingKey => {
14136
+ const siblingConfig = config.inputs[siblingKey];
14137
+ if (siblingConfig) {
14138
+ inputs[siblingKey] = {
14139
+ ...siblingConfig,
14140
+ label: siblingConfig.label || siblingKey
14141
+ };
14142
+ values[siblingKey] = item?.[siblingKey];
14143
+ }
14144
+ });
14113
14145
  if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
14114
14146
  Object.keys(dataLinkForm.identification).filter(fieldKey => fieldKey !== 'datastakeId' && !tableKeys.includes(fieldKey)).filter(fieldKey => {
14115
14147
  const formInputConfig = dataLinkForm.identification[fieldKey];
@@ -14120,14 +14152,17 @@ const handleDataLinkGroupWithTableKeys = ({
14120
14152
  ...formInputConfig,
14121
14153
  label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
14122
14154
  };
14123
- if (formInputConfig.label && typeof formInputConfig.label === 'object') {
14124
- const dynamicLabelKeys = Object.keys(formInputConfig.label);
14155
+ if (formInputConfig?.label && typeof formInputConfig?.label === 'object') {
14156
+ const dynamicLabelKeys = Object.keys(formInputConfig?.label);
14125
14157
  let resolvedLabel = null;
14126
14158
  for (const labelKey of dynamicLabelKeys) {
14127
14159
  const parts = labelKey.split(' is ');
14128
14160
  if (parts.length === 2) {
14129
14161
  const [conditionKey, conditionValue] = parts;
14130
- if (item?.[conditionKey] === conditionValue) {
14162
+ const flattenedItem = Object.assign({}, item.location, {
14163
+ address: item.address
14164
+ });
14165
+ if (flattenedItem?.[conditionKey] === conditionValue) {
14131
14166
  resolvedLabel = formInputConfig.label[labelKey];
14132
14167
  break;
14133
14168
  }
@@ -14135,7 +14170,7 @@ const handleDataLinkGroupWithTableKeys = ({
14135
14170
  }
14136
14171
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
14137
14172
  }
14138
- values[fieldKey] = item?.[fieldKey];
14173
+ values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[fieldKey];
14139
14174
  });
14140
14175
  }
14141
14176
  return {
@@ -14145,11 +14180,12 @@ const handleDataLinkGroupWithTableKeys = ({
14145
14180
  };
14146
14181
  if (Array.isArray(value)) {
14147
14182
  return value.map((item, itemIndex) => {
14148
- const datastakeIdValue = item?.[inputKey]?.datastakeId || item?.datastakeId;
14183
+ const merged = mergeObject(item);
14184
+ const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
14149
14185
  const {
14150
14186
  inputs,
14151
14187
  values
14152
- } = createInputsAndValues(item);
14188
+ } = createInputsAndValues(merged);
14153
14189
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
14154
14190
  nodeKey: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
14155
14191
  config: {
@@ -14170,11 +14206,12 @@ const handleDataLinkGroupWithTableKeys = ({
14170
14206
  }, `${inputKey}-${itemIndex}`);
14171
14207
  });
14172
14208
  } else {
14173
- const datastakeIdValue = value?.[inputKey]?.datastakeId || value?.datastakeId;
14209
+ const merged = mergeObject(value);
14210
+ const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
14174
14211
  const {
14175
14212
  inputs,
14176
14213
  values
14177
- } = createInputsAndValues(value);
14214
+ } = createInputsAndValues(merged);
14178
14215
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
14179
14216
  nodeKey: datastakeIdValue || t('No ID'),
14180
14217
  config: {
@@ -14267,7 +14304,7 @@ const handleDataLinkWithTableKeys = ({
14267
14304
  }
14268
14305
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
14269
14306
  }
14270
- values[tableKey] = item?.[tableKey];
14307
+ values[tableKey] = item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[tableKey];
14271
14308
  } else {
14272
14309
  inputs[tableKey] = {
14273
14310
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
@@ -14306,7 +14343,7 @@ const handleDataLinkWithTableKeys = ({
14306
14343
  }
14307
14344
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
14308
14345
  }
14309
- values[fieldKey] = item?.[fieldKey];
14346
+ values[fieldKey] = item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[fieldKey];
14310
14347
  });
14311
14348
  }
14312
14349
  return {
@@ -14486,9 +14523,6 @@ const AjaxSubGroup$2 = ({
14486
14523
  _getAppHeader: getAppHeader
14487
14524
  });
14488
14525
  const ajaxForm = ajaxModalValues?.form;
14489
- console.log({
14490
- ajaxForm
14491
- });
14492
14526
  if (ajaxModalValues.isFetching) {
14493
14527
  return /*#__PURE__*/jsxRuntime.jsx("div", {
14494
14528
  className: "ajax-subgroup-loading",
@@ -14502,9 +14536,6 @@ const AjaxSubGroup$2 = ({
14502
14536
  });
14503
14537
  }
14504
14538
  const formInputs = Object.values(ajaxForm || {})[0] || {};
14505
- console.log({
14506
- formInputs
14507
- });
14508
14539
  const sortedRecords = value.sort((a, b) => {
14509
14540
  const yearA = parseInt(a.meta?.year || '0');
14510
14541
  const yearB = parseInt(b.meta?.year || '0');
@@ -20351,7 +20382,7 @@ function SDGWidget(_ref) {
20351
20382
  })
20352
20383
  }));
20353
20384
  }
20354
- const SDGContainer = dt.div(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteral(["\n\tdisplay: grid;\n\tgrid-template-columns: repeat(auto-fit, minmax(50px, 1fr));\n\tgap: 8px;\n\n\t.sdg-item {\n\t\theight: 50px;\n\t\twidth: 50px;\n\t\tborder-radius: 8px;\n\t\tbackground-size: cover;\n\t\tbackground-position: center;\n\t\tbackground-repeat: no-repeat;\n\t}\n\n\t.sdg-item-content {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\theight: 100%;\n\t\tcolor: white;\n\t\ttext-align: center;\n\t}\n"])));
20385
+ const SDGContainer = dt.div(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteral(["\n\tdisplay: grid;\n\tgrid-template-columns: repeat(auto-fit, minmax(50px, 1fr));\n\tgap: 8px;\n\n\t.sdg-item {\n\t\theight: 50px;\n\t\twidth: 50px;\n\t\tborder-radius: 8px;\n\t\tbackground-size: cover;\n\t\tbackground-position: center;\n\t\tbackground-repeat: no-repeat;\n\t}\n\n\t.sdg-item-content {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\theight: 100%; \n\t\tcolor: white;\n\t\ttext-align: center;\n\t}\n"])));
20355
20386
 
20356
20387
  var Style$w = dt.div`
20357
20388
  border: 1px solid var(--base-gray-40);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.110",
3
+ "version": "0.6.112",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -1,6 +1,7 @@
1
1
  import Widget from "../index.jsx";
2
2
  import styled from "styled-components";
3
3
  import { getGoalConfig } from "./config.js";
4
+
4
5
  export default function SDGWidget({
5
6
  title = "Sustainable Development Goals",
6
7
  activeSdgGoals = [],
@@ -47,7 +48,7 @@ const SDGContainer = styled.div`
47
48
  .sdg-item-content {
48
49
  display: flex;
49
50
  align-items: center;
50
- height: 100%;
51
+ height: 100%;
51
52
  color: white;
52
53
  text-align: center;
53
54
  }
@@ -31,8 +31,6 @@ const AjaxSubGroup = ({
31
31
 
32
32
  const ajaxForm = ajaxModalValues?.form;
33
33
 
34
- console.log({ajaxForm});
35
-
36
34
  if (ajaxModalValues.isFetching) {
37
35
  return (
38
36
  <div className="ajax-subgroup-loading" style={{ padding: '20px', textAlign: 'center' }}>
@@ -42,7 +40,6 @@ const AjaxSubGroup = ({
42
40
  }
43
41
 
44
42
  const formInputs = Object.values(ajaxForm || {})[0] || {};
45
- console.log({formInputs})
46
43
 
47
44
  const sortedRecords = value.sort((a, b) => {
48
45
  const yearA = parseInt(a.meta?.year || '0');
@@ -1,6 +1,15 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import useAjaxModal from '../utils/useAjaxModal';
3
3
 
4
+ const mergeObject = (obj) => {
5
+ return Object.entries(obj).reduce((acc, [key, value]) => {
6
+ if (typeof value === "object" && !Array.isArray(value) && value !== null) {
7
+ return { ...acc, ...value };
8
+ }
9
+ return { ...acc, [key]: value };
10
+ }, {});
11
+ }
12
+
4
13
  export const handleDataLinkGroupWithTableKeys = ({
5
14
  config,
6
15
  inputConfig,
@@ -26,10 +35,10 @@ export const handleDataLinkGroupWithTableKeys = ({
26
35
  const otherConfig = config.inputs[otherInputKey];
27
36
  if (otherConfig?.type === 'dataLink') {
28
37
  const siblingTableKeys = otherConfig?.meta?.tableKeys || [];
29
- const siblingAdditionalTableKeys = config.meta?.additionalTableKeys || [];
30
- const siblingAllTableKeys = [...siblingTableKeys, ...siblingAdditionalTableKeys];
38
+ const additionalTableKeys = config.meta?.additionalTableKeys || [];
39
+ const allSiblingKeys = [...siblingTableKeys, ...additionalTableKeys];
31
40
 
32
- return siblingAllTableKeys.includes(inputKey) && otherInputKey !== inputKey;
41
+ return allSiblingKeys.includes(inputKey) && otherInputKey !== inputKey;
33
42
  }
34
43
  return false;
35
44
  });
@@ -42,8 +51,13 @@ export const handleDataLinkGroupWithTableKeys = ({
42
51
 
43
52
  const tableKeys = inputConfig.meta.tableKeys;
44
53
  const additionalTableKeys = config.meta?.additionalTableKeys || [];
45
- const allTableKeys = [...new Set([...tableKeys, ...additionalTableKeys])];
54
+
46
55
  const parentInputKeys = Object.keys(config.inputs || {});
56
+ const siblingInputsMatchingTableKeys = parentInputKeys
57
+ .filter(siblingKey => siblingKey !== inputKey)
58
+ .filter(siblingKey => tableKeys.includes(siblingKey) || additionalTableKeys.includes(siblingKey));
59
+
60
+ const allTableKeys = [...new Set([...tableKeys, ...siblingInputsMatchingTableKeys])];
47
61
 
48
62
  const isAjaxModal = useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
49
63
 
@@ -132,6 +146,17 @@ export const handleDataLinkGroupWithTableKeys = ({
132
146
  }
133
147
  });
134
148
 
149
+ siblingInputsMatchingTableKeys.forEach(siblingKey => {
150
+ const siblingConfig = config.inputs[siblingKey];
151
+ if (siblingConfig) {
152
+ inputs[siblingKey] = {
153
+ ...siblingConfig,
154
+ label: siblingConfig.label || siblingKey
155
+ };
156
+ values[siblingKey] = item?.[siblingKey];
157
+ }
158
+ });
159
+
135
160
  if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
136
161
  Object.keys(dataLinkForm.identification)
137
162
  .filter(fieldKey => fieldKey !== 'datastakeId' && !tableKeys.includes(fieldKey))
@@ -149,25 +174,25 @@ export const handleDataLinkGroupWithTableKeys = ({
149
174
  : (formInputConfig.label || formInputConfig.tableLabel || fieldKey)
150
175
  };
151
176
 
152
- if (formInputConfig.label && typeof formInputConfig.label === 'object') {
153
- const dynamicLabelKeys = Object.keys(formInputConfig.label);
177
+ if (formInputConfig?.label && typeof formInputConfig?.label === 'object') {
178
+ const dynamicLabelKeys = Object.keys(formInputConfig?.label);
154
179
  let resolvedLabel = null;
155
180
 
156
181
  for (const labelKey of dynamicLabelKeys) {
157
182
  const parts = labelKey.split(' is ');
158
183
  if (parts.length === 2) {
159
184
  const [conditionKey, conditionValue] = parts;
160
- if (item?.[conditionKey] === conditionValue) {
185
+ const flattenedItem = Object.assign({}, item.location, { address: item.address });
186
+ if (flattenedItem?.[conditionKey] === conditionValue) {
161
187
  resolvedLabel = formInputConfig.label[labelKey];
162
188
  break;
163
- }
189
+ }
164
190
  }
165
191
  }
166
192
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] ||
167
193
  (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
168
194
  }
169
-
170
- values[fieldKey] = item?.[fieldKey];
195
+ values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[fieldKey];
171
196
  });
172
197
  }
173
198
 
@@ -176,8 +201,9 @@ export const handleDataLinkGroupWithTableKeys = ({
176
201
 
177
202
  if (Array.isArray(value)) {
178
203
  return value.map((item, itemIndex) => {
179
- const datastakeIdValue = item?.[inputKey]?.datastakeId || item?.datastakeId;
180
- const { inputs, values } = createInputsAndValues(item);
204
+ const merged = mergeObject(item);
205
+ const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
206
+ const { inputs, values } = createInputsAndValues(merged);
181
207
 
182
208
  return (
183
209
  <TreeNodeComponent
@@ -202,8 +228,9 @@ export const handleDataLinkGroupWithTableKeys = ({
202
228
  );
203
229
  });
204
230
  } else {
205
- const datastakeIdValue = value?.[inputKey]?.datastakeId || value?.datastakeId;
206
- const { inputs, values } = createInputsAndValues(value);
231
+ const merged = mergeObject(value);
232
+ const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
233
+ const { inputs, values } = createInputsAndValues(merged);
207
234
 
208
235
  return (
209
236
  <TreeNodeComponent
@@ -90,8 +90,7 @@ export const handleDataLinkWithTableKeys = ({
90
90
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] ||
91
91
  (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
92
92
  }
93
-
94
- values[tableKey] = item?.[tableKey];
93
+ values[tableKey] = item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[tableKey];
95
94
  } else {
96
95
  inputs[tableKey] = {
97
96
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
@@ -140,8 +139,7 @@ export const handleDataLinkWithTableKeys = ({
140
139
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] ||
141
140
  (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
142
141
  }
143
-
144
- values[fieldKey] = item?.[fieldKey];
142
+ values[fieldKey] = item?.[formInputConfig?.tableLabel?.toLowerCase()] || item?.[fieldKey];
145
143
  });
146
144
  }
147
145
 
@@ -6,6 +6,14 @@ import Geolocation from '../../ViewForm/components/geolocation';
6
6
 
7
7
  export const evaluateShowIfCondition = (condition, item) => {
8
8
  if (!condition || !item) return false;
9
+
10
+ if(condition.includes(' notEmpty ')) {
11
+ const parts = condition.split(' notEmpty ');
12
+ if (parts.length === 2) {
13
+ const [field, expectedValue] = parts.map(p => p.trim());
14
+ return item[field] !== '' || item[field] !== null || item[field] !== undefined;
15
+ }
16
+ }
9
17
 
10
18
  // Handle boolean AND operations
11
19
  if (condition.includes(' && ')) {
@@ -39,7 +39,7 @@ export const renderValue = ({ value, hasChildren, config, user, getApiBaseUrl =
39
39
  displayValue = '-';
40
40
  } else if (typeof value === 'object' && value !== null) {
41
41
  if (Array.isArray(value)) {
42
- displayValue = value.length > 0 ? value.join(', ') : '-'; // Changed from '' to '-'
42
+ displayValue = value.length > 0 ? value.join(', ') : '-';
43
43
  } else if (value.name || value.fullName) {
44
44
  displayValue = value.name || value.fullName;
45
45
  } else if (value.label) {