Skip to content

Commit

Permalink
Merge pull request #156 from konecty/fix/remove-inherited-fields
Browse files Browse the repository at this point in the history
Fix: Don't remove inherited fields if it's sent on request
  • Loading branch information
7sete7 authored Jul 3, 2024
2 parents 8a0e22b + 0add075 commit 7dbadae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/imports/meta/removeInheritedFields.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import isArray from 'lodash/isArray';

export function removeInheritedFields(lookupField) {
export function removeInheritedFields(lookupField, objectNewValues) {
if (isArray(lookupField.inheritedFields)) {
return lookupField.inheritedFields.reduce((acc, inheritedField) => {
if (['always', 'hierarchy_always'].includes(inheritedField.inherit)) {
if (['always', 'hierarchy_always'].includes(inheritedField.inherit) && objectNewValues[inheritedField.fieldName] === undefined) {
acc[inheritedField.fieldName] = null;
}
return acc;
Expand Down
2 changes: 1 addition & 1 deletion src/imports/meta/validateAndProcessValueFor.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export async function validateAndProcessValueFor({ meta, fieldName, value, actio
}

if (actionType === 'update' && value == null && field.type === 'lookup') {
Object.assign(objectNewValues, removeInheritedFields(field));
Object.assign(objectNewValues, removeInheritedFields(field, objectNewValues));
}

if (value == null && field.type !== 'autoNumber') {
Expand Down

0 comments on commit 7dbadae

Please sign in to comment.