<commit_before>class Lanes.Components.RecordFinder.Dialog extends Lanes.React.Component

    modelBindings:
        clauses: ->
            @props.query.clauses

    propTypes:
        query: Lanes.PropTypes.State.isRequired
        onRecordSelect: React.PropTypes.func.isRequired

    contextTypes:
        viewport: Lanes.PropTypes.State.isRequired

    warning: ->
        <BS.Alert bsStyle='warning'>
             <strong>{@model.lastServerMessage}</strong>
        </BS.Alert>

    onRecordSelect: (model) ->
        return unless model
        @props.query.loadModel(model).then @props.onRecordSelect
        _.delay( =>
            @onCancel()
        , 300)

    onCancel: ->
        @context.viewport.hideModal()

    addClause: ->
        @props.query.addNewClause()
    selectFirst: ->
        model = @props.query.results.modelAt(0)
        @onRecordSelect(model) if model

    onColumnSort: (field) ->
        clause = @clauses.last()
        clause.field = field
        _.dom(@, '.clause:last-child .query-string').focusAndSelect()

    render: ->
        <div className='record-finder-dialog row'>
            <div className="form-horizontal query-clauses">
            { for c in @clauses.models
                <LC.RecordFinder.Clause
                    key={c.cid} onEnter={@selectFirst}
                    onAddClause={@addClause} model=c /> }
            </div>
            <LC.Grid
                onColumnClick={@onColumnSort}
                query={@props.query} height=200 autoLoadQuery
                onSelectionChange={@onRecordSelect}<commit_msg>focus selected row while loading<commit_after>class Lanes.Components.RecordFinder.Dialog extends Lanes.React.Component

    modelBindings:
        clauses: ->
            @props.query.clauses

    propTypes:
        query: Lanes.PropTypes.State.isRequired
        onRecordSelect: React.PropTypes.func.isRequired

    contextTypes:
        viewport: Lanes.PropTypes.State.isRequired

    getInitialState: -> {}

    warning: ->
        <BS.Alert bsStyle='warning'>
             <strong>{@model.lastServerMessage}</strong>
        </BS.Alert>

    isGridRowFocused: (row, index) ->
        @state.selectedRow is index

    onRecordSelect: (model, selectedRow) ->
        @setState({selectedRow})
        @props.query.markModified()
        return unless model
        @props.query.loadModel(model).then @props.onRecordSelect
        _.delay( =>
            @onCancel()
        , 300)

    onCancel: ->
        @context.viewport.hideModal()

    addClause: ->
        @props.query.addNewClause()
    selectFirst: ->
        model = @props.query.results.modelAt(0)
        @onRecordSelect(model) if model

    onColumnSort: (field) ->
        clause = @clauses.last()
        clause.field = field
        _.dom(@, '.clause:last-child .query-string').focusAndSelect()

    render: ->
        <div className='record-finder-dialog row'>
            <div className="form-horizontal query-clauses">
            { for c in @clauses.models
                <LC.RecordFinder.Clause
                    key={c.cid} onEnter={@selectFirst}
                    onAddClause={@addClause} model=c /> }
            </div>
            <LC.Grid
                onColumnClick={@onColumnSort}
                isRowFocused={@isGridRowFocused}
                query={@props.query} height=200 autoLoadQuery
                onSelectionChange={@onRecordSelect}
{'fraction_non_alphanumeric': 0.1179923686527737, 'fraction_numerical': 0.004109186968007044, 'mean_word_length': 2.005291005291005, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 39, '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': '1684963', 'n_tokens_mistral': 982, 'n_tokens_neox': 960, 'n_words': 158}