ebta-workflow-prod 4.0.14 → 4.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ebta-workflow-prod",
3
3
  "private": false,
4
- "version": "4.0.14",
4
+ "version": "4.0.16",
5
5
  "description": "",
6
6
  "license": "UNLICENSED",
7
7
  "author": "",
@@ -166,18 +166,34 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
166
166
  // Iterate through each attribute in the 'attributes' object of the feature
167
167
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
168
168
  for (const [key, value] of Object.entries(feature.attributes)) {
169
- // Check if the attribute is in the short list
170
169
  if (shortListOfAttributes.includes(key)) {
171
- // If it's not already in the attributeSummary, initialize it
170
+ if (value === null || value === undefined) continue;
171
+
172
172
  if (!attributeSummary[key]) {
173
173
  attributeSummary[key] = {};
174
174
  }
175
- let valueKey
176
- if (props.fields.find(obj => obj.name == key)?.type == "date" && Number(value) > 0) {
177
- valueKey = dayjs.unix(Number(value) / 1000).format("DD/MM/YYYY")
175
+
176
+ let valueKey: string;
177
+ const fieldType = props.fields.find(obj => obj.name == key)?.type;
178
+
179
+ if (fieldType === "date") {
180
+ const epoch = Number(value);
181
+ if (!epoch || epoch <= 0) continue;
182
+ valueKey = dayjs.unix(epoch / 1000).format("DD/MM/YYYY");
183
+
184
+ } else if (fieldType && ['integer', 'number', 'float', 'short', 'long', 'big integer'].includes(fieldType)) {
185
+ // Numeric: value passed null check above, but still guard NaN
186
+ const num = Number(value);
187
+ if (isNaN(num)) continue;
188
+ valueKey = String(value);
189
+
190
+ } else {
191
+ // String: reject known meaningless values
192
+ valueKey = String(value).trim();
193
+ const meaningless = ['', 'null', 'undefined', '{}', 'N/A', 'n/a', '<Null>', '<null>'];
194
+ if (meaningless.includes(valueKey)) continue;
178
195
  }
179
- // Count the occurrence of each value for the attribute
180
- else { valueKey = String(value); }
196
+
181
197
  if (!attributeSummary[key][valueKey]) {
182
198
  attributeSummary[key][valueKey] = 0;
183
199
  }
@@ -213,10 +229,10 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
213
229
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
214
230
  let result = props.fields.filter(obj => !attributeList || attributeList.length === 0 || attributeList.includes(obj.name)) // Filter only if nameList is valid
215
231
  .filter(obj => {
216
- if (RawOriginalData.length==0){return true}
232
+ if (RawOriginalData.length == 0) { return true }
217
233
  let matchingRawDataValues = RawOriginalData.find(item => item.name === obj.name)?.uniqValue;
218
234
  let meanless = ['{}', ' ', 'null']
219
- return (matchingRawDataValues && matchingRawDataValues.length > 0 && !meanless.includes(matchingRawDataValues[0].value))
235
+ return matchingRawDataValues !== undefined && matchingRawDataValues.length > 0 && !matchingRawDataValues.every((val) => meanless.includes(val.value))
220
236
  })
221
237
  .map(obj => {
222
238
  let newObj: Attribute = { name: obj.name };
@@ -253,7 +269,16 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
253
269
  const filteredAttributes = {};
254
270
  for (const key of attributeList) {
255
271
  if (key in feature.attributes) {
256
- filteredAttributes[key] = originalData.find(attri => attri.name === key)?.type == 'date' ? epoch2MelbDate(Number(feature.attributes[key]) / 1000) : feature.attributes[key];
272
+ const isDate = originalData.find(attri => attri.name === key)?.type == 'date';
273
+ const rawVal = feature.attributes[key];
274
+ if (isDate) {
275
+ const epoch = Number(rawVal);
276
+ filteredAttributes[key] = (rawVal !== null && rawVal !== undefined && epoch > 0)
277
+ ? epoch2MelbDate(epoch / 1000)
278
+ : null; // keep as null, generateAttributeSummary will skip it
279
+ } else {
280
+ filteredAttributes[key] = rawVal;
281
+ }
257
282
  }
258
283
  }
259
284
  return filteredAttributes;
@@ -874,7 +899,9 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
874
899
  // Iterate through the features array
875
900
  features.forEach((feature) => {
876
901
  const value = feature[attributeName];
902
+ if (value === null || value === undefined || value === '') return;
877
903
  if (value) {
904
+
878
905
  // Count the occurrence of each value for the attribute
879
906
  if (!attributeSummary[value]) {
880
907
  attributeSummary[value] = 0;
@@ -1211,7 +1238,7 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
1211
1238
  limitInUse = (attribute.type == 'date' && (dayjs.unix(minDate.current).format('DD/MM/YYYY') != startDate.format('DD/MM/YYYY') || (dayjs.unix(maxDate.current).format('DD/MM/YYYY') != endDate.format('DD/MM/YYYY')))) || searchValue.length > 0 || (minValue !== -Infinity || maxValue !== Infinity)
1212
1239
  }
1213
1240
  if (attribute.uniqValue && attribute.uniqValue.length > 0) {
1214
- displayedValues = (attribute.uniqValue.length < defaultNumber + 2) || showAll ? attribute.uniqValue : attribute.uniqValue.slice(0, defaultNumber);
1241
+ displayedValues = (attribute.uniqValue.length < defaultNumber + 2) || showAll ? attribute.uniqValue : attribute.uniqValue.slice(0, defaultNumber);
1215
1242
  }
1216
1243
 
1217
1244
  if (limitInUse && filteredValues.length > 0) {
@@ -1529,14 +1556,14 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
1529
1556
  const matchedItems = attri.uniqValue?.filter(item =>
1530
1557
  keywords.every(keyword => item.value.toLowerCase().includes(keyword))
1531
1558
  );
1532
- return sortItemsBySelection(matchedItems,attri.selection) || [];
1559
+ return sortItemsBySelection(matchedItems, attri.selection) || [];
1533
1560
  }
1534
1561
 
1535
1562
  function filterRange(attri: Attribute, min: number, max: number) {
1536
1563
  const matchedItems = attri.uniqValue?.filter(item =>
1537
1564
  Number(item.value) <= max && Number(item.value) >= min
1538
1565
  );
1539
- return sortItemsBySelection(matchedItems,attri.selection) || []
1566
+ return sortItemsBySelection(matchedItems, attri.selection) || []
1540
1567
  }
1541
1568
 
1542
1569
  const groupByMelbourneDate = (data: fieldValue[]) => {
@@ -1563,7 +1590,7 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
1563
1590
  itemDate.isSame(start, 'day') || itemDate.isSame(end, 'day'); // Inclusive comparison
1564
1591
  });
1565
1592
 
1566
- return sortItemsBySelection(matchedItems,attri.selection);
1593
+ return sortItemsBySelection(matchedItems, attri.selection);
1567
1594
  }
1568
1595
 
1569
1596
 
@@ -1574,7 +1601,7 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
1574
1601
  const matchedItems = attri.uniqValue?.filter(item =>
1575
1602
  keywords.every(keyword => item.value.toLowerCase().includes(keyword))
1576
1603
  );
1577
- return sortItemsBySelection(matchedItems,attri.selection) || [];
1604
+ return sortItemsBySelection(matchedItems, attri.selection) || [];
1578
1605
  }
1579
1606
  if (props.openedAttribute !== undefined && (openAttriTime.current) !== (props.openedAttribute.timestamp)) {
1580
1607
  let newAttriData: fieldValue[] | undefined
@@ -1683,7 +1710,7 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
1683
1710
  if (startDate == undefined) { setProperty("startDate" as any, defaultStart) }
1684
1711
  if (endDate == undefined) { setProperty("endDate" as any, defaultEnd) }
1685
1712
  if (filteredValues == undefined) { setProperty("filteredValues" as any, []) }
1686
- if (sqlRule== undefined) {props.setProperty("sqlRule" as any, "AND") }
1713
+ if (sqlRule == undefined) { props.setProperty("sqlRule" as any, "AND") }
1687
1714
  }, [defaultEnd, defaultStart, endDate, filteredValues, layerName, maxValue, minValue, props, rule, searchQuery, searchValue, setProperty, sqlRule, startDate, summary]);
1688
1715
 
1689
1716
  React.useEffect(() => {
@@ -1754,18 +1781,18 @@ function AttributeFilter(props: AttributeFilterProps): React.ReactElement {
1754
1781
  )}
1755
1782
  </Search> : <></>}
1756
1783
  {sqlRule && (
1757
- <RadioGroup
1758
- //Radio Group
1759
- row
1760
- aria-labelledby="demo-row-radio-buttons-group-label"
1761
- name="row-radio-buttons-group"
1762
- value={sqlRule}
1763
- onChange={handleSqlRule}
1764
- >
1765
- <FormControlLabel sx={{ fontSize: 15 }} value="AND" control={<Radio sx={{ color: 'var(--accentIconBorder) !important' }}
1766
- />} label={<span style={{ fontSize: '1.2rem' }}>Meet ALL Conditions</span>} />
1767
- <FormControlLabel sx={{ fontSize: 15 }} value="OR" control={<Radio sx={{ color: 'var(--accentIconBorder) !important' }} />} label={<span style={{ fontSize: '1.2rem' }}>Meet ANY Conditon</span>} />
1768
- </RadioGroup>
1784
+ <RadioGroup
1785
+ //Radio Group
1786
+ row
1787
+ aria-labelledby="demo-row-radio-buttons-group-label"
1788
+ name="row-radio-buttons-group"
1789
+ value={sqlRule}
1790
+ onChange={handleSqlRule}
1791
+ >
1792
+ <FormControlLabel sx={{ fontSize: 15 }} value="AND" control={<Radio sx={{ color: 'var(--accentIconBorder) !important' }}
1793
+ />} label={<span style={{ fontSize: '1.2rem' }}>Meet ALL Conditions</span>} />
1794
+ <FormControlLabel sx={{ fontSize: 15 }} value="OR" control={<Radio sx={{ color: 'var(--accentIconBorder) !important' }} />} label={<span style={{ fontSize: '1.2rem' }}>Meet ANY Conditon</span>} />
1795
+ </RadioGroup>
1769
1796
  )}
1770
1797
  {
1771
1798
  props.footerButton ?