<commit_before>import React, {Component} from "react";
import FiltersPanel from "./filters_panel";
import ControlPanel from "./control_panel";
import layerPanel from "../../../styles/components/c_layer_panel.scss";
import {Accordion, AccordionItem} from "react-sanfona";

class LayerPanel extends Component {

  constructor(props) {
    super(props);

    this.state = {
      hasSearchResults: false,
      visibleSearchResults: false,
      visibleAdvancedSearch: false
    };
  }

  fakeSearchResults(event) {
    this.setState({
      hasSearchResults: !!event.target.value.length,
      visibleSearchResults: !!event.target.value.length && !this.state.visibleAdvancedSearch
    });
  }

  toggleVisibleAdvancedSearch() {
    this.setState({
      visibleAdvancedSearch: !this.state.visibleAdvancedSearch,
      visibleSearchResults: this.state.visibleAdvancedSearch && this.state.hasSearchResults
    })
  }

  render() {
    let layers = [];
    if (this.props.layers) {
      for (let i = 0, length = this.props.layers.length; i < length; i++) {
        layers.push(
          <li className={layerPanel.list_checkbox} key={i}>
            <label>
              <input type="checkbox" checked={this.props.layers[i].visible}
                     onChange={(e) => this.props.onToggle(this.props.layers[i])}></input>
              {this.props.layers[i].title}
            </label>
          </li>
        );
      }
    }

    let searchAccordionTitle = <input onChange={this.fakeSearchResults.bind(this)} className={layerPanel.input_accordion} placeholder="SEARCH VESSELS"></input>;

    let baseMapAccordionTitle = <div className={layerPanel.title_accordion}>Basemap
      <div className={layerPanel.content_box}>
        <div className={layerPanel.box_basemap}></div>
        <div className={layerPanel.box_image_basemap}></div>
      </div>
    </div>;
    let layersAccordionTitle = <span className={layerPanel.title_accordion}>Layers</span>
    let controlAccordionTitle = <span className={layerPanel.title_accordion}>Control</span>;
    let advancedSearchAccordionTitle = <span onClick={this.toggleVisibleAdvancedSearch.bind(this)} className={layerPanel.text_search}>{this.state.visibleAdvancedSearch ? 'hide advanced search' : 'advanced search'}</span>;


    let advancedSearchAccordion = <Accordion allowMultiple={false} activeItems={6}>
      <AccordionItem title={advancedSearchAccordionTitle} key="advancedsearch">
        <div className={layerPanel.content_accordion}>
          <div><commit_msg>Fixes an issue where the layers couldn't be toggled<commit_after>import React, {Component} from "react";
import FiltersPanel from "./filters_panel";
import ControlPanel from "./control_panel";
import layerPanel from "../../../styles/components/c_layer_panel.scss";
import {Accordion, AccordionItem} from "react-sanfona";

class LayerPanel extends Component {

  constructor(props) {
    super(props);

    this.state = {
      hasSearchResults: false,
      visibleSearchResults: false,
      visibleAdvancedSearch: false
    };
  }

  fakeSearchResults(event) {
    this.setState({
      hasSearchResults: !!event.target.value.length,
      visibleSearchResults: !!event.target.value.length && !this.state.visibleAdvancedSearch
    });
  }

  toggleVisibleAdvancedSearch() {
    this.setState({
      visibleAdvancedSearch: !this.state.visibleAdvancedSearch,
      visibleSearchResults: this.state.visibleAdvancedSearch && this.state.hasSearchResults
    })
  }

  render() {
    let layers = [];
    if (this.props.layers) {
      for (let i = 0, length = this.props.layers.length; i < length; i++) {
        layers.push(
          <li className={layerPanel.list_checkbox} key={i}>
            <label>
              <input type="checkbox" checked={this.props.layers[i].visible}
                     onChange={(e) => this.props.onLayerToggle(this.props.layers[i])}></input>
              {this.props.layers[i].title}
            </label>
          </li>
        );
      }
    }

    let searchAccordionTitle = <input onChange={this.fakeSearchResults.bind(this)} className={layerPanel.input_accordion} placeholder="SEARCH VESSELS"></input>;

    let baseMapAccordionTitle = <div className={layerPanel.title_accordion}>Basemap
      <div className={layerPanel.content_box}>
        <div className={layerPanel.box_basemap}></div>
        <div className={layerPanel.box_image_basemap}></div>
      </div>
    </div>;
    let layersAccordionTitle = <span className={layerPanel.title_accordion}>Layers</span>
    let controlAccordionTitle = <span className={layerPanel.title_accordion}>Control</span>;
    let advancedSearchAccordionTitle = <span onClick={this.toggleVisibleAdvancedSearch.bind(this)} className={layerPanel.text_search}>{this.state.visibleAdvancedSearch ? 'hide advanced search' : 'advanced search'}</span>;


    let advancedSearchAccordion = <Accordion allowMultiple={false} activeItems={6}>
      <AccordionItem title={advancedSearchAccordionTitle} key="advancedsearch">
        <div className={layerPanel.content_accordion}>
          <div>
{'fraction_non_alphanumeric': 0.12961136318800554, 'fraction_numerical': 0.000789110278161373, 'mean_word_length': 3.6471127406049497, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, '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': '4996367', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1434, 'n_words': 255}