Skip to content

Commit

Permalink
Merge pull request #1480 from entando/ENG-4058_composite_fix
Browse files Browse the repository at this point in the history
ENG-4058 fix composite attribute inside users profile types
  • Loading branch information
ichalagashvili authored May 12, 2023
2 parents 30e6116 + 23e8b65 commit a62a6ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/helpers/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const getPayloadForForm = (

userProfile.attributes.forEach((attr) => {
const {
code, value, values, listElements, elements,
code, value, values, listElements, elements, compositeelements,
} = attr;

const attrType =
Expand Down Expand Up @@ -117,9 +117,9 @@ export const getPayloadForForm = (
}
case TYPE_COMPOSITE: {
const childProfileType = selectedProfileType.find(item => item.code === code);
if (elements && childProfileType) {
if (compositeelements && childProfileType) {
formAttr[code] = getPayloadForForm(
username, { attributes: elements },
username, { attributes: compositeelements },
childProfileType.compositeAttributes,
defaultLanguage,
);
Expand Down Expand Up @@ -205,12 +205,12 @@ export const getPayloadForApi = (
}
case TYPE_COMPOSITE: {
const childProfileType = selectedProfileType.find(item => item.code === key);
const elements = getPayloadForApi(
const compositeelements = getPayloadForApi(
profile[key],
childProfileType.compositeAttributes,
defaultLanguage,
).attributes;
attr.push({ code: key, elements });
attr.push({ code: key, compositeelements });
break;
}
default:
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/entities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ describe('getPayloadForForm', () => {
attributes: [
{
code: 'someComposite',
elements: [
compositeelements: [
{ code: 'textChild', values: { [DEFAULT_LANGUAGE]: 'random text' } },
{ code: 'booleanChild', value: false },
],
Expand Down Expand Up @@ -604,7 +604,7 @@ describe('getPayloadForApi', () => {
}],
testAssertions: (formAttr) => {
const attribute = formAttr.attributes.find(attr => attr.code === 'myAttribute');
expect(attribute).toHaveProperty('elements', [
expect(attribute).toHaveProperty('compositeelements', [
{ code: 'textChild', values: { [DEFAULT_LANGUAGE]: 'random text' } },
{ code: 'booleanChild', value: false },
]);
Expand Down

0 comments on commit a62a6ee

Please sign in to comment.