<commit_before>import React from 'react'
import Modal from '../modal'
import GenericForm from '../genericform'
import { setup_fields, service_definition } from '../service/utils'
import Loading from '../loading'
import rpc from 'app/rpc'
import { merge } from 'app/utils'

const RuleList = React.createClass({
  componentDidMount(){
    this.updateToggles( $(this.refs.form).find('.checkbox.toggle') )
  },
  updateToggles(sel){
    let self=this
    $(sel).checkbox({
      onChecked(ev){
        console.log("Activated rule name %o", this.name)
        self.props.activateRule(this.name)
      },
      onUnchecked(ev){
        console.log("Dectivated rule name %o", this.name)
        self.props.deactivateRule(this.name)
      }
    })
  },
  componentDidUpdate(newprops){
    this.updateToggles( $(this.refs.form).find('.checkbox.toggle') )
  },
  render(){
    const props = this.props
    if (props.rules.length == 0)
      return (<span/>)
    return (
      <div className="ui equal width form" ref="form">
        <h4 className="ui header">
          Rule presets
        </h4>
        <div className="ui two column grid"  style={{paddingTop:10}}>
        {props.rules.map( (r) => (
          <div key={r.id} className="field column">
            <div className="ui checkbox toggle" data-position="bottom left" data-tooltip={r.description}>
              <input type="checkbox" className="toggle" defaultChecked={r.is_active} name={r.id}/>
              <label>{r.name}</label><commit_msg>Fix use space to change rule preset toggle at service settings<commit_after>import React from 'react'
import Modal from '../modal'
import GenericForm from '../genericform'
import { setup_fields, service_definition } from '../service/utils'
import Loading from '../loading'
import rpc from 'app/rpc'
import { merge } from 'app/utils'

const RuleList = React.createClass({
  componentDidMount(){
    this.updateToggles( $(this.refs.form).find('.checkbox.toggle') )
  },
  updateToggles(sel){
    let self=this
    $(sel).checkbox({
      onChecked(){
        self.props.activateRule(this.name)
      },
      onUnchecked(){
        self.props.deactivateRule(this.name)
      }
    }).addClass("ready")
  },
  componentDidUpdate(newprops){
    this.updateToggles( $(this.refs.form).find('.checkbox.toggle:not(.ready)') )
  },
  render(){
    const props = this.props
    if (props.rules.length == 0)
      return (<span/>)
    return (
      <div className="ui equal width form" ref="form">
        <h4 className="ui header">
          Rule presets
        </h4>
        <div className="ui two column grid"  style={{paddingTop:10}}>
        {props.rules.map( (r) => (
          <div key={r.id} className="field column">
            <div className="ui checkbox toggle" data-position="bottom left" data-tooltip={r.description}>
              <input type="checkbox" className="toggle" defaultChecked={r.is_active} name={r.id}/>
              <label>{r.name}</label>
{'fraction_non_alphanumeric': 0.15382014874915484, 'fraction_numerical': 0.0033806626098715348, 'mean_word_length': 2.9506008010680906, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '1553193', 'n_tokens_mistral': 895, 'n_tokens_neox': 880, 'n_words': 206}