Sha256: f417a4f039d31ffccc74fe53b6d49397ded8008e120e483e80d48f83a2f3d8cc

Contents?: true

Size: 1019 Bytes

Versions: 3

Compression:

Stored size: 1019 Bytes

Contents

class BaseComponent

    constructor: (options={})->
        super
        @access ||= this.calculate_access()

    namespace: "Components"

    session:
        access:
            type: 'string',
            values: ['read','write','none']

    derived:
        readOnly:  { deps: ['access'], fn:-> @access=='read' }
        writeAble: { deps: ['access'], fn:-> @access=='write' }

    readTemplate:  -> @renderTemplateMethod('template')
    writeTemplate: -> @renderTemplateMethod('template')
    emptyTemplate: -> '<span></span>'

    template: ->
        if this.writeAble
            this.writeTemplate()
        else if this.readOnly
            this.readTemplate()
        else
            this.emptyTemplate()

    calculate_access:->
        if ! @field_name || Lanes.Views.RenderContext.canWrite(@field_name)
            'write'
        else if Lanes.Views.RenderContext.canRead(@field_name)
            'read'
        else
            'none'


Lanes.Components.Base = Lanes.Views.Base.extend(BaseComponent)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lanes-0.1.0 client/lanes/components/Base.coffee
lanes-0.0.8 client/lanes/components/Base.coffee
lanes-0.0.5 client/lanes/components/Base.coffee