MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / getRealValue

Function getRealValue

web/pgadmin/static/js/components/FormComponents.jsx:892–913  ·  view source on GitHub ↗
(options, value, creatable, formatter)

Source from the content-addressed store, hash-verified

890}
891
892function getRealValue(options, value, creatable, formatter) {
893 let realValue = null;
894 if(options?.length == 0 && !creatable) {
895 return realValue;
896 }
897 if (_.isArray(value)) {
898 realValue = [...value];
899 /* If multi select options need to be in some format by UI, use formatter */
900 if (formatter) {
901 realValue = formatter.fromRaw(realValue, options);
902 } else if (creatable) {
903 realValue = realValue.map((val) => ({ label: val, value: val }));
904 } else {
905 realValue = realValue.map((val) => (_.find(options, (option) => _.isEqual(option.value, val))));
906 }
907 } else {
908 let flatOptions = flattenSelectOptions(options);
909 realValue = _.find(flatOptions, (option) => option.value == value) ||
910 (creatable && !_.isUndefined(value) && !_.isNull(value) ? { label: value, value: value } : null);
911 }
912 return realValue;
913}
914export function InputSelectNonSearch({ options, ...props }) {
915 return <MuiSelect native {...props} variant="outlined">
916 {(options || []).map((o) => <option key={o.value} value={o.value}>{o.label}</option>)}

Callers 1

InputSelectFunction · 0.85

Calls 2

flattenSelectOptionsFunction · 0.85
findMethod · 0.80

Tested by

no test coverage detected