<commit_before>﻿import * as React from 'react'
import { UserQueryEntity, UserQueryMessage, QueryFilterEntity, QueryOrderEntity, QueryColumnEntity } from '../Signum.Entities.UserQueries'
import { FormGroup, FormControlStatic, EntityComponent, ValueLine, ValueLineType, EntityLine, EntityCombo, EntityList, EntityRepeater, EntityFrame} from '../../../../Framework/Signum.React/Scripts/Lines'
import * as Finder from '../../../../Framework/Signum.React/Scripts/Finder'
import { QueryDescription, SubTokensOptions } from '../../../../Framework/Signum.React/Scripts/FindOptions'
import { getQueryNiceName } from '../../../../Framework/Signum.React/Scripts/Reflection'
import { TypeContext, FormGroupStyle } from '../../../../Framework/Signum.React/Scripts/TypeContext'
import QueryTokenEntityBuilder from '../../UserAssets/Templates/QueryTokenEntityBuilder'

const CurrentEntityKey = "[CurrentEntity]";
export default class UserQuery extends EntityComponent<UserQueryEntity> {

    renderEntity() {

        var queryKey = this.entity.query.key;
        var ctx = this.props.ctx;

        return (
            <div>
                <EntityLine ctx={ctx.subCtx(e => e.owner) } />
                <ValueLine ctx={ctx.subCtx(e => e.displayName) } />
                <FormGroup ctx={ctx.subCtx(e => e.query) }>
                    {
                        Finder.isFindable(queryKey) ?
                            <a className="form-control-static" href={Finder.findOptionsPath({ queryName: queryKey }) }>{getQueryNiceName(queryKey) }</a> :
                            <span>{getQueryNiceName(queryKey) }</span>
                    }
                </FormGroup>
                <EntityLine ctx={ctx.subCtx(e => e.entityType) } onChange={() => this.forceUpdate() }/>
                {
                    this.entity.entityType &&
                    <p className="messageEntity col-sm-offset-2">
                        {UserQueryMessage.Use0ToFilterCurrentEntity.niceToString(CurrentEntityKey) }
                    </p>
                }
                <ValueLine ctx={ctx.subCtx(e => e.withoutFilters) } />
                <div className="form-xs">
                    <div className="repeater-inline form-inline sf-filters-list ">
                        <EntityRepeater ctx={ctx.subCtx(e => e.filters) } getComponent={this.renderFilter}/>
                    </div>
                    <ValueLine ctx={ctx.subCtx(e => e.columnsMode) } />
                    <div className="repeater-inline form-inline sf-filters-list ">
                        <EntityRepeater ctx={ctx.subCtx(e => e.columns) } getComponent={this.renderColumn}/>
                    </div>
                    <div className="repeater-inline form-inline sf-filters-list ">
                        <EntityRepeater ctx={ctx.subCtx(e => e.orders) } getComponent={this.renderOrder}/>
                    </div>
                </div>
                <div className="row">
                    <div className="col-sm-6">
                        <ValueLine ctx={ctx.subCtx(e => e.paginationMode, { labelColumns: { sm: 4 } }) } />
                    </div>
                    <div className="col-sm-6">
                        <ValueLine ctx={ctx.subCtx(e => e.elementsPerPage, { labelColumns: { sm: 4 } }) } />
                    </div>
                </div>
            </div>
        );
    }

    renderFilter = (ctx: TypeContext<QueryFilterEntity>) => {
        var ctx2 = ctx.subCtx({ formGroupStyle: FormGroupStyle.None });
        return (
            <div>
                <QueryTokenEntityBuilder
                    ctx={ctx2.subCtx(a => a.token, { formGroupStyle: FormGroupStyle.None }) }
                    queryKey={this.entity.query.key}
                    subTokenOptions={SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement} />
                <span style={{ margin: "0px 10px" }}>
                    <ValueLine ctx={ctx2.subCtx(e => e.operation) } />
                </span>
                <ValueLine ctx={ctx2.subCtx(e => e.valueString) } />
            </div>
        );
    }

    renderColumn = (ctx: TypeContext<QueryColumnEntity>) => {
        var ctx2 = ctx.subCtx({ formGroupStyle: FormGroupStyle.None });
        return (
            <div>
                <QueryTokenEntityBuilder<commit_msg>fix UserQuery<commit_after>﻿import * as React from 'react'
import { UserQueryEntity, UserQueryMessage, QueryFilterEntity, QueryOrderEntity, QueryColumnEntity } from '../Signum.Entities.UserQueries'
import { FormGroup, FormControlStatic, EntityComponent, ValueLine, ValueLineType, EntityLine, EntityCombo, EntityList, EntityRepeater, EntityFrame} from '../../../../Framework/Signum.React/Scripts/Lines'
import * as Finder from '../../../../Framework/Signum.React/Scripts/Finder'
import { QueryDescription, SubTokensOptions } from '../../../../Framework/Signum.React/Scripts/FindOptions'
import { getQueryNiceName } from '../../../../Framework/Signum.React/Scripts/Reflection'
import { TypeContext, FormGroupStyle } from '../../../../Framework/Signum.React/Scripts/TypeContext'
import QueryTokenEntityBuilder from '../../UserAssets/Templates/QueryTokenEntityBuilder'

const CurrentEntityKey = "[CurrentEntity]";
export default class UserQuery extends EntityComponent<UserQueryEntity> {

    renderEntity() {

        var queryKey = this.entity.query.key;
        var ctx = this.props.ctx;

        return (
            <div>
                <EntityLine ctx={ctx.subCtx(e => e.owner) } />
                <ValueLine ctx={ctx.subCtx(e => e.displayName) } />
                <FormGroup ctx={ctx.subCtx(e => e.query) }>
                    {
                        Finder.isFindable(queryKey) ?
                            <a className="form-control-static" href={Finder.findOptionsPath({ queryName: queryKey }) }>{getQueryNiceName(queryKey) }</a> :
                            <span>{getQueryNiceName(queryKey) }</span>
                    }
                </FormGroup>
                <EntityLine ctx={ctx.subCtx(e => e.entityType) } onChange={() => this.forceUpdate() }/>
                {
                    this.entity.entityType &&
                    <p className="messageEntity col-sm-offset-2">
                        {UserQueryMessage.Use0ToFilterCurrentEntity.niceToString(CurrentEntityKey) }
                    </p>
                }
                <ValueLine ctx={ctx.subCtx(e => e.withoutFilters) } />
                <div className="form-xs">
                    <div className="repeater-inline form-inline sf-filters-list ">
                        <EntityRepeater ctx={ctx.subCtx(e => e.filters) } getComponent={this.renderFilter}/>
                    </div>
                    <ValueLine ctx={ctx.subCtx(e => e.columnsMode) } />
                    <div className="repeater-inline form-inline sf-filters-list ">
                        <EntityRepeater ctx={ctx.subCtx(e => e.columns) } getComponent={this.renderColumn}/>
                    </div>
                    <div className="repeater-inline form-inline sf-filters-list ">
                        <EntityRepeater ctx={ctx.subCtx(e => e.orders) } getComponent={this.renderOrder}/>
                    </div>
                </div>
                <div className="row">
                    <div className="col-sm-6">
                        <ValueLine ctx={ctx.subCtx(e => e.paginationMode, { labelColumns: { sm: 4 } }) } />
                    </div>
                    <div className="col-sm-6">
                        <ValueLine ctx={ctx.subCtx(e => e.elementsPerPage, { labelColumns: { sm: 4 } }) } />
                    </div>
                </div>
            </div>
        );
    }

    renderFilter = (ctx: TypeContext<QueryFilterEntity>) => {
        var ctx2 = ctx.subCtx({ formGroupStyle: FormGroupStyle.None });
        return (
            <div>
                <QueryTokenEntityBuilder
                    ctx={ctx2.subCtx(a => a.token, { formGroupStyle: FormGroupStyle.None }) }
                    queryKey={this.entity.query.key}
                    subTokenOptions={SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement} />
                <span style={{ margin: "0px 10px" }}>
                    <ValueLine ctx={ctx2.subCtx(e => e.operation) } />
                </span>
                <ValueLine ctx={ctx2.subCtx(e => e.valueString) } valueHtmlProps={{ size: 50 }} />
            </div>
        );
    }

    renderColumn = (ctx: TypeContext<QueryColumnEntity>) => {
        var ctx2 = ctx.subCtx({ formGroupStyle: FormGroupStyle.None });
        return (
            <div>
                <QueryTokenEntityBuilder
{'fraction_non_alphanumeric': 0.13774680603948897, 'fraction_numerical': 0.003484320557491289, 'mean_word_length': 1.7867313915857606, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 127, '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': '934700', 'n_tokens_mistral': 2351, 'n_tokens_neox': 2307, 'n_words': 399}