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/build/main.js +1 -1
- package/package.json +1 -1
- package/src/elements/AttributeFilter.tsx +55 -28
package/package.json
CHANGED
|
@@ -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
|
-
|
|
170
|
+
if (value === null || value === undefined) continue;
|
|
171
|
+
|
|
172
172
|
if (!attributeSummary[key]) {
|
|
173
173
|
attributeSummary[key] = {};
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
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 ?
|