1
0
mirror of https://gitlab.com/bramw/baserow.git synced 2024-11-21 23:37:55 +00:00
bramw_baserow/web-frontend/modules/database/utils/field.js
2022-11-22 10:40:57 +00:00

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
}