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/groupBy.js
2023-12-17 19:51:05 +00:00

23 lines
686 B
JavaScript

/**
* Checks if the provided values objects have equal matching field values. If can
* optionally run the value of the first object through the
* `getRowValueFromGroupValue` method.
*/
export function fieldValuesAreEqualInObjects(
fields,
registry,
object1,
object2,
object1IsGroup = false
) {
return fields.every((field) => {
const fieldType = registry.get('field', field.type)
let object1Value = object1[`field_${field.id}`]
if (object1IsGroup) {
object1Value = fieldType.getRowValueFromGroupValue(field, object1Value)
}
const object2Value = object2[`field_${field.id}`]
return fieldType.isEqual(field, object1Value, object2Value)
})
}