How to use the @talend/react-forms/lib/UIForm/utils/properties.getValue function in @talend/react-forms

To help you get started, we’ve selected a few @talend/react-forms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Talend / ui / packages / components-kit / src / components / ComponentForm / ComponentForm.component.js View on Github external
export function resolveNameForTitleMap({ schema, properties, value }) {
	if (schema.titleMap) {
		// Here we add a field side by side with the value
		// to keep the title associated to the value
		const info = schema.titleMap.find(titleMap => titleMap.value === value);

		const parentKey = schema.key.slice();
		const key = parentKey.pop();
		const nameKey = `$${key}_name`;
		const parentValue = getValue(properties, { key: parentKey });

		if (info) {
			parentValue[nameKey] = info.name;
		} else {
			delete parentValue[nameKey];
		}
	}
}
github Talend / ui / packages / containers / src / ComponentForm / ComponentForm.component.js View on Github external
return;
	}

	// Here we add a field side by side with the value
	// to keep the title associated to the value
	const valueIsArray = Array.isArray(value);
	const uniformValue = valueIsArray ? value : [value];

	const names = uniformValue
		.map(nextValue => schema.titleMap.find(titleMap => titleMap.value === nextValue))
		.map(entry => entry && entry.name);

	const parentKey = schema.key.slice();
	const key = parentKey.pop();
	const nameKey = `$${key}_name`;
	const parentValue = getValue(properties, { key: parentKey });

	if (names.some(name => name !== undefined)) {
		parentValue[nameKey] = valueIsArray ? names : names[0];
	} else {
		delete parentValue[nameKey];
	}
}