mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-02-12 16:18:48 +00:00
25 lines
625 B
JavaScript
25 lines
625 B
JavaScript
/**
|
|
* Find the primary field in a list of fields.
|
|
* If no primary field is found, return the first field.
|
|
* @param fields
|
|
* @returns {*}
|
|
*/
|
|
export function getPrimaryOrFirstField(fields) {
|
|
const primaryField = fields.find((field) => field.primary)
|
|
return primaryField || fields[0]
|
|
}
|
|
|
|
/**
|
|
* Checks if a given field has at least one compatible filterType
|
|
* @param field
|
|
* @param filterTypes
|
|
* @returns {boolean}
|
|
*/
|
|
export function hasCompatibleFilterTypes(field, filterTypes) {
|
|
for (const type in filterTypes) {
|
|
if (filterTypes[type].fieldIsCompatible(field)) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|