<commit_before>﻿
import * as React from 'react'
import { Modal, ModalProps, ModalClass, ButtonToolbar } from 'react-bootstrap'
import * as Finder from '../Finder'
import { Dic, areEqual } from '../Globals'
import { openModal, IModalProps } from '../Modals';
import { FilterOption, QueryDescription, QueryToken, SubTokensOptions, filterOperations, FilterType, isList, FilterOperation } from '../FindOptions'
import { SearchMessage, JavascriptMessage, Lite, Entity } from '../Signum.Entities'
import { ValueLine, EntityLine, EntityCombo } from '../Lines'
import { Binding, IsByAll, getTypeInfos } from '../Reflection'
import { TypeContext, FormGroupStyle } from '../TypeContext'
import QueryTokenBuilder from './QueryTokenBuilder'

require("!style!css!./FilterBuilder.css");

interface FilterBuilderProps extends React.Props<FilterBuilder> {
    filterOptions: FilterOption[];
    subTokensOptions: SubTokensOptions;
    queryDescription: QueryDescription;
    tokenChanged: (token: QueryToken) => void;
    lastToken: QueryToken;
}

export default class FilterBuilder extends React.Component<FilterBuilderProps, {}>  {

    handlerNewFilter = () => {

        this.props.filterOptions.push({
            token: this.props.lastToken,
            columnName: null,
            operation: !this.props.lastToken ? null : (filterOperations[this.props.lastToken.filterType] || []).firstOrNull(),
            value: null,
        });
        this.forceUpdate();
    };

    handlerDeleteFilter = (filter: FilterOption) => {
        this.props.filterOptions.remove(filter);
        this.forceUpdate();
    };

    render() {


        return (
            <div className="panel panel-default sf-filters form-xs">
                <div className="panel-body sf-filters-list table-responsive" style={{ overflowX: "visible" }}>
                    {
                        <table className="table table-condensed">
                            <thead>
                                <tr>
                                    <th style={{ minWidth: "24px" }}></th>
                                    <th className="sf-filter-field-header">{ SearchMessage.Field.niceToString() }</th>
                                    <th>{ SearchMessage.Operation.niceToString() }</th>
                                    <th>{ SearchMessage.Value.niceToString() }</th>
                                </tr>
                            </thead>
                            <tbody>
                                {this.props.filterOptions.map((f, i) => <FilterComponent filter={f} key={i}
                                    onDeleteFilter={this.handlerDeleteFilter}
                                    subTokenOptions={this.props.subTokensOptions}
                                    queryDescription={this.props.queryDescription}
                                    tokenChanged ={this.props.tokenChanged} />) }
                                <tr >
                                    <td colSpan={4}>
                                        <a title={SearchMessage.AddFilter.niceToString() }
                                            className="sf-line-button sf-create"
                                            onClick={this.handlerNewFilter}>
                                            <span className="glyphicon glyphicon-plus" style={{ marginRight: "5px" }}/>{SearchMessage.AddFilter.niceToString() }
                                        </a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    }
                </div>

            </div>
        );
    }
}
<commit_msg>fix FilterBuilder<commit_after>﻿
import * as React from 'react'
import { Modal, ModalProps, ModalClass, ButtonToolbar } from 'react-bootstrap'
import * as Finder from '../Finder'
import { Dic, areEqual } from '../Globals'
import { openModal, IModalProps } from '../Modals';
import { FilterOption, QueryDescription, QueryToken, SubTokensOptions, filterOperations, FilterType, isList, FilterOperation } from '../FindOptions'
import { SearchMessage, JavascriptMessage, Lite, Entity } from '../Signum.Entities'
import { ValueLine, EntityLine, EntityCombo } from '../Lines'
import { Binding, IsByAll, getTypeInfos } from '../Reflection'
import { TypeContext, FormGroupStyle } from '../TypeContext'
import QueryTokenBuilder from './QueryTokenBuilder'

require("!style!css!./FilterBuilder.css");

interface FilterBuilderProps extends React.Props<FilterBuilder> {
    filterOptions: FilterOption[];
    subTokensOptions: SubTokensOptions;
    queryDescription: QueryDescription;
    tokenChanged: (token: QueryToken) => void;
    lastToken: QueryToken;
}

export default class FilterBuilder extends React.Component<FilterBuilderProps, {}>  {

    handlerNewFilter = () => {

        this.props.filterOptions.push({
            token: this.props.lastToken,
            columnName: null,
            operation: !this.props.lastToken ? null : (filterOperations[this.props.lastToken.filterType] || []).firstOrNull(),
            value: null,
        });
        this.forceUpdate();
    };

    handlerDeleteFilter = (filter: FilterOption) => {
        this.props.filterOptions.remove(filter);
        this.forceUpdate();
    };

    render() {


        return (
            <div className="panel panel-default sf-filters form-xs">
                <div className="panel-body sf-filters-list table-responsive" style={{ overflowX: "visible" }}>
                    {
                        <table className="table table-condensed">
                            <thead>
                                <tr>
                                    <th style={{ minWidth: "24px" }}></th>
                                    <th className="sf-filter-field-header">{ SearchMessage.Field.niceToString() }</th>
                                    <th>{ SearchMessage.Operation.niceToString() }</th>
                                    <th>{ SearchMessage.Value.niceToString() }</th>
                                </tr>
                            </thead>
                            <tbody>
                                {this.props.filterOptions.map((f, i) => <FilterComponent filter={f} key={i}
                                    onDeleteFilter={this.handlerDeleteFilter}
                                    subTokenOptions={this.props.subTokensOptions}
                                    queryDescription={this.props.queryDescription}
                                    tokenChanged ={this.props.tokenChanged} />) }
                                <tr >
                                    <td colSpan={4}>
                                        <a title={SearchMessage.AddFilter.niceToString() }
                                            className="sf-line-button sf-create"
                                            onClick={this.handlerNewFilter}>
                                            <span className="glyphicon glyphicon-plus"/><span style={{ marginLeft: "5px", marginRight: "5px" }}> {SearchMessage.AddFilter.niceToString() } </span>
                                        </a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    }
                </div>

            </div>
        );
    }
}

{'fraction_non_alphanumeric': 0.11319989180416554, 'fraction_numerical': 0.0012172031376791995, 'mean_word_length': 1.5008454514710856, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1785464', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1696, 'n_words': 360}