<commit_before>import * as React from "react";
import { ListAndFormProps, ToolBayFormState } from "../interfaces";
import { Widget, WidgetBody, WidgetHeader } from "../../ui";
import { BlurableInput } from "../../blurable_input";
import { saveToolBays, destroySlot, addSlot, updateSlot } from "../actions";
import { t } from "i18next";

export class ToolBayForm extends React.Component<ListAndFormProps,
    ToolBayFormState> {
    constructor() {
        super();
        this.set = this.set.bind(this);
        this.update = this.update.bind(this);
        this.add = this.add.bind(this);
        this.resetState = this.resetState.bind(this);
        this.state = { x: "0", y: "0", z: "0", name: "", tool_bay_id: 0 };
    }

    resetState() {
        this.setState({ x: "0", y: "0", z: "0", name: "", tool_bay_id: 0 });
    }

    set(e: React.SyntheticEvent<HTMLInputElement> |
        React.SyntheticEvent<HTMLSelectElement>) {
        let { name, value } = e.currentTarget;
        this.setState({ [name]: value });
    }

    update(e: React.SyntheticEvent<HTMLInputElement> |
        React.SyntheticEvent<HTMLSelectElement>) {
        let { id, name, value } = e.currentTarget;
        let data = { slot_id: id, property: name, value: value };
        this.props.dispatch(updateSlot(data));
    }

    add(bay_id: number) {
        let slotState = this.state;
        this.props.dispatch(addSlot({ slotState, bay_id }));
        this.resetState();
    }

    render() {
        let { set, update, add } = this;
        let {dispatch} = this.props;
        let {tool_bays, tool_slots, tools } = this.props.all;
        let slotNum = 0;
        return <div>
            {tool_bays.map((bay, i = 0) => {
                let { name } = bay;
                let bayId = bay.id;
                i++;
                return <Widget key={name}>
                    <WidgetHeader
                        helpText="Bays are for Tools"
                        title={name}>
                        <button
                            className="green button-like widget-control"
                            onClick={dispatch(saveToolBays)}>
                            {t("SAVE")}
                        </button>
                    </WidgetHeader>
                    <WidgetBody>
                        <table>
                            <tbody>
                                <tr>
                                    <td>
                                        <label>TOOLBAY NAME</label>
                                    </td>
                                    <td>
                                        <BlurableInput
                                            value={name}
                                            onCommit={set}
                                            />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <table>
                            <thead>
                                <tr>
                                    <th>SLOT</th>
                                    <th>X</th>
                                    <th>Y</th>
                                    <th>Z</th>
                                    <th>TOOL</th>
                                </tr>
                            </thead>
                            <tbody>
                                {tool_slots.map(slot => {
                                    let { x, y, z } = slot;
                                    let slotId = slot.id;
                                    slotNum++;
                                    return <tr key={slotNum}>
                                        <td>
                                            {slotNum}
                                        </td>
                                        <td>
                                            <BlurableInput
                                                type="number"
                                                id={`${slotId}`}
                                                name="x"
                                                value={x.toString()}
                                                onCommit={update}
                                                />
                                        </td>
                                        <td>
                                            <BlurableInput
                                                type="number"
                                                id={`${slotId}`}
                                                name="y"
                                                value={y.toString()}
                                                onCommit={update}
                                                />
                                        </td>
                                        <td>
                                            <BlurableInput
                                                type="number"
                                                id={`${slotId}`}
                                                name="z"
                                                value={z.toString()}
                                                onCommit={update}
                                                /><commit_msg>fix id strings in toolbay form<commit_after>import * as React from "react";
import { ListAndFormProps, ToolBayFormState } from "../interfaces";
import { Widget, WidgetBody, WidgetHeader } from "../../ui";
import { BlurableInput } from "../../blurable_input";
import { saveToolBays, destroySlot, addSlot, updateSlot } from "../actions";
import { t } from "i18next";

export class ToolBayForm extends React.Component<ListAndFormProps,
    ToolBayFormState> {
    constructor() {
        super();
        this.set = this.set.bind(this);
        this.update = this.update.bind(this);
        this.add = this.add.bind(this);
        this.resetState = this.resetState.bind(this);
        this.state = { x: "0", y: "0", z: "0", name: "", tool_bay_id: 0 };
    }

    resetState() {
        this.setState({ x: "0", y: "0", z: "0", name: "", tool_bay_id: 0 });
    }

    set(e: React.SyntheticEvent<HTMLInputElement> |
        React.SyntheticEvent<HTMLSelectElement>) {
        let { name, value } = e.currentTarget;
        this.setState({ [name]: value });
    }

    update(e: React.SyntheticEvent<HTMLInputElement> |
        React.SyntheticEvent<HTMLSelectElement>) {
        let { id, name, value } = e.currentTarget;
        let data = { slot_id: id, property: name, value: value };
        this.props.dispatch(updateSlot(data));
    }

    add(bay_id: number) {
        let slotState = this.state;
        this.props.dispatch(addSlot({ slotState, bay_id }));
        this.resetState();
    }

    render() {
        let { set, update, add } = this;
        let {dispatch} = this.props;
        let {tool_bays, tool_slots, tools } = this.props.all;
        let slotNum = 0;
        return <div>
            {tool_bays.map((bay, i = 0) => {
                let { name } = bay;
                let bayId = bay.id;
                i++;
                return <Widget key={name}>
                    <WidgetHeader
                        helpText="Bays are for Tools"
                        title={name}>
                        <button
                            className="green button-like widget-control"
                            onClick={dispatch(saveToolBays)}>
                            {t("SAVE")}
                        </button>
                    </WidgetHeader>
                    <WidgetBody>
                        <table>
                            <tbody>
                                <tr>
                                    <td>
                                        <label>TOOLBAY NAME</label>
                                    </td>
                                    <td>
                                        <BlurableInput
                                            value={name}
                                            onCommit={set}
                                            />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <table>
                            <thead>
                                <tr>
                                    <th>SLOT</th>
                                    <th>X</th>
                                    <th>Y</th>
                                    <th>Z</th>
                                    <th>TOOL</th>
                                </tr>
                            </thead>
                            <tbody>
                                {tool_slots.map(slot => {
                                    let { x, y, z } = slot;
                                    let slotId = slot.id;
                                    slotNum++;
                                    return <tr key={slotNum}>
                                        <td>
                                            {slotNum}
                                        </td>
                                        <td>
                                            <BlurableInput
                                                type="number"
                                                id={(slotId || "").toString()}
                                                name="x"
                                                value={x.toString()}
                                                onCommit={update}
                                                />
                                        </td>
                                        <td>
                                            <BlurableInput
                                                type="number"
                                                id={(slotId || "").toString()}
                                                name="y"
                                                value={y.toString()}
                                                onCommit={update}
                                                />
                                        </td>
                                        <td>
                                            <BlurableInput
                                                type="number"
                                                id={(slotId || "").toString()}
                                                name="z"
                                                value={z.toString()}
                                                onCommit={update}
                                                />
{'fraction_non_alphanumeric': 0.09614849187935035, 'fraction_numerical': 0.0022273781902552203, 'mean_word_length': 0.6369436427160869, 'pattern_counts': {'":': 0, '<': 107, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 146, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2541154', 'n_tokens_mistral': 2178, 'n_tokens_neox': 2107, 'n_words': 440}