Sha256: cf9e4643f293b19a179da529f713f666c435f171bbbf0f9d7ac7b10e09538744

Contents?: true

Size: 868 Bytes

Versions: 3

Compression:

Stored size: 868 Bytes

Contents

class Lanes.Screens.Commands extends Lanes.Models.State

    constructor: (@screen, @options = {}) ->
        _.defaults(@options, modelName: 'model')
        _.bindAll(this, _.functionsIn(this))

    resetModel: ->
        model = @getModel()
        @setModel( new model.constructor )
        undefined

    getModel: -> @screen[@options.modelName]

    setModel: (model) ->
        @options.modelWillRebind?(model)
        @screen.data.rebind("#{@options.modelName}": model)
        @screen.setModelUrl?(model)
        @options.modelDidRebind?(model)

    canEditModel: ->
        @screen.hasWriteAccess?()

    getSyncOptions: ->
        _.result(@screen, 'syncOptions') || {}

    saveModel: ->
        @getModel().save(@getSyncOptions())

    toggleEdit: ->
        @screen.setState(isEditing: !@isEditing())

    isEditing: ->
        !!@screen.state.isEditing

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lanes-0.5.6 client/lanes/screens/Commands.coffee
lanes-0.5.5 client/lanes/screens/Commands.coffee
lanes-0.5.0 client/lanes/screens/Commands.coffee