Skip to content

Commit

Permalink
Fix form issue with label & uris (#256)
Browse files Browse the repository at this point in the history
* Fix form
  • Loading branch information
mboudet committed Jul 13, 2021
1 parent a350e98 commit 65298b7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 30 deletions.
31 changes: 18 additions & 13 deletions askomics/react/src/routes/form/attribute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ export default class AttributeBox extends Component {
this.handleDateFilter = this.props.handleDateFilter.bind(this)
}

subNums (id) {
let newStr = ""
let oldStr = id.toString()
let arrayString = [...oldStr]
arrayString.forEach(char => {
let code = char.charCodeAt()
newStr += String.fromCharCode(code + 8272)
})
return newStr
}

renderLinker () {
let options = []

Expand Down Expand Up @@ -110,9 +121,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label">{this.props.attribute.displayLabel}</label>
<label className="attr-label">{this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label}</label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
{form}
Expand Down Expand Up @@ -186,9 +196,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label">{this.props.attribute.displayLabel}</label>
<label className="attr-label">{this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label}</label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
{this.props.attribute.uri == "rdf:type" || this.props.attribute.uri == "rdfs:label" ? <nodiv></nodiv> : <i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i> }
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
Expand Down Expand Up @@ -256,9 +265,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label">{this.props.attribute.displayLabel}</label>
<label className="attr-label">{this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label}</label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
Expand Down Expand Up @@ -308,9 +316,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label">{this.props.attribute.displayLabel}</label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<label className="attr-label">{this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label}</label>
<div className="attr-icons">
<i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i>
<i className={excludeIcon} id={this.props.attribute.id} onClick={this.toggleExclude}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
Expand Down Expand Up @@ -354,9 +361,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label">{this.props.attribute.displayLabel}</label>
<label className="attr-label">{this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label}</label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
Expand Down Expand Up @@ -432,9 +438,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label">{this.props.attribute.displayLabel}</label>
<label className="attr-label">{this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label}</label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
Expand Down
3 changes: 1 addition & 2 deletions askomics/react/src/routes/form/query.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ export default class FormQuery extends Component {
})
}).then(response => {
this.graphState = this.props.location.state.graphState
console.log(this.props.location.state.graphState)
this.updateGraphState()
this.setState({ waiting: false })
})
Expand Down Expand Up @@ -440,7 +439,7 @@ export default class FormQuery extends Component {
this.state.graphState.attr.forEach(attribute => {
if (attribute.form) {
if (! entityMap.has(attribute.nodeId)){
entityMap.set(attribute.nodeId, {entity_label: attribute.entityDisplayLabel, attributes:[]})
entityMap.set(attribute.nodeId, {entity_label: attribute.entityDisplayLabel ? attribute.entityDisplayLabel : attribute.entityLabel, attributes:[]})
}
entityMap.get(attribute.nodeId).attributes.push(
<AttributeBox
Expand Down
29 changes: 17 additions & 12 deletions askomics/react/src/routes/form_edit/attribute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ export default class AttributeBox extends Component {
this.handleDateFilter = this.props.handleDateFilter.bind(this)
}

subNums (id) {
let newStr = ""
let oldStr = id.toString()
let arrayString = [...oldStr]
arrayString.forEach(char => {
let code = char.charCodeAt()
newStr += String.fromCharCode(code + 8272)
})
return newStr
}

renderLinker () {
let options = []

Expand Down Expand Up @@ -110,9 +121,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel} value={this.props.attribute.displayLabel} onChange={this.props.setAttributeName} /></label>
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} value={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} onChange={this.props.setAttributeName} /></label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
{form}
Expand Down Expand Up @@ -188,9 +198,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel} value={this.props.attribute.displayLabel} onChange={this.props.setAttributeName} /></label>
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} value={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} onChange={this.props.setAttributeName} /></label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
{this.props.attribute.uri == "rdf:type" || this.props.attribute.uri == "rdfs:label" ? <nodiv></nodiv> : <i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i> }
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
Expand Down Expand Up @@ -258,9 +267,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel} value={this.props.attribute.displayLabel} onChange={this.props.setAttributeName} /></label>
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} value={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} onChange={this.props.setAttributeName} /></label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
Expand Down Expand Up @@ -310,9 +318,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel} value={this.props.attribute.displayLabel} onChange={this.props.setAttributeName} /></label>
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} value={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} onChange={this.props.setAttributeName} /></label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i>
<i className={excludeIcon} id={this.props.attribute.id} onClick={this.toggleExclude}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
Expand Down Expand Up @@ -356,9 +363,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel} value={this.props.attribute.displayLabel} onChange={this.props.setAttributeName} /></label>
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} value={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} onChange={this.props.setAttributeName} /></label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
Expand Down Expand Up @@ -434,9 +440,8 @@ export default class AttributeBox extends Component {

return (
<div className="attribute-box">
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel} value={this.props.attribute.displayLabel} onChange={this.props.setAttributeName} /></label>
<label className="attr-label"><Input type="text" id={this.props.attribute.id} placeholder={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} value={this.props.attribute.displayLabel ? this.props.attribute.displayLabel : this.props.attribute.label} onChange={this.props.setAttributeName} /></label>
<div className="attr-icons">
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={optionalIcon} id={this.props.attribute.id} onClick={this.toggleOptional}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
Expand Down
4 changes: 2 additions & 2 deletions askomics/react/src/routes/form_edit/query.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export default class FormEditQuery extends Component {
this.state.graphState.attr.forEach(attribute => {
if (attribute.form) {
if (! entityMap.has(attribute.nodeId)){
entityMap.set(attribute.nodeId, {entity_label: attribute.entityDisplayLabel, attributes:[]})
entityMap.set(attribute.nodeId, {entity_label: attribute.entityDisplayLabel ? attribute.entityDisplayLabel : attribute.entityLabel, attributes:[]})
}
entityMap.get(attribute.nodeId).attributes.push(
<AttributeBox
Expand Down Expand Up @@ -445,7 +445,7 @@ export default class FormEditQuery extends Component {
return (
<div className="container">
{redirectLogin}
<h2>Query Builder</h2>
<h2>Form editor</h2>
<hr />
<WaitingDiv waiting={this.state.waiting} center />
<br />
Expand Down
2 changes: 1 addition & 1 deletion askomics/react/src/routes/query/attribute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default class AttributeBox extends Component {
<div className="attribute-box">
<label className="attr-label">{this.props.attribute.label}</label>
<div className="attr-icons">
{this.props.config.user.admin ? <i className={formIcon} id={this.props.attribute.id} onClick={this.toggleFormAttribute}></i> : <nodiv></nodiv>} : <nodiv></nodiv>}
{this.props.config.user.admin ? <i className={formIcon} id={this.props.attribute.id} onClick={this.toggleFormAttribute}></i> : <nodiv></nodiv>}
<i className={linkIcon} id={this.props.attribute.id} onClick={this.toggleLinkAttribute}></i>
<i className={eyeIcon} id={this.props.attribute.id} onClick={this.toggleVisibility}></i>
</div>
Expand Down
4 changes: 4 additions & 0 deletions askomics/react/src/routes/query/query.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ export default class Query extends Component {
humanNodeId: this.getHumanIdFromId(nodeId),
uri: 'rdf:type',
label: 'Uri',
displayLabel: 'Uri',
entityLabel: this.getLabel(nodeUri),
entityDisplayLabel: this.getLabel(nodeUri),
entityUris: [nodeUri, ],
type: 'uri',
faldo: false,
Expand All @@ -278,7 +280,9 @@ export default class Query extends Component {
humanNodeId: this.getHumanIdFromId(nodeId),
uri: 'rdfs:label',
label: 'Label',
displayLabel: 'Label',
entityLabel: this.getLabel(nodeUri),
entityDisplayLabel: this.getLabel(nodeUri),
entityUris: [nodeUri, ],
type: 'text',
faldo: false,
Expand Down

0 comments on commit 65298b7

Please sign in to comment.