Sha256: 9f9978ae0b7f68d4527ec01dd0181cf8071ceed6794594fc12fd0d7f779a0150

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

class CheckBox extends Lanes.React.BaseComponent
    d: -> @props.query.results.xtraData(@props.row)

    onChange: (ev) -> #, me, results, index) ->
        @d().selected = ev.target.checked
        @props.selections.onChange?(@props)
        @forceUpdate()

    render: ->
        selected = @d().selected
        selected = @props.selections.selectionDefault unless selected?
        <input type="checkbox" checked={selected} onChange={@onChange} />



DEFAULTS =
    id: 'selected'
    query: false
    textAlign: 'center'
    fixedWidth: 90
    selectionDefault: true
    sortBy: (row, indx, all) ->
        false == this.xtraData(indx)?.selected

class Lanes.Components.Grid.Selections
    constructor: (options) ->
        _.extend(@, DEFAULTS)
        @onChange = options.onChange
        @choices = {}
        _.bindAll(@, 'onColumnClick')
        @component = _.partial(@component, _, @)

    onColumnClick: (ev, props) ->
        unless ev.target.tagName is 'INPUT'
            input = ev.target.querySelector('input')
            xd = props.query.results.xtraData(props.rowNum)
            xd.selected = input.checked = !input.checked
        @onChange?(props)
        ev.stopPropagation()

    component: (props, me) ->
        <CheckBox {...props} selections={me} />

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lanes-0.5.6 client/lanes/components/grid/Selections.cjsx
lanes-0.5.5 client/lanes/components/grid/Selections.cjsx
lanes-0.5.0 client/lanes/components/grid/Selections.cjsx
lanes-0.4.0 client/lanes/components/grid/Selections.cjsx