Changeset View
Changeset View
Standalone View
Standalone View
cosealious-src/lib/ResourceDropdown.jsx
Show All 12 Lines | const default_props = { | ||||
value: "", | value: "", | ||||
resources: [], | resources: [], | ||||
displayAttrIsSafe: false, | displayAttrIsSafe: false, | ||||
}; | }; | ||||
function getAttr(name, resource, props) { | function getAttr(name, resource, props) { | ||||
const propname = name + "Attr"; | const propname = name + "Attr"; | ||||
if (typeof props[propname] === "string") { | if (typeof props[propname] === "string") { | ||||
return resource[props[propname]] || resource.body[props[propname]]; | return resource[props[propname]]; | ||||
} else if (typeof props[propname] === "function") { | } else if (typeof props[propname] === "function") { | ||||
return props[propname](resource); | return props[propname](resource); | ||||
} | } | ||||
} | } | ||||
function getOptionValue(resource, props) { | function getOptionValue(resource, props) { | ||||
return getAttr("value", resource, props); | return getAttr("value", resource, props); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |