Sha256: af9c7685b20be9cb236a2adc740cc6850bd391838e21e3fa6254ea7457cc311b

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

class BaseComponent

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

    namespace: "Component"

    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: (scope)->
        if scope.writeAble
            scope.writeTemplate()
        else if scope.readOnly
            scope.readTemplate()
        else
            scope.emptyTemplate()

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


Lanes.Component.Base = Lanes.View.Base.extend(BaseComponent)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lanes-0.0.3 client/javascripts/component/Base.coffee
lanes-0.0.2 client/javascripts/component/Base.coffee
lanes-0.0.1 client/javascripts/component/Base.coffee