Skip to content

Commit

Permalink
Change input json fetch parsing to use LOC json for lists
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreben committed Dec 13, 2018
1 parent 9bf10c6 commit f704e7e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
24 changes: 16 additions & 8 deletions src/components/editor/InputList.jsx
Expand Up @@ -16,10 +16,9 @@ class
}

render() {
//TODO: change target_url to use live ld4l lookup when it is available (#226)
let target_url, isMandatory, isRepeatable
let list_url, isMandatory, isRepeatable
try {
target_url = this.props.propertyTemplate.valueConstraint.useValuesFrom[0]
list_url = this.props.propertyTemplate.valueConstraint.useValuesFrom[0]
isMandatory = JSON.parse(this.props.propertyTemplate.mandatory)
isRepeatable = JSON.parse(this.props.propertyTemplate.repeatable)
} catch (error) {
Expand All @@ -36,20 +35,29 @@ class
isLoading: this.state.isLoading,
options: this.state.options,
selected: this.state.selected,
labelKey: "label"
labelKey: "@value"
}

var opts = []
return (
<div>
<label htmlFor="targetComponent">{this.props.propertyTemplate.propertyLabel}
<Typeahead
onFocus={() => {
this.setState({isLoading: true});
fetch(`${target_url}`)
fetch(`${list_url}.json`)
.then(resp => resp.json())
.then(json => this.setState({
.then(json => {
for(var i in json){
try{
opts.push(json[i]["http://www.loc.gov/mads/rdf/v1#authoritativeLabel"][0]["@value"])
} catch (error) {
//ignore
}
}
})
.then(() => this.setState({
isLoading: false,
options: json
options: opts
}))
}}
onBlur={() => {
Expand Down
Expand Up @@ -109,7 +109,7 @@
"valueConstraint": {
"valueTemplateRefs": [],
"useValuesFrom": [
"./static/spoofedFilesFromServer/fromQA/carriers.json"
"http://id.loc.gov/vocabulary/carriers"
],
"valueDataType": {
"dataTypeURI": "http://id.loc.gov/ontologies/bibframe/Carrier"
Expand Down Expand Up @@ -191,7 +191,7 @@
"valueConstraint": {
"valueTemplateRefs": [],
"useValuesFrom": [
"./static/spoofedFilesFromServer/fromQA/frequencies.json"
"http://id.loc.gov/vocabulary/frequencies"
],
"valueDataType": {
"dataTypeURI": "http://id.loc.gov/ontologies/bibframe/Frequency"
Expand Down

0 comments on commit f704e7e

Please sign in to comment.