diff --git a/src/containers/SearchEngine/components/QueryBuilder/Group.js b/src/containers/SearchEngine/components/QueryBuilder/Group.js index 42ce5cc2fa..1a6db6d4ec 100644 --- a/src/containers/SearchEngine/components/QueryBuilder/Group.js +++ b/src/containers/SearchEngine/components/QueryBuilder/Group.js @@ -65,7 +65,7 @@ class Group extends PureComponent { return ( { + rules.forEach((rule, index) => { if (!rule.criteria && !rule.metacriteria) { if (!rule.itemtype) { - render.push(this.selectRule('criteria', rule, index)) + render.push( + this.selectRule( + 'criteria', + rule, + [...this.props.index, 'criteria', index], + ), + ) } else { - render.push(this.selectRule('metacriteria', rule, index)) + render.push( + this.selectRule( + 'metacriteria', + rule, + [...this.props.index, 'metacriteria', index], + ), + ) } } else { render.push( { const CurrentRules = this.state[type] - const newRules = [...CurrentRules] - - if (newValue) { - newRules[id] = { ...newRules[id], ...newValue } - - this.setState({ - [type]: newRules, - }) - } else { - this.setState({ - [type]: newRules.slice(0, id).concat(newRules.slice(id + 1)), - }) - } + let newRules = [...CurrentRules] + + console.log(id) + + let rule = [...CurrentRules] + id.forEach((index) => { + rule = rule[index] + }) + + let y + id.forEach((index) => { + if (y) { + newRules = { ...newRules[index] } + } + y = index + }) + + console.log(rule) + console.log(newRules) + + + // if (newValue) { + // newRules[id] = { ...newRules[id], ...newValue } + + // this.setState({ + // [type]: newRules, + // }) + // } else { + // this.setState({ + // [type]: newRules.slice(0, id).concat(newRules.slice(id + 1)), + // }) + // } } /**