Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parents of parent aren't accessible #94

Open
devdaniero opened this issue Jul 25, 2018 · 1 comment
Open

Parents of parent aren't accessible #94

devdaniero opened this issue Jul 25, 2018 · 1 comment

Comments

@devdaniero
Copy link

When working with localization it's often the case to have the same structure for multiple objects which you want to 'merge' when exposing to a third party. For example object 'attribute' and object 'classification' both have a code but the name is localized.

Attribute object:

{
	"attributeCode": "unique_attribute_code",
	"localizedAttributes": {
		"en": {
			"attributeName": "HP",
			"formattedValue": "100 HP"
		},
		"de": {
			"attributeName": "PS",
			"formattedValue": "100 PS"
		}
	}
}

Template object:

        content: {
            classificationCode: { dataKey: 'classification.code' },
            attributeCode: { dataKey: 'code' },
            localizedAttributes: {
                dataKey: 'localizedAttributes',
                content: {
                    nl: {
                        dataKey: 'nl',
                        content: {
                            classificationName: { dataKey: 'Cant get classification.localizedAttributes.nl.name' },
                            attributeName: { dataKey: 'name' }
                        }
                    },
                    fr: {
                        dataKey: 'fr',
                        content: {
                            classificationName: { dataKey: 'Cant get classification.localizedAttributes.fr.name' },
                            attributeName: { dataKey: 'name' }
                        }
                    }
                }
            }
        }

As you can see in the template I can set the attribute code and go deeper on the object for the classification code. But for the localizedAttributes I can't use classification.localizedAttributes.nl.name for example. And I can only climb up one parent with the source parameter.

It would be great to extend the source parameter to chain parents here. For example:

    content: {
        classificationName: { dataKey: 'name', source: 'parent.parent.classification.localizedAttributes.nl' },
        attributeName: { dataKey: 'name' }
    }

This way it's possible to go deeper and higher with ease and gives so much flexibility for building custom views.

@fastcodejava
Copy link
Collaborator

fastcodejava commented Jul 25, 2018

I don't have much time to work on this project. But I think it is fairly easy.
Would you please send the payload, so I can test it thoroughly.
It will be more like:

content: {
        classificationName: { dataKey: 'classification.localizedAttributes.nl.name', source: 'parent.parent' },
        attributeName: { dataKey: 'name' }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants