Merge pull request #14930 from Budibase/view-calc-count-non-numeric

Allow counting non-numeric fields in calculation views
This commit is contained in:
Andrew Kingston 2024-10-31 16:26:57 +00:00 committed by GitHub
commit d9b7e3e6e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 5 deletions

View File

@ -90,8 +90,15 @@
const getFieldOptions = (self, calculations, schema) => { const getFieldOptions = (self, calculations, schema) => {
return Object.entries(schema) return Object.entries(schema)
.filter(([field, fieldSchema]) => { .filter(([field, fieldSchema]) => {
// Only allow numeric fields that are not calculations themselves // Don't allow other calculation columns
if (fieldSchema.calculationType || !isNumeric(fieldSchema.type)) { if (fieldSchema.calculationType) {
return false
}
// Only allow numeric columns for most calculation types
if (
self.type !== CalculationType.COUNT &&
!isNumeric(fieldSchema.type)
) {
return false return false
} }
// Don't allow duplicates // Don't allow duplicates
@ -234,7 +241,7 @@
<InfoDisplay <InfoDisplay
icon="Help" icon="Help"
quiet quiet
body="Calculations only work with numeric columns and a maximum of 5 calculations can be added at once." body="Most calculations only work with numeric columns and a maximum of 5 calculations can be added at once."
/> />
<div> <div>
@ -257,6 +264,4 @@
.group-by { .group-by {
grid-column: 2 / 5; grid-column: 2 / 5;
} }
span {
}
</style> </style>