mirror of
https://gitlab.com/bramw/baserow.git
synced 2024-11-21 23:37:55 +00:00
26 lines
625 B
JavaScript
26 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
|
|
}
|