<commit_before>class CascadingSelect extends React.Component {
  constructor(props) {
    super();
    this.nodeChanged = this.nodeChanged.bind(this);
    this.buildUrl = this.buildUrl.bind(this);
    this.buildLevelProps = this.buildLevelProps.bind(this);
    this.buildLevels = this.buildLevels.bind(this);
    this.isLastLevel = this.isLastLevel.bind(this);
    this.state = props;
  }

  componentDidMount() {
    this.getData(this.state.option_set_id, this.state.option_node_id);
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.option_set_id != this.state.option_set_id) {
      this.getData(nextProps.option_set_id, nextProps.option_node_id);
    }
  }

  nodeChanged(newNodeId) {
    this.getData(this.state.option_set_id, newNodeId);
  }

  // Fetches data to populate the control. nodeId may be null if there is no node selected.
  getData(setId, nodeId) {
    ELMO.app.loading(true);
    var self = this;
    var url = this.buildUrl(setId, nodeId);
    $.ajax(url)
      .done(function(response) {
          self.setState(response);
        })
        .fail(function(jqXHR, exception){
          console.log(exception);
        })
        .always(function() {
          ELMO.app.loading(false);
        });
  }

  buildUrl(setId, nodeId) {
    return `${ELMO.app.url_builder.build('option-sets', setId, 'condition-form-view')}?node_id=${nodeId}`;
  }

  buildLevelProps(level, isLastLevel) {
    return {
      type: "select",
      name: `${this.state.name_prefix}[option_node_ids][]`,
      id: `questioning_display_conditions_attributes_option_node_ids_`,<commit_msg>7172: Comment<commit_after>class CascadingSelect extends React.Component {
  constructor(props) {
    super();
    this.nodeChanged = this.nodeChanged.bind(this);
    this.buildUrl = this.buildUrl.bind(this);
    this.buildLevelProps = this.buildLevelProps.bind(this);
    this.buildLevels = this.buildLevels.bind(this);
    this.isLastLevel = this.isLastLevel.bind(this);
    this.state = props;
  }

  // Refresh data on mount.
  componentDidMount() {
    this.getData(this.state.option_set_id, this.state.option_node_id);
  }

  // Refresh data if the option set is changing.
  componentWillReceiveProps(nextProps) {
    if (nextProps.option_set_id != this.state.option_set_id) {
      this.getData(nextProps.option_set_id, nextProps.option_node_id);
    }
  }

  // Refresh data if the selected node changed.
  nodeChanged(newNodeId) {
    this.getData(this.state.option_set_id, newNodeId);
  }

  // Fetches data to populate the control. nodeId may be null if there is no node selected.
  getData(setId, nodeId) {
    ELMO.app.loading(true);
    var self = this;
    var url = this.buildUrl(setId, nodeId);
    $.ajax(url)
      .done(function(response) {
          self.setState(response);
        })
        .fail(function(jqXHR, exception){
          console.log(exception);
        })
        .always(function() {
          ELMO.app.loading(false);
        });
  }

  buildUrl(setId, nodeId) {
    return `${ELMO.app.url_builder.build('option-sets', setId, 'condition-form-view')}?node_id=${nodeId}`;
  }

  buildLevelProps(level, isLastLevel) {
    return {
      type: "select",
      name: `${this.state.name_prefix}[option_node_ids][]`,
      id: `questioning_display_conditions_attributes_option_node_ids_`,
{'fraction_non_alphanumeric': 0.1308411214953271, 'fraction_numerical': 0.0012059089538739825, 'mean_word_length': 3.3035019455252916, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '131499', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1105, 'n_words': 177}