Sha256: 3a28eb9f55845478644c78733e013ddcee82978d21185b9fec14b4c6f83496b5

Contents?: true

Size: 909 Bytes

Versions: 3

Compression:

Stored size: 909 Bytes

Contents

class Lanes.Components.Toolbar.SaveButton extends Lanes.React.Component

    propTypes:
        commands: React.PropTypes.object.isRequired

    onSave: ->
        model = @props.commands.getModel()
        if @isSavable(model)
            @props.commands.saveModel()
        else
            model.unmaskInvalidField('all')

    isSavable: (model) ->
        if @props.commands.saveModel
            @props.commands.isEditing() and model.isSavable
        else
            false

    render: ->
        return null unless @props.commands.canEditModel()
        model = @props.commands.getModel()
        text = if model.isNew() then 'Create' else 'Save'
        classNames = _.classnames('save', 'navbar-btn', 'control',
            {disabled: !@isSavable(model)}
        )
        <BS.NavItem onClick={@onSave} className={classNames}>
            <LC.Icon type="cloud-upload" />{text}
        </BS.NavItem>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lanes-0.7.0 client/lanes/components/toolbar/SaveButton.cjsx
lanes-0.6.1 client/lanes/components/toolbar/SaveButton.cjsx
lanes-0.6.0 client/lanes/components/toolbar/SaveButton.cjsx