Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mboudet committed May 17, 2023
1 parent 763bcf2 commit f348066
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 3 additions & 5 deletions askomics/libaskomics/SparqlQuery.py
Expand Up @@ -1356,18 +1356,16 @@ def build_query_from_json(self, preview=False, for_editor=False):
attributes[attribute["linkedWith"]]["entity_id"],
attributes[attribute["linkedWith"]]["label"]
))
var_to_replace.append((obj, var_2))

any([filter['filterSign'] == "=" and not filter['filterValue'] for filter in attribute.get('linkedFilters', [])])

if not (attribute.get('linkedNegative', False) or attribute.get('linkedFilterValue')):
var_to_replace.append((obj, var_2))
else:
filter = "!=" if attribute.get('linkedNegative', False) else "="
filter = "!" if attribute.get('linkedNegative', False) else ""
regex_clause = var_2
if attribute.get('linkedFilterValue'):
regex_clause = "REGEX(REPLACE('{}', '\\$1', {}, 'i'))".format(attribute.get('linkedFilterValue'), var_2)
filter_string = "FILTER ( {} {} {} ) .".format(obj, filter, regex_clause)
regex_clause = "REGEX({}, REPLACE('{}', '\\\$1', {}), 'i')".format(obj, attribute.get('linkedFilterValue', "$1"), var_2)
filter_string = "FILTER ( {} {} ) .".format(filter, regex_clause)
self.store_filter(filter_string, block_id, sblock_id, pblock_ids)

# Numeric
Expand Down
10 changes: 6 additions & 4 deletions askomics/react/src/routes/query/attribute.jsx
Expand Up @@ -67,6 +67,8 @@ export default class AttributeBox extends Component {
let optionDict = {}
let content

console.log("rendered")

this.props.graph.nodes.map(node => {
if (!node.suggested) {
options.push(<option style={{"background-color": "#cccccc"}} disabled>{node.label + " " + this.subNums(node.humanId)}</option>)
Expand All @@ -80,16 +82,16 @@ export default class AttributeBox extends Component {
})

if (this.props.attribute.type == 'text') {
box = this.renderTextLinker(optionDict)
content = this.renderTextLinker(optionDict)
}
if (this.props.attribute.type == 'decimal') {
content = this.renderNumericLinker(optionDict)
}
if (this.props.attribute.type == 'category') {
box = this.renderBooleanLinker(optionDict)
content = this.renderBooleanLinker(optionDict)
}
if (this.props.attribute.type == 'boolean') {
box = this.renderBooleanLinker(optionDict)
content = this.renderBooleanLinker(optionDict)
}
if (this.props.attribute.type == 'date') {
content = this.renderNumericLinker(optionDict, "date")
Expand Down Expand Up @@ -190,7 +192,7 @@ export default class AttributeBox extends Component {
input = (<Input disabled={this.props.attribute.optional} type="text" id={this.props.attribute.id} value={this.props.attribute.filterValue} onChange={this.handleFilterValue} />)
}

if (this.props.attribute.linkedWith) {
if (this.props.attribute.linked) {
form = this.renderLinker()
} else {
form = (
Expand Down

0 comments on commit f348066

Please sign in to comment.